]>
git.saurik.com Git - apple/dyld.git/blob - testing/test-cases/dlopen-flat.dtest/main.c
84f58352a6beb9c3b5531d893f8a40c642a4ee5a
2 // BUILD: $CC foo.c -dynamiclib -Wl,-U,_gInitialisersCalled -install_name $RUN_DIR/libfoo.dylib -o $BUILD_DIR/libfoo.dylib
3 // BUILD: $CC bar.c -dynamiclib -Wl,-U,_gInitialisersCalled $BUILD_DIR/libfoo.dylib -flat_namespace -install_name $RUN_DIR/libbar.dylib -o $BUILD_DIR/libbar.dylib -Wl,-w
4 // BUILD: $CC main.c -DRUN_DIR="$RUN_DIR" -o $BUILD_DIR/dlopen-flat.exe
6 // RUN: ./dlopen-flat.exe
11 int gInitialisersCalled
= 0;
14 printf("[BEGIN] dlopen-flat\n");
20 fooHandle
= dlopen(RUN_DIR
"/libfoo.dylib", RTLD_LAZY
);
22 printf("dlopen failed with error: %s\n", dlerror());
25 if (gInitialisersCalled
!= 1) {
26 printf("gInitialisersCalled != 1\n");
27 printf("[FAIL] dlopen-flat\n");
31 // Now unload foo which should do something.
32 result
= dlclose(fooHandle
);
34 printf("dlclose() returned %c\n", result
);
35 printf("[FAIL] dlopen-flat\n");
39 // Open foo again which should do something.
41 fooHandle
= dlopen(RUN_DIR
"/libfoo.dylib", RTLD_LAZY
);
43 printf("dlopen failed with error: %s\n", dlerror());
46 if (gInitialisersCalled
!= 2) {
47 printf("gInitialisersCalled != 2\n");
48 printf("[FAIL] dlopen-flat\n");
53 // Bar is going to resolve foo()
56 barHandle
= dlopen(RUN_DIR
"/libbar.dylib", RTLD_LAZY
);
58 printf("dlopen failed with error: %s\n", dlerror());
61 if (gInitialisersCalled
!= 3) {
62 printf("gInitialisersCalled != 3\n");
63 printf("[FAIL] dlopen-flat\n");
67 // Now unload foo which shouldn't do anything.
68 result
= dlclose(fooHandle
);
70 printf("dlclose() returned %c\n", result
);
71 printf("[FAIL] dlopen-flat\n");
75 // Open foo again which shouldn't do anything.
77 fooHandle
= dlopen(RUN_DIR
"/libfoo.dylib", RTLD_LAZY
);
79 printf("dlopen failed with error: %s\n", dlerror());
82 if (gInitialisersCalled
!= 3) {
83 printf("gInitialisersCalled != 3\n");
84 printf("[FAIL] dlopen-flat\n");
89 printf("[PASS] dlopen-flat\n");