]> git.saurik.com Git - apple/dyld.git/blob - testing/test-cases/dyld_get_sdk_version.dtest/main.c
dyld-750.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 #include "test_support.h"
11
12 extern struct mach_header __dso_handle;
13
14 int main(int argc, const char* argv[], const char* envp[], const char* apple[]) {
15 // should succeed
16 if ( dyld_get_sdk_version(&__dso_handle) == 0 ) {
17 FAIL("dyld_get_sdk_version: expected SDK");
18 }
19
20 // should fail
21 const char* text = "bad text";
22 if ( dyld_get_sdk_version((struct mach_header*)text) != 0 ) {
23 FAIL("dyld_get_sdk_version: expected failure");
24 }
25
26
27 #if TARGET_OS_WATCH
28 uint32_t iosVersion = dyld_get_program_sdk_version();
29 uint32_t watchOSVersion = dyld_get_program_sdk_watch_os_version();
30 if (iosVersion != (watchOSVersion + 0x00070000)) {
31 FAIL("dyld_get_program_sdk_watch_os_version");
32 }
33 #endif
34 #if TARGET_OS_BRIDGE
35 uint32_t iosVersion = dyld_get_program_sdk_version();
36 uint32_t bridgeOSVersion = dyld_get_program_sdk_bridge_os_version();
37 if (bridgeOSVersion != (watchOSVersion + 0x00090000)) {
38 FAIL("dyld_get_program_sdk_watch_os_version");
39 }
40 #endif
41 PASS("Success");
42 }
43