]> git.saurik.com Git - apple/libc.git/blob - tests/timespec_get.c
Libc-1439.100.3.tar.gz
[apple/libc.git] / tests / timespec_get.c
1 #include <time.h>
2 #include <sys/time.h>
3 #include <stdlib.h>
4 #include <unistd.h>
5
6 #include <darwintest.h>
7
8 T_DECL(timespec_get, "timespec_get")
9 {
10 struct timespec ts;
11 T_ASSERT_EQ(timespec_get(&ts, TIME_UTC), TIME_UTC, NULL);
12
13 struct timeval tv;
14 T_ASSERT_POSIX_ZERO(gettimeofday(&tv, NULL), NULL);
15
16 T_EXPECT_LE((unsigned long)tv.tv_sec - (unsigned long)ts.tv_sec, (unsigned long)1,
17 "gettimeofday() should return same as timespec_get(TIME_UTC)");
18 }
19