]> git.saurik.com Git - apple/dyld.git/blob - testing/test-cases/NSAddImage-fail.dtest/main.c
dyld-551.4.tar.gz
[apple/dyld.git] / testing / test-cases / NSAddImage-fail.dtest / main.c
1 // BUILD_ONLY: MacOSX
2
3 // BUILD: $CC main.c -o $BUILD_DIR/NSAddImage-fail.exe -Wno-deprecated-declarations
4
5 // RUN: ./NSAddImage-fail.exe return
6 // RUN: NOCR_TEST_NAME="NSAddImage-fail expected abort" $REQUIRE_CRASH ./NSAddImage-fail.exe abort
7
8
9
10 #include <stdio.h>
11 #include <string.h>
12 #include <dlfcn.h>
13 #include <mach-o/dyld.h>
14
15
16 int main(int argc, const char* argv[])
17 {
18 const char* arg = argv[1];
19
20 if ( strcmp(arg, "return") == 0 ) {
21 printf("[BEGIN] NSAddImage-fail %s\n", arg);
22 const struct mach_header* mh = NSAddImage("/xqz/42/libnotfound.xxx", NSADDIMAGE_OPTION_RETURN_ONLY_IF_LOADED);
23 if ( mh == NULL )
24 printf("[PASS] NSAddImage-fail %s\n", arg);
25 else
26 printf("[FAIL] NSAddImage-fail %s\n", arg);
27 }
28 else {
29 // run with nocr which print BEGIN/PASS/FAIL
30 NSAddImage("/xqz/42/libnotfound.xxx", 0);
31 }
32
33 return 0;
34 }
35