diff options
author | Josh Gao <jmgao@google.com> | 2017-05-01 20:49:49 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2017-05-01 20:49:50 +0000 |
commit | eaad4e28e885fac2b8203ed529c5e4c558ce989f (patch) | |
tree | 9d2a9ce1a0412c8702ef9d187e959d6df133eb91 /base/chrono_utils_test.cpp | |
parent | d6f8b5f2d48413d365f0846eb53178145d0d7687 (diff) | |
parent | ae29339ca138648eeaee68f801feb02d85ee2abf (diff) |
Merge "base: make boot_clock work on host linux, hide it on non-linux."
Diffstat (limited to 'base/chrono_utils_test.cpp')
-rw-r--r-- | base/chrono_utils_test.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/base/chrono_utils_test.cpp b/base/chrono_utils_test.cpp index 057132d9f9..1f1ce15b16 100644 --- a/base/chrono_utils_test.cpp +++ b/base/chrono_utils_test.cpp @@ -16,6 +16,7 @@ #include "android-base/chrono_utils.h" +#include <err.h> #include <time.h> #include <chrono> @@ -25,9 +26,12 @@ namespace android { namespace base { +#if defined(__linux__) std::chrono::seconds GetBootTimeSeconds() { struct timespec now; - clock_gettime(CLOCK_BOOTTIME, &now); + if (clock_gettime(CLOCK_BOOTTIME, &now) != 0) { + err(1, "clock_gettime failed"); + } auto now_tp = boot_clock::time_point(std::chrono::seconds(now.tv_sec) + std::chrono::nanoseconds(now.tv_nsec)); @@ -41,6 +45,7 @@ TEST(ChronoUtilsTest, BootClockNowSeconds) { std::chrono::duration_cast<std::chrono::seconds>(boot_clock::now().time_since_epoch()); EXPECT_EQ(now, boot_seconds); } +#endif // defined(__linux__) } // namespace base -} // namespace android
\ No newline at end of file +} // namespace android |