]> git.saurik.com Git - apple/dyld.git/blob - testing/test-cases/dlopen-iOSMac.dtest/main.c
dyld-851.27.tar.gz
[apple/dyld.git] / testing / test-cases / dlopen-iOSMac.dtest / main.c
1 // BUILD(macos): $CC main.c -o $BUILD_DIR/dlopen-iOSMac.exe -DFOR_IOSMAC=1 -target x86_64-darwin-ios13.0-macabi
2 // BUILD(macos): $CC main.c -o $BUILD_DIR/dlopen-macOS.exe -DRUN_DIR="$RUN_DIR"
3 // BUILD(macos): $CC cat.c -dynamiclib -install_name $RUN_DIR/libcat.dylib -o $BUILD_DIR/libcat.dylib -target x86_64-darwin-ios13.0-macabi
4 // BUILD(macos): $CC foo.c -dynamiclib -install_name $RUN_DIR/libtestnotincache.dylib -o $BUILD_DIR/libtestnotincache.dylib $BUILD_DIR/libcat.dylib
5 // BUILD(macos): $CC foo.c -dynamiclib -install_name $RUN_DIR/libtestincache.dylib -o $BUILD_DIR/libtestincache.dylib -framework UIKit -F/System/iOSSupport/System/Library/Frameworks
6
7 // BUILD(ios,tvos,watchos,bridgeos):
8
9 // RUN: ./dlopen-iOSMac.exe
10 // RUN: ./dlopen-macOS.exe
11
12
13 #include <stdio.h>
14 #include <dlfcn.h>
15 #include <mach-o/dyld.h>
16
17 #include "test_support.h"
18
19 int main(int arg, const char* argv[])
20 {
21
22 #if FOR_IOSMAC
23 void* handle = dlopen("/System/Library/Frameworks/UIKit.framework/UIKit", RTLD_LAZY);
24 if ( handle == NULL ) {
25 FAIL("dlopen-iOS-on-Mac, UIKit failed to dlopen(): %s", dlerror());
26 return 0;
27 }
28 #else
29 void* handle = dlopen("/System/Library/Frameworks/AppKit.framework/AppKit", RTLD_LAZY);
30 if ( handle == NULL ) {
31 FAIL("dlopen-macOS, AppKit failed to dlopen(): %s", dlerror());
32 return 0;
33 }
34 // verify that can't load a macOS dylib that links with a catalyst dylib
35 handle = dlopen(RUN_DIR "/libtestnotincache.dylib", RTLD_LAZY);
36 if ( handle != NULL ) {
37 FAIL("dlopen-macOS, libtestnotincache.dylib should not be loaded");
38 return 0;
39 }
40 // verify that can't load a macOS dylib that links with a catalyst dylib which is in the dyld cache
41 handle = dlopen(RUN_DIR "/libtestincache.dylib", RTLD_LAZY);
42 if ( handle != NULL ) {
43 FAIL("dlopen-macOS, libtestincache.dylib should not be loaded");
44 return 0;
45 }
46 #endif
47
48 #if FOR_IOSMAC
49 PASS("dlopen-iOS-on-Mac");
50 #else
51 PASS("dlopen-macOS");
52 #endif
53
54 return 0;
55 }
56