]>
git.saurik.com Git - apple/dyld.git/blob - testing/test-cases/dlopen_from-basic.dtest/main.c
2 // BUILD: $CC bar.c -dynamiclib -install_name @rpath/libbar.dylib -o $BUILD_DIR/dir/libbar.dylib
3 // BUILD: $CC bar.c -dynamiclib -install_name @rpath/libbaz.dylib -o $BUILD_DIR/dir/libbaz.dylib
4 // BUILD: $CC test.c -dynamiclib -install_name $RUN_DIR/test/libtest.dylib -o $BUILD_DIR/test/libtest.dylib -rpath @loader_path/../dir
5 // BUILD: $CC main.c -o $BUILD_DIR/dlopen_from-basic.exe $BUILD_DIR/test/libtest.dylib
7 // RUN: ./dlopen_from-basic.exe
10 #include <dlfcn_private.h>
13 #include "test_support.h"
15 /// test dlopen_from() works for both @rpath and @loader_path
19 int main(int argc
, const char* argv
[], const char* envp
[], const char* apple
[])
21 // verify the straight dlopen fails because libtest.dylib sets up the LC_RPATH
22 void* handle
= dlopen("@rpath/libbar.dylib", RTLD_LAZY
);
23 if ( handle
!= NULL
) {
24 FAIL("dlopen(\"@rpath/libbar.dylib\") should not have succeeded");
26 // verify dlopen_from() works becuase libtest.dylib sets up an LC_RPATH
27 handle
= dlopen_from("@rpath/libbar.dylib", RTLD_LAZY
, &test
);
28 if ( handle
== NULL
) {
29 FAIL("dlopen_from(\"@rpath/libbar.dylib\", &test) failed: %s", dlerror());
32 // verify the straight dlopen fails because main executables @loader_path is used
33 handle
= dlopen("@loader_path/../dir/libbaz.dylib", RTLD_LAZY
);
34 if ( handle
!= NULL
) {
35 FAIL("dlopen(\"@loader_path/../dir/libbaz.dylib\") should not have succeeded");
37 // verify dlopen_from() works with @loader_path resolving to where libtest.dylib is
38 handle
= dlopen_from("@loader_path/../dir/libbaz.dylib", RTLD_LAZY
, &test
);
39 if ( handle
== NULL
) {
40 FAIL("dlopen_from(\"@loader_path/../dir/libbaz.dylib\", &test) failed: %s", dlerror());