]> git.saurik.com Git - apple/dyld.git/blob - testing/test-cases/thread-local-cleanup.dtest/main.c
dyld-851.27.tar.gz
[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 #include "test_support.h"
11
12 int main(int argc, const char* argv[], const char* envp[], const char* apple[]) {
13 for (int i=0; i < 1000; ++i) {
14 void* handle = dlopen(RUN_DIR "/libtlv.dylib", RTLD_FIRST);
15 if ( handle == NULL ) {
16 FAIL("dlopen error: iteration %d %s", i, dlerror());
17 }
18
19 int result = dlclose(handle);
20 if ( result != 0 ) {
21 FAIL("dlclose error: iteration %d %s", i, dlerror());
22 }
23 }
24
25 PASS("Success");
26 }
27