]> git.saurik.com Git - apple/dyld.git/blob - testing/test-cases/dlopen-intertwined.dtest/main.c
11580d31c34195689d4b73df5e68646eed56f149
[apple/dyld.git] / testing / test-cases / dlopen-intertwined.dtest / main.c
1
2
3 // BUILD: $CC base.c -dynamiclib -o $BUILD_DIR/libbase.dylib -install_name $RUN_DIR/libbase.dylib
4 // BUILD: $CC A.c -dynamiclib -o $BUILD_DIR/libA.dylib -install_name $RUN_DIR/libA.dylib $BUILD_DIR/libbase.dylib
5 // BUILD: $CC C.c -dynamiclib -o $BUILD_DIR/libC.dylib -install_name $RUN_DIR/libC.dylib $BUILD_DIR/libbase.dylib
6 // BUILD: $CC B.c -dynamiclib -o $BUILD_DIR/libB.dylib -install_name $RUN_DIR/libB.dylib $BUILD_DIR/libbase.dylib $BUILD_DIR/libC.dylib
7 // BUILD: $CC D.c -dynamiclib -o $BUILD_DIR/libD.dylib -install_name $RUN_DIR/libD.dylib $BUILD_DIR/libbase.dylib $BUILD_DIR/libC.dylib
8 // BUILD: $CC E.c -dynamiclib -o $BUILD_DIR/libE.dylib -install_name $RUN_DIR/libE.dylib $BUILD_DIR/libbase.dylib $BUILD_DIR/libA.dylib
9 // BUILD: $CC F.c -dynamiclib -o $BUILD_DIR/libF.dylib -install_name $RUN_DIR/libF.dylib $BUILD_DIR/libbase.dylib $BUILD_DIR/libD.dylib
10 // BUILD: $CC main.c -o $BUILD_DIR/dlopen-intertwined.exe $BUILD_DIR/libbase.dylib $BUILD_DIR/libA.dylib -DRUN_DIR="$RUN_DIR"
11
12 // RUN: ./dlopen-intertwined.exe
13
14 #include <stdio.h>
15 #include <dlfcn.h>
16 #include <stdlib.h>
17 #include <dispatch/dispatch.h>
18
19 // main deps on A
20 // main dlopens B which deps on C
21 // main dlopens D which deps on C
22 // main dlopens E which deps on A
23 // main dlopens F which deps on D
24
25 extern void a(const char*);
26 extern void setState(const char* from);
27
28 int main()
29 {
30 printf("[BEGIN] dlopen-intertwined\n");
31
32 a("main");
33
34 void* handle = dlopen(RUN_DIR "/libB.dylib", RTLD_LAZY);
35 if ( handle == NULL ) {
36 printf("[FAIL] dlopen-intertwined: %s\n", dlerror());
37 exit(0);
38 }
39
40 handle = dlopen(RUN_DIR "/libD.dylib", RTLD_LAZY);
41 if ( handle == NULL ) {
42 printf("[FAIL] dlopen-intertwined: %s\n", dlerror());
43 exit(0);
44 }
45
46 handle = dlopen(RUN_DIR "/libE.dylib", RTLD_LAZY);
47 if ( handle == NULL ) {
48 printf("[FAIL] dlopen-intertwined: %s\n", dlerror());
49 exit(0);
50 }
51
52 handle = dlopen(RUN_DIR "/libF.dylib", RTLD_LAZY);
53 if ( handle == NULL ) {
54 printf("[FAIL] dlopen-intertwined: %s\n", dlerror());
55 exit(0);
56 }
57
58 setState("DONE");
59
60 printf("[PASS] dlopen-intertwined\n");
61 return 0;
62 }
63