]> git.saurik.com Git - apple/dyld.git/blob - testing/test-cases/NSAddImage-loaded.dtest/main.c
dyld-851.27.tar.gz
[apple/dyld.git] / testing / test-cases / NSAddImage-loaded.dtest / main.c
1 // BUILD(macos): $CC main.c -o $BUILD_DIR/NSAddImage-loaded.exe -Wno-deprecated-declarations
2
3 // BUILD(ios,tvos,watchos,bridgeos):
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