]> git.saurik.com Git - apple/dyld.git/blob - testing/test-cases/NSAddImage-loaded.dtest/main.c
dyld-750.5.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 #include "test_support.h"
15
16 int main(int argc, const char* argv[], const char* envp[], const char* apple[]) {
17 // verify value is returned for image already loaded
18 const struct mach_header* mh = NSAddImage("/usr/lib/libSystem.B.dylib", NSADDIMAGE_OPTION_RETURN_ONLY_IF_LOADED);
19 if ( mh == NULL )
20 FAIL("Could not find mh for libSystem.B.dylib");
21
22 // verify existing dylib is not loaded if it is not already loaded
23 mh = NSAddImage("/usr/lib/libz.dylib", NSADDIMAGE_OPTION_RETURN_ONLY_IF_LOADED);
24 if ( mh != NULL )
25 FAIL("Found mh for unloaded dylib libz.dylib");
26
27 PASS("Success");
28 }
29