]> git.saurik.com Git - apple/dyld.git/blob - testing/test-cases/dyld_version_spis.dtest/main.c
dyld-750.5.tar.gz
[apple/dyld.git] / testing / test-cases / dyld_version_spis.dtest / main.c
1
2 // BUILD: $CC main.c -o $BUILD_DIR/versions.exe
3
4 // RUN: ./versions.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 dyld_platform_t active = dyld_get_active_platform();
16 dyld_platform_t base = dyld_get_base_platform(active);
17 dyld_build_version_t absoluteMin = { .platform = base, .version = 0 };
18 dyld_build_version_t absoluteMax = { .platform = base, .version = 0xffffffff };
19
20 #if TARGET_OS_OSX
21 if ( base != PLATFORM_MACOS ) {
22 FAIL("base.platform %u incorrect for macOS", base);
23 }
24 #elif TARGET_OS_IOS
25 if ( base != PLATFORM_IOS ) {
26 FAIL("base.platform %u incorrect for iOS", base);
27 }
28 #elif TARGET_OS_TV
29 if ( base != PLATFORM_TVOS ) {
30 FAIL("base.platform %u incorrect for tvOS", base);
31 }
32 #elif TARGET_OS_BRIDGE
33 if ( base != PLATFORM_BRIDGEOS ) {
34 FAIL("base.platform %u incorrect for wacthOS", base);
35 }
36 #elif TARGET_OS_WATCH
37 if ( base != PLATFORM_WATCHOS ) {
38 FAIL("base.platform %u incorrect for bridgeOn", base);
39 }
40 #else
41 FAIL("Running on unknown platform");
42 #endif
43
44 #if TARGET_OS_SIMULATOR
45 if (dyld_is_simulator_platform(active) != true) {
46 FAIL("active platform %u should be a simulator", active);
47 }
48 #else
49 if (dyld_is_simulator_platform(active) == true) {
50 FAIL("active platform %u should not be a simulator", active);
51 }
52 #endif
53
54 if (dyld_is_simulator_platform(base) == true) {
55 FAIL("base platform %u should not be a simulator", base);
56 }
57
58 if (!dyld_sdk_at_least(&__dso_handle, absoluteMin)) {
59 FAIL("executable sdk version should not < 1.0.0");
60 }
61
62 if (dyld_sdk_at_least(&__dso_handle, absoluteMax)) {
63 FAIL("executable sdk version should not > 65536.0.0");
64 }
65
66 if (!dyld_minos_at_least(&__dso_handle, absoluteMin)) {
67 FAIL("executable min version should not < 1.0.0");
68 }
69
70 if (dyld_minos_at_least(&__dso_handle, absoluteMax)) {
71 FAIL("executable min version should not > 65536.0.0");
72 }
73
74 PASS("Success");
75 }
76