]> git.saurik.com Git - apple/dyld.git/blob - testing/test-cases/thread-local-cleanup.dtest/main.c
e30179273f3cacd1d7c10ef7b1f0c3a53ffad6df
[apple/dyld.git] / testing / test-cases / thread-local-cleanup.dtest / main.c
1
2 // BUILD: $CC foo.c -dynamiclib -install_name $RUN_DIR/libtlv.dylib -o $BUILD_DIR/libtlv.dylib
3 // BUILD: $CC main.c -DRUN_DIR="$RUN_DIR" -o $BUILD_DIR/thread-local-cleanup.exe
4
5 // RUN: ./thread-local-cleanup.exe
6
7 #include <stdio.h>
8 #include <dlfcn.h>
9
10
11
12
13
14 int main()
15 {
16 printf("[BEGIN] thread-local-cleanup\n");
17
18 for (int i=0; i < 1000; ++i) {
19 void* handle = dlopen(RUN_DIR "/libtlv.dylib", RTLD_FIRST);
20 if ( handle == NULL ) {
21 printf("[FAIL] thread-local-cleanup: iteration %d %s\n", i, dlerror());
22 return 0;
23 }
24
25 int result = dlclose(handle);
26 if ( result != 0 ) {
27 printf("[FAIL] thread-local-cleanup: iteration %d %s\n", i, dlerror());
28 return 0;
29 }
30 }
31
32 printf("[PASS] thread-local-cleanup\n");
33
34 return 0;
35 }
36