]> git.saurik.com Git - apple/dyld.git/blob - testing/test-cases/dlopen-RTLD_NOLOAD.dtest/init-main.c
41201eac5c640f14996cadc446e2f8f35eca5af2
[apple/dyld.git] / testing / test-cases / dlopen-RTLD_NOLOAD.dtest / init-main.c
1
2 // BUILD: $CC init-b.c -dynamiclib -DRUN_DIR="$RUN_DIR" -install_name $RUN_DIR/libInitB.dylib -o $BUILD_DIR/libInitB.dylib
3 // BUILD: $CC init-a.c -dynamiclib -install_name $RUN_DIR/libInitA.dylib $BUILD_DIR/libInitB.dylib -o $BUILD_DIR/libInitA.dylib
4 // BUILD: $CC init-main.c $BUILD_DIR/libInitA.dylib -o $BUILD_DIR/dlopen-RTLD_NOLOAD-in-initializer.exe
5
6 // RUN: ./dlopen-RTLD_NOLOAD-in-initializer.exe
7
8 #include <stdio.h>
9 #include <stdlib.h>
10 #include <string.h>
11 #include <stdbool.h>
12 #include <dlfcn.h>
13
14
15 extern bool initsInWrongOrder;
16 extern bool allInitsDone();
17
18 int main()
19 {
20 printf("[BEGIN] dlopen-RTLD_NOLOAD-in-initializer\n");
21
22 ///
23 /// This tests that using RTLD_NOLOAD in an initializer does not trigger out of order initializers
24 ///
25 if ( initsInWrongOrder )
26 printf("[FAIL] dlopen-RTLD_NOLOAD-in-initializer: wrong init order\n");
27 else if ( !allInitsDone() )
28 printf("[FAIL] dlopen-RTLD_NOLOAD-in-initializer: all initializers not run\n");
29 else
30 printf("[PASS] dlopen-RTLD_NOLOAD-in-initializer\n");
31
32 return 0;
33 }