2 // BUILD: $CC main.c -o $BUILD_DIR/versions.exe
8 #include <mach-o/dyld_priv.h>
10 #include "test_support.h"
12 extern struct mach_header __dso_handle
;
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 };
21 if ( base
!= PLATFORM_MACOS
) {
22 FAIL("base.platform %u incorrect for macOS", base
);
25 if ( base
!= PLATFORM_IOS
) {
26 FAIL("base.platform %u incorrect for iOS", base
);
29 if ( base
!= PLATFORM_TVOS
) {
30 FAIL("base.platform %u incorrect for tvOS", base
);
32 #elif TARGET_OS_BRIDGE
33 if ( base
!= PLATFORM_BRIDGEOS
) {
34 FAIL("base.platform %u incorrect for wacthOS", base
);
37 if ( base
!= PLATFORM_WATCHOS
) {
38 FAIL("base.platform %u incorrect for bridgeOn", base
);
41 FAIL("Running on unknown platform");
44 #if TARGET_OS_SIMULATOR
45 if (dyld_is_simulator_platform(active
) != true) {
46 FAIL("active platform %u should be a simulator", active
);
49 if (dyld_is_simulator_platform(active
) == true) {
50 FAIL("active platform %u should not be a simulator", active
);
54 if (dyld_is_simulator_platform(base
) == true) {
55 FAIL("base platform %u should not be a simulator", base
);
58 if (!dyld_sdk_at_least(&__dso_handle
, absoluteMin
)) {
59 FAIL("executable sdk version should not < 1.0.0");
62 if (dyld_sdk_at_least(&__dso_handle
, absoluteMax
)) {
63 FAIL("executable sdk version should not > 65536.0.0");
66 if (!dyld_minos_at_least(&__dso_handle
, absoluteMin
)) {
67 FAIL("executable min version should not < 1.0.0");
70 if (dyld_minos_at_least(&__dso_handle
, absoluteMax
)) {
71 FAIL("executable min version should not > 65536.0.0");