]> git.saurik.com Git - apple/dyld.git/blob - testing/test-cases/dlopen-rpath-prev.dtest/main.c
dyld-733.6.tar.gz
[apple/dyld.git] / testing / test-cases / dlopen-rpath-prev.dtest / main.c
1
2 // BUILD: mkdir -p $BUILD_DIR/dir1 $BUILD_DIR/dir2
3 // BUILD: $CC sub1.c -dynamiclib -install_name @rpath/librpathstatic.dylib -o $BUILD_DIR/dir1/librpathstatic.dylib
4 // BUILD: $CC sub2.c -dynamiclib -install_name @rpath/libdynamic.dylib -o $BUILD_DIR/dir2/libdynamic.dylib $BUILD_DIR/dir1/librpathstatic.dylib
5 // BUILD: $CC foo.c -dynamiclib -install_name $RUN_DIR/libstatic.dylib -o $BUILD_DIR/libstatic.dylib -rpath @loader_path/dir1 $BUILD_DIR/dir1/librpathstatic.dylib
6 // BUILD: $CC main.c $BUILD_DIR/libstatic.dylib -DRUN_DIR="$RUN_DIR" -o $BUILD_DIR/dlopen-rpath-prev.exe
7
8 // RUN: ./dlopen-rpath-prev.exe
9
10 // main links with libstatic.dylib which uses rpath to link with dir1/librpathstatic.dylib
11 // main dlopen()s libdynamic.dylib which links with dir1/librpathstatic.dylib, but has no rpath for it and depends on it being already loaded
12
13 #include <stdio.h>
14 #include <dlfcn.h>
15
16 int main()
17 {
18 printf("[BEGIN] dlopen-rpath-prev\n");
19
20 void* handle = dlopen(RUN_DIR "/dir2/libdynamic.dylib", RTLD_LAZY);
21 if ( handle == NULL ) {
22 printf("dlerror(): %s\n", dlerror());
23 printf("[FAIL] dlopen-rpath-prev\n");
24 return 0;
25 }
26
27 printf("[PASS] dlopen-rpath-prev\n");
28 return 0;
29 }
30