]> git.saurik.com Git - apple/dyld.git/blob - testing/test-cases/_dyld_get_image_name-cache-symlink.dtest/main.c
dyld-851.27.tar.gz
[apple/dyld.git] / testing / test-cases / _dyld_get_image_name-cache-symlink.dtest / main.c
1
2 // BUILD: $CC foo.c -dynamiclib -install_name /System/Library/Frameworks/IOKit.framework/IOKit -o $BUILD_DIR/libfoo.dylib
3 // BUILD: $CC main.c -o $BUILD_DIR/_dyld_get_image_name-cache-symlink.exe $BUILD_DIR/libfoo.dylib
4
5 // RUN: DYLD_LIBRARY_PATH=/usr/lib/system/introspection ./_dyld_get_image_name-cache-symlink.exe
6
7
8 #include <stdio.h>
9 #include <string.h>
10 #include <dlfcn.h>
11 #include <mach-o/dyld.h>
12 #include <mach-o/dyld_priv.h>
13
14 #include "test_support.h"
15
16 int main(int argc, const char* argv[], const char* envp[], const char* apple[]) {
17 // walk images to see if path was converted to real path
18 const char* foundPath = NULL;
19 int count = _dyld_image_count();
20 for (int i=0; i < count; ++i) {
21 const char* path = _dyld_get_image_name(i);
22 LOG("path[%2d]=%s", i, path);
23 if ( strstr(path, "/IOKit") != NULL ) {
24 if ( foundPath == NULL ) {
25 foundPath = path;
26 }
27 else {
28 FAIL("More than one libfoo found");
29 }
30 }
31 }
32 if ( foundPath == NULL ) {
33 FAIL("No IOKit found");
34 }
35 if ( strcmp(foundPath, "/System/Library/Frameworks/IOKit.framework/Versions/A/IOKit") != 0 ) {
36 FAIL("Path is symlink not real path: %s", foundPath);
37 }
38
39 PASS("Success");
40 }
41