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