]> git.saurik.com Git - apple/xnu.git/blame - tests/mach_boottime_usec.c
xnu-7195.101.1.tar.gz
[apple/xnu.git] / tests / mach_boottime_usec.c
CommitLineData
39037602
A
1#include <stdlib.h>
2#include <time.h>
3#include <sys/time.h>
4#include <sys/types.h>
5#include <sys/sysctl.h>
6#include <mach/mach_time.h>
7
8#include <darwintest.h>
9
cb323159
A
10T_GLOBAL_META(T_META_RUN_CONCURRENTLY(true));
11
39037602 12T_DECL(mach_boottime_usec, "mach_boottime_usec()",
0a7de745 13 T_META_ALL_VALID_ARCHS(true), T_META_LTEPHASE(LTE_POSTINIT))
39037602
A
14{
15 uint64_t bt_usec = mach_boottime_usec();
16
17 struct timeval bt_tv;
18 size_t len = sizeof(bt_tv);
19 T_ASSERT_POSIX_SUCCESS(sysctlbyname("kern.boottime", &bt_tv, &len, NULL, 0), NULL);
20
21 T_EXPECT_EQ((uint64_t)bt_tv.tv_sec * USEC_PER_SEC + (uint64_t)bt_tv.tv_usec, bt_usec, NULL);
22}