]> git.saurik.com Git - apple/dyld.git/blob - testing/test-cases/dyld_version_spis.dtest/main.c
dyld-851.27.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 // We choose high platform value that is unlikely to ever be used, and a non-zero version number
20 // If the platform number we choose here is ever used it will fail on that platform and this test will need to be fixed.
21 dyld_build_version_t bogusPlatformVersion = { .platform = 0xffff0000, .version = 1 };
22
23 #if TARGET_OS_OSX
24 if ( base != PLATFORM_MACOS ) {
25 FAIL("base.platform %u incorrect for macOS", base);
26 }
27 #elif TARGET_OS_IOS
28 if ( base != PLATFORM_IOS ) {
29 FAIL("base.platform %u incorrect for iOS", base);
30 }
31 #elif TARGET_OS_TV
32 if ( base != PLATFORM_TVOS ) {
33 FAIL("base.platform %u incorrect for tvOS", base);
34 }
35 #elif TARGET_OS_BRIDGE
36 if ( base != PLATFORM_BRIDGEOS ) {
37 FAIL("base.platform %u incorrect for wacthOS", base);
38 }
39 #elif TARGET_OS_WATCH
40 if ( base != PLATFORM_WATCHOS ) {
41 FAIL("base.platform %u incorrect for bridgeOn", base);
42 }
43 #else
44 FAIL("Running on unknown platform");
45 #endif
46
47 #if TARGET_OS_SIMULATOR
48 if (dyld_is_simulator_platform(active) != true) {
49 FAIL("active platform %u should be a simulator", active);
50 }
51 #else
52 if (dyld_is_simulator_platform(active) == true) {
53 FAIL("active platform %u should not be a simulator", active);
54 }
55 #endif
56
57 if (dyld_is_simulator_platform(base) == true) {
58 FAIL("base platform %u should not be a simulator", base);
59 }
60
61 if (!dyld_sdk_at_least(&__dso_handle, absoluteMin)) {
62 FAIL("executable sdk version should not < 1.0.0");
63 }
64
65 if (dyld_sdk_at_least(&__dso_handle, absoluteMax)) {
66 FAIL("executable sdk version should not > 65536.0.0");
67 }
68
69 if (!dyld_minos_at_least(&__dso_handle, absoluteMin)) {
70 FAIL("executable min version should not < 1.0.0");
71 }
72
73 if (dyld_minos_at_least(&__dso_handle, absoluteMax)) {
74 FAIL("executable min version should not > 65536.0.0");
75 }
76
77 if (dyld_minos_at_least(&__dso_handle, bogusPlatformVersion)) {
78 FAIL("dyld_minos_at_least should be false for bogus platform");
79 }
80
81 if (dyld_program_minos_at_least(bogusPlatformVersion)) {
82 FAIL("dyld_program_minos_at_least should be false for bogus platform");
83 }
84
85 if (dyld_sdk_at_least(&__dso_handle, bogusPlatformVersion)) {
86 FAIL("dyld_sdk_at_least should be false for bogus platform");
87 }
88
89 if (dyld_program_sdk_at_least(bogusPlatformVersion)) {
90 FAIL("dyld_program_sdk_at_least should be false for bogus platform");
91 }
92
93
94 PASS("Success");
95 }
96