dyld-625.13.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 extern struct mach_header __dso_handle;
11
12 int main()
13 {
14 printf("[BEGIN] dyld_version_spi\n");
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 printf("[FAIL] base.platform %u incorrect for macOS\n", base);
23 return 0;
24 }
25 #elif TARGET_OS_IOS
26 if ( base != PLATFORM_IOS ) {
27 printf("[FAIL] base.platform %u incorrect for iOS\n", base);
28 return 0;
29 }
30 #elif TARGET_OS_TV
31 if ( base != PLATFORM_TVOS ) {
32 printf("[FAIL] base.platform %u incorrect for tvOS\n", base);
33 return 0;
34 }
35 #elif TARGET_OS_BRIDGE
36 if ( base != PLATFORM_BRIDGEOS ) {
37 printf("[FAIL] base.platform %u incorrect for wacthOS\n", base);
38 return 0;
39 }
40 #elif TARGET_OS_WATCH
41 if ( base != PLATFORM_WATCHOS ) {
42 printf("[FAIL] base.platform %u incorrect for bridgeOS\n", base);
43 return 0;
44 }
45 #else
46 printf("[FAIL] Running on unknown platform\n");
47 return 0;
48 #endif
49
50 #if TARGET_OS_SIMULATOR
51 if (dyld_is_simulator_platform(active) != true) {
52 printf("[FAIL] active platform %u should be a simulator\n", active);
53 return 0;
54 }
55 #else
56 if (dyld_is_simulator_platform(active) == true) {
57 printf("[FAIL] active platform %u should not be a simulator\n", active);
58 return 0;
59 }
60 #endif
61
62 if (dyld_is_simulator_platform(base) == true) {
63 printf("[FAIL] base platform %u should not be a simulator\n", base);
64 return 0;
65 }
66
67 if (!dyld_sdk_at_least(&__dso_handle, absoluteMin)) {
68 printf("[FAIL] executable sdk version should not < 1.0.0\n");
69 return 0;
70 }
71
72 if (dyld_sdk_at_least(&__dso_handle, absoluteMax)) {
73 printf("[FAIL] executable sdk version should not > 65536.0.0\n");
74 return 0;
75 }
76
77 if (!dyld_minos_at_least(&__dso_handle, absoluteMin)) {
78 printf("[FAIL] executable min version should not < 1.0.0\n");
79 return 0;
80 }
81
82 if (dyld_minos_at_least(&__dso_handle, absoluteMax)) {
83 printf("[FAIL] executable min version should not > 65536.0.0\n");
84 return 0;
85 }
86
87 printf("[PASS] dyld_version_spi\n");
88 return 0;
89 }
90