dyld-750.5.tar.gz
[apple/dyld.git] / testing / test-cases / dlopen-recurse.dtest / main.c
1
2 // BUILD: $CC bar.c -dynamiclib -install_name $RUN_DIR/libbar.dylib -o $BUILD_DIR/libbar.dylib
3 // BUILD: $CC foo.c -dynamiclib -install_name $RUN_DIR/libfoo.dylib -o $BUILD_DIR/libfoo.dylib -DRUN_DIR="$RUN_DIR"
4 // BUILD: $CC main.c -o $BUILD_DIR/dlopen-recurse.exe -DRUN_DIR="$RUN_DIR"
5
6 // RUN: ./dlopen-recurse.exe
7
8 #include <stdio.h>
9 #include <dlfcn.h>
10 #include <stdlib.h>
11 #include <dispatch/dispatch.h>
12
13 #include "test_support.h"
14
15 int main(int argc, const char* argv[], const char* envp[], const char* apple[]) {
16 // libfoo's initializer calls dlopen(). If that hangs, we have a locking bug
17 void* handle = dlopen(RUN_DIR "/libfoo.dylib", RTLD_LAZY);
18 dlclose(handle);
19
20 PASS("Success");
21 }
22