]>
git.saurik.com Git - apple/dyld.git/blob - testing/test-cases/dlopen-symlink.dtest/main.c
2 // BUILD: $CC foo.c -dynamiclib -install_name $RUN_DIR/libfoo.dylib -o $BUILD_DIR/libfoo.dylib
3 // BUILD: $SYMLINK libfoo.dylib $BUILD_DIR/libfoo-symlink.dylib
4 // BUILD: $CC main.c -o $BUILD_DIR/dlopen-symlink.exe -DRUN_DIR="$RUN_DIR"
6 // RUN: ./dlopen-symlink.exe
12 #include <mach-o/dyld.h>
13 #include <mach-o/dyld_priv.h>
15 #include "test_support.h"
17 int main(int argc
, const char* argv
[], const char* envp
[], const char* apple
[]) {
18 // call dlopen() with a path that is a symlink
19 void* handle
= dlopen(RUN_DIR
"/libfoo-symlink.dylib", RTLD_LAZY
);
20 if ( handle
== NULL
) {
21 FAIL("dlerror(): %s", dlerror());
24 // walk images to see if path was converted to real path
25 const char* foundPath
= NULL
;
26 int count
= _dyld_image_count();
27 for (int i
=0; i
< count
; ++i
) {
28 const char* path
= _dyld_get_image_name(i
);
29 LOG("path[%2d]=%s", i
, path
);
30 if ( strstr(path
, "libfoo") != NULL
) {
31 if ( foundPath
== NULL
) {
35 FAIL("More than one libfoo found");
39 if ( foundPath
== NULL
) {
40 FAIL("No libfoo found");
42 if ( strstr(foundPath
, "libfoo-symlink") != NULL
) {
43 FAIL("Path is symlink not real path: %s", foundPath
);