]> git.saurik.com Git - apple/dyld.git/blob - testing/test-cases/dyld_get_sdk_version.dtest/main.c
dyld-733.6.tar.gz
[apple/dyld.git] / testing / test-cases / dyld_get_sdk_version.dtest / main.c
1
2 // BUILD: $CC main.c -o $BUILD_DIR/sdk-check.exe
3
4 // RUN: ./sdk-check.exe
5
6 #include <stdio.h>
7 #include <string.h>
8 #include <mach-o/dyld_priv.h>
9
10 extern struct mach_header __dso_handle;
11
12 int main()
13 {
14 printf("[BEGIN] dyld_get_sdk_version\n");
15
16 // should succeed
17 if ( dyld_get_sdk_version(&__dso_handle) == 0 ) {
18 printf("[FAIL] dyld_get_sdk_version: expected SDK\n");
19 return 0;
20 }
21
22 // should fail
23 const char* text = "bad text";
24 if ( dyld_get_sdk_version((struct mach_header*)text) != 0 ) {
25 printf("[FAIL] dyld_get_sdk_version: expected failure\n");
26 return 0;
27 }
28
29
30 #if TARGET_OS_WATCH
31 uint32_t iosVersion = dyld_get_program_sdk_version();
32 uint32_t watchOSVersion = dyld_get_program_sdk_watch_os_version();
33 if (iosVersion != (watchOSVersion + 0x00070000)) {
34 printf("[FAIL] dyld_get_program_sdk_watch_os_version\n");
35 return 0;
36 }
37 #endif
38 #if TARGET_OS_BRIDGE
39 uint32_t iosVersion = dyld_get_program_sdk_version();
40 uint32_t bridgeOSVersion = dyld_get_program_sdk_bridge_os_version();
41 if (bridgeOSVersion != (watchOSVersion + 0x00090000)) {
42 printf("[FAIL] dyld_get_program_sdk_watch_os_version\n");
43 return 0;
44 }
45 #endif
46 printf("[PASS] dyld_get_sdk_version\n");
47 return 0;
48 }
49