xref: /xnu-11417.140.69/tests/remote_time.c (revision 43a90889846e00bfb5cf1d255cdc0a701a1e05a4)
1*43a90889SApple OSS Distributions #include <darwintest.h>
2*43a90889SApple OSS Distributions #include <System/kern/remote_time.h>
3*43a90889SApple OSS Distributions #include <mach/mach_time.h>
4*43a90889SApple OSS Distributions #include <stdint.h>
5*43a90889SApple OSS Distributions #include <sys/sysctl.h>
6*43a90889SApple OSS Distributions #include <TargetConditionals.h>
7*43a90889SApple OSS Distributions 
8*43a90889SApple OSS Distributions T_GLOBAL_META(T_META_RUN_CONCURRENTLY(true));
9*43a90889SApple OSS Distributions 
10*43a90889SApple OSS Distributions extern uint64_t __mach_bridge_remote_time(uint64_t);
11*43a90889SApple OSS Distributions 
12*43a90889SApple OSS Distributions T_DECL(remote_time_syscall, "test mach_bridge_remote_time syscall",
13*43a90889SApple OSS Distributions     T_META_CHECK_LEAKS(false))
14*43a90889SApple OSS Distributions {
15*43a90889SApple OSS Distributions #if TARGET_OS_BRIDGE
16*43a90889SApple OSS Distributions 	uint64_t local_time = mach_absolute_time();
17*43a90889SApple OSS Distributions 	uint64_t remote_time1 = mach_bridge_remote_time(local_time);
18*43a90889SApple OSS Distributions 	uint64_t remote_time2 = __mach_bridge_remote_time(local_time);
19*43a90889SApple OSS Distributions 	T_LOG("local_time = %llu, remote_time1 = %llu, remote_time2 = %llu",
20*43a90889SApple OSS Distributions 	    local_time, remote_time1, remote_time2);
21*43a90889SApple OSS Distributions 	T_ASSERT_EQ(remote_time1, remote_time2, "syscall works");
22*43a90889SApple OSS Distributions #else
23*43a90889SApple OSS Distributions 	T_SKIP("Skipping test");
24*43a90889SApple OSS Distributions #endif /* TARGET_OS_BRIDGE */
25*43a90889SApple OSS Distributions }
26