]> git.saurik.com Git - apple/dyld.git/blob - testing/test-cases/dlopen-intertwined.dtest/main.c
dyld-851.27.tar.gz
[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 #include "test_support.h"
20
21 // main deps on A
22 // main dlopens B which deps on C
23 // main dlopens D which deps on C
24 // main dlopens E which deps on A
25 // main dlopens F which deps on D
26
27 extern void a(const char*);
28 extern void setState(const char* from);
29
30 int main(int argc, const char* argv[], const char* envp[], const char* apple[]) {
31 a("main");
32
33 void* handle = dlopen(RUN_DIR "/libB.dylib", RTLD_LAZY);
34 if ( handle == NULL ) {
35 FAIL("Error: %s", dlerror());
36 }
37
38 handle = dlopen(RUN_DIR "/libD.dylib", RTLD_LAZY);
39 if ( handle == NULL ) {
40 FAIL("Error: %s", dlerror());
41 }
42
43 handle = dlopen(RUN_DIR "/libE.dylib", RTLD_LAZY);
44 if ( handle == NULL ) {
45 FAIL("Error: %s", dlerror());
46 }
47
48 handle = dlopen(RUN_DIR "/libF.dylib", RTLD_LAZY);
49 if ( handle == NULL ) {
50 FAIL("Error: %s", dlerror());
51 }
52
53 setState("DONE");
54
55 PASS("Success");
56 }
57