Build with exceptions (fixes the issue with crashes where +initialize throws)

Start adding the tests to CMake.
main
theraven 13 years ago
parent d1f3463ac7
commit d1336543d8

@ -10,6 +10,7 @@ set(CMAKE_C_FLAGS "-std=gnu99 ${CMAKE_C_FLAGS}")
set(libobjc_VERSION 4.6)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fexceptions")
# Build configuration
add_definitions( -DGNUSTEP -D__OBJC_RUNTIME_INTERNAL__=1)
# Probably not needed anymore?
@ -291,6 +292,6 @@ configure_file(
add_custom_target(uninstall
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
#enable_testing()
#add_subdirectory(Test)
enable_testing()
add_subdirectory(Test)

@ -9,6 +9,11 @@ struct big
int a, b, c, d, e;
};
#ifdef __has_attribute
#if __has_attribute(objc_root_class)
__attribute__((objc_root_class))
#endif
#endif
@interface Foo @end
@implementation Foo @end
@interface Foo (Dynamic)

@ -0,0 +1,32 @@
# Clear the LD_LIBRARY_PATH if GNUstep set it so that we don't accidentally use
# the installed version
set(TESTS
objc_msgSend.m
BlockImpTest.m
PropertyIntrospectionTest.m
ProtocolCreation.m
)
#ExceptionTest.m
#PropertyAttributeTest.m
#RuntimeTest.m
foreach(TEST_SOURCE ${TESTS})
get_filename_component(TEST ${TEST_SOURCE} NAME_WE)
add_executable(${TEST} ${TEST_SOURCE})
add_test(${TEST} ${TEST})
set_target_properties(${TEST} PROPERTIES
INCLUDE_DIRECTORIES ".."
COMPILE_FLAGS "-fobjc-runtime=gnustep-1.6 -fblocks"
LANGUAGE C
LINKER_LANGUAGE C
)
set_property(TEST ${TEST} PROPERTY
ENVIRONMENT "LD_LIBRARY_PATH="
)
target_link_libraries(${TEST} objc)
endforeach()

@ -3,6 +3,11 @@
#include <string.h>
#include <assert.h>
#ifdef __has_attribute
#if __has_attribute(objc_root_class)
__attribute__((objc_root_class))
#endif
#endif
@interface Foo
@property (getter=bar, setter=setBar:, nonatomic, copy) id foo;
@end

@ -1,17 +1,15 @@
#include <time.h>
#include <stdio.h>
#include <objc/runtime.h>
#include <assert.h>
#include <string.h>
#include <class.h>
#include <stdarg.h>
#include "objc/runtime.h"
//#define assert(x) if (!(x)) { printf("Failed %d\n", __LINE__); }
id objc_msgSend(id, SEL, ...);
typedef struct { int a,b,c,d,e; } s;
s objc_msgSend_stret(id, SEL, ...);
@interface Fake
- (int)izero;
- (float)fzero;
@ -20,6 +18,11 @@ s objc_msgSend_stret(id, SEL, ...);
@end
Class TestCls;
#ifdef __has_attribute
#if __has_attribute(objc_root_class)
__attribute__((objc_root_class))
#endif
#endif
@interface Test { id isa; }@end
@implementation Test
- foo
@ -90,7 +93,7 @@ int main(void)
assert(objc_registerSmallObjectClass_np(objc_getClass("Test"), 1));
a = objc_msgSend((id)01, @selector(foo));
assert((id)0x42 == a);
s ret = objc_msgSend_stret(TestCls, @selector(sret));
s ret = ((s(*)(id, SEL))objc_msgSend_stret)(TestCls, @selector(sret));
assert(ret.a == 1);
assert(ret.b == 2);
assert(ret.c == 3);
@ -99,7 +102,7 @@ int main(void)
if (sizeof(id) == 8)
{
assert(objc_registerSmallObjectClass_np(objc_getClass("Test"), 3));
ret = objc_msgSend_stret((id)3, @selector(sret));
ret = ((s(*)(id, SEL))objc_msgSend_stret)((id)3, @selector(sret));
assert(ret.a == 1);
assert(ret.b == 2);
assert(ret.c == 3);

Loading…
Cancel
Save