POSIX clock cleanup.
The newest of these clocks was added in Linux 2.6.12, so no need for runtime
checks.
Add CTS tests that we can actually use the various clocks.
Bug: http://b/67458266
Test: ran tests
Change-Id: I3cfd7982043d6f8d4ebdc2b29e8722334f443ce5
diff --git a/tests/time_test.cpp b/tests/time_test.cpp
index 4e3fa83..d553ff5 100644
--- a/tests/time_test.cpp
+++ b/tests/time_test.cpp
@@ -574,6 +574,31 @@
ASSERT_LT(ts2.tv_nsec, 1000000);
}
+TEST(time, clock_gettime_CLOCK_REALTIME) {
+ timespec ts;
+ ASSERT_EQ(0, clock_gettime(CLOCK_REALTIME, &ts));
+}
+
+TEST(time, clock_gettime_CLOCK_MONOTONIC) {
+ timespec ts;
+ ASSERT_EQ(0, clock_gettime(CLOCK_MONOTONIC, &ts));
+}
+
+TEST(time, clock_gettime_CLOCK_PROCESS_CPUTIME_ID) {
+ timespec ts;
+ ASSERT_EQ(0, clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &ts));
+}
+
+TEST(time, clock_gettime_CLOCK_THREAD_CPUTIME_ID) {
+ timespec ts;
+ ASSERT_EQ(0, clock_gettime(CLOCK_THREAD_CPUTIME_ID, &ts));
+}
+
+TEST(time, clock_gettime_CLOCK_BOOTTIME) {
+ timespec ts;
+ ASSERT_EQ(0, clock_gettime(CLOCK_BOOTTIME, &ts));
+}
+
TEST(time, clock) {
// clock(3) is hard to test, but a 1s sleep should cost less than 1ms.
clock_t t0 = clock();