]> git.saurik.com Git - apple/dyld.git/blob - testing/test-cases/NSAddImage-loaded.dtest/main.c
dyld-733.6.tar.gz
[apple/dyld.git] / testing / test-cases / NSAddImage-loaded.dtest / main.c
1 // BUILD_ONLY: MacOSX
2
3 // BUILD: $CC main.c -o $BUILD_DIR/NSAddImage-loaded.exe -Wno-deprecated-declarations
4
5 // RUN: ./NSAddImage-loaded.exe return
6
7
8
9 #include <stdio.h>
10 #include <string.h>
11 #include <dlfcn.h>
12 #include <mach-o/dyld.h>
13
14
15 int main(int argc, const char* argv[])
16 {
17 printf("[BEGIN] NSAddImage-loaded\n");
18
19 // verify value is returned for image already loaded
20 const struct mach_header* mh = NSAddImage("/usr/lib/libSystem.B.dylib", NSADDIMAGE_OPTION_RETURN_ONLY_IF_LOADED);
21 if ( mh == NULL )
22 printf("[FAIL] NSAddImage-loaded\n");
23
24 // verify existing dylib is not loaded if it is not already loaded
25 mh = NSAddImage("/usr/lib/libz.dylib", NSADDIMAGE_OPTION_RETURN_ONLY_IF_LOADED);
26 if ( mh != NULL )
27 printf("[FAIL] NSAddImage-loaded\n");
28
29 printf("[PASS] NSAddImage-loaded\n");
30
31 return 0;
32 }
33