aboutsummaryrefslogtreecommitdiffstats
path: root/tests/time_test.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/time_test.cpp')
-rw-r--r--tests/time_test.cpp17
1 files changed, 13 insertions, 4 deletions
diff --git a/tests/time_test.cpp b/tests/time_test.cpp
index fb5a4a71f..869ee4baa 100644
--- a/tests/time_test.cpp
+++ b/tests/time_test.cpp
@@ -20,9 +20,12 @@
#include <time.h>
-#ifdef __BIONIC__ // mktime_tz is a bionic extension.
+#if defined(__BIONIC__) // mktime_tz is a bionic extension.
#include <libc/private/bionic_time.h>
+#endif // __BIONIC__
+
TEST(time, mktime_tz) {
+#if defined(__BIONIC__)
struct tm epoch;
memset(&epoch, 0, sizeof(tm));
epoch.tm_year = 1970 - 1900;
@@ -40,8 +43,10 @@ TEST(time, mktime_tz) {
// Missing. Falls back to UTC.
ASSERT_EQ(2678400, mktime_tz(&epoch, "PST"));
+#else // __BIONIC__
+ GTEST_LOG_(INFO) << "This test does nothing.\n";
+#endif // __BIONIC__
}
-#endif
TEST(time, gmtime) {
time_t t = 0;
@@ -55,7 +60,6 @@ TEST(time, gmtime) {
ASSERT_EQ(1970, broken_down->tm_year + 1900);
}
-#if __BIONIC__
TEST(time, mktime_10310929) {
struct tm t;
memset(&t, 0, sizeof(tm));
@@ -66,7 +70,9 @@ TEST(time, mktime_10310929) {
#if !defined(__LP64__)
// 32-bit bionic stupidly had a signed 32-bit time_t.
ASSERT_EQ(-1, mktime(&t));
+#if defined(__BIONIC__)
ASSERT_EQ(-1, mktime_tz(&t, "UTC"));
+#endif
#else
// Everyone else should be using a signed 64-bit time_t.
ASSERT_GE(sizeof(time_t) * 8, 64U);
@@ -74,12 +80,15 @@ TEST(time, mktime_10310929) {
setenv("TZ", "America/Los_Angeles", 1);
tzset();
ASSERT_EQ(static_cast<time_t>(4108348800U), mktime(&t));
+#if defined(__BIONIC__)
ASSERT_EQ(static_cast<time_t>(4108320000U), mktime_tz(&t, "UTC"));
+#endif
setenv("TZ", "UTC", 1);
tzset();
ASSERT_EQ(static_cast<time_t>(4108320000U), mktime(&t));
+#if defined(__BIONIC__)
ASSERT_EQ(static_cast<time_t>(4108348800U), mktime_tz(&t, "America/Los_Angeles"));
#endif
-}
#endif
+}