]> git.saurik.com Git - apple/xnu.git/blame - tools/tests/darwintests/mach_boottime_usec.c
xnu-4570.51.1.tar.gz
[apple/xnu.git] / tools / tests / darwintests / 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
10T_DECL(mach_boottime_usec, "mach_boottime_usec()",
813fb2f6 11 T_META_ALL_VALID_ARCHS(true), T_META_LTEPHASE(LTE_POSTINIT))
39037602
A
12{
13 uint64_t bt_usec = mach_boottime_usec();
14
15 struct timeval bt_tv;
16 size_t len = sizeof(bt_tv);
17 T_ASSERT_POSIX_SUCCESS(sysctlbyname("kern.boottime", &bt_tv, &len, NULL, 0), NULL);
18
19 T_EXPECT_EQ((uint64_t)bt_tv.tv_sec * USEC_PER_SEC + (uint64_t)bt_tv.tv_usec, bt_usec, NULL);
20}