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