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