]>
git.saurik.com Git - apple/dyld.git/blob - testing/test-cases/dlopen-realpath.dtest/main.c
2 // BUILD: $CC main.c -o $BUILD_DIR/dlopen-realpath.exe
3 // BUILD: $SYMLINK ./IOKit.framework/IOKit $BUILD_DIR/IOKit
4 // BUILD: $SYMLINK /System/Library/Frameworks/IOKit.framework $BUILD_DIR/IOKit.framework
6 //FIXME: Use something besides IOKit so we do not need to copy it into the chroot
7 // R: DYLD_FALLBACK_LIBRARY_PATH=/baz ./dlopen-realpath.exe
12 #include "test_support.h"
14 static void tryImage(const char* path
)
16 void* handle
= dlopen(path
, RTLD_LAZY
);
17 if ( handle
== NULL
) {
18 FAIL("dlerror(\"%s\"): %s", path
, dlerror());
21 int result
= dlclose(handle
);
23 FAIL("dlclose(\"%s\"): %s", path
, dlerror());
29 int main(int argc
, const char* argv
[], const char* envp
[], const char* apple
[]) {
30 tryImage("./IOKit.framework/IOKit");
31 tryImage("./././IOKit/../IOKit.framework/IOKit");
34 // Also try libSystem which has an alias in the OS to /usr/lib/libSystem.B.dylib
35 tryImage("/usr/lib/libSystem.dylib");
37 // Also try using non-canonical path
38 // This requires DYLD_FALLBACK_LIBRARY_PATH to be disabled, otherwise it is found that way
39 tryImage("//usr/lib/libSystem.dylib");
40 tryImage("/usr/./lib/libSystem.dylib");