]> git.saurik.com Git - apple/objc4.git/blob - test/gcenforcer.m
objc4-680.tar.gz
[apple/objc4.git] / test / gcenforcer.m
1 /*
2 TEST_CONFIG OS=macosx
3
4 TEST_BUILD
5 $C{COMPILE_C} $DIR/gc.c -dynamiclib -o libnoobjc.dylib
6 $C{COMPILE_NOMEM} $DIR/gc.m -dynamiclib -o libnogc.dylib
7 $C{COMPILE_NOMEM} $DIR/gc.m -dynamiclib -o libsupportsgc.dylib -fobjc-gc
8 $C{COMPILE_NOMEM} $DIR/gc.m -dynamiclib -o librequiresgc.dylib -fobjc-gc-only
9 $C{COMPILE_NOMEM} $DIR/gc.m -dynamiclib -o librequiresgc.fake.dylib -fobjc-gc -install_name librequiresgc.dylib
10
11 $C{COMPILE} $DIR/gcenforcer.m -o gcenforcer.out
12 END
13 */
14
15 #include "test.h"
16 #include <objc/objc-auto.h>
17 #include <dlfcn.h>
18
19 int main()
20 {
21 int i;
22 for (i = 0; i < 1000; i++) {
23 testassert(dlopen_preflight("libsupportsgc.dylib"));
24 testassert(dlopen_preflight("libnoobjc.dylib"));
25
26 if (objc_collectingEnabled()) {
27 testassert(dlopen_preflight("librequiresgc.dylib"));
28 testassert(! dlopen_preflight("libnogc.dylib"));
29 } else {
30 testassert(! dlopen_preflight("librequiresgc.dylib"));
31 testassert(dlopen_preflight("libnogc.dylib"));
32 }
33 }
34
35 succeed(__FILE__);
36 }