diff --git a/tests/time_test.cpp b/tests/time_test.cpp index 02163a554..fb5a4a71f 100644 --- a/tests/time_test.cpp +++ b/tests/time_test.cpp @@ -55,7 +55,7 @@ TEST(time, gmtime) { ASSERT_EQ(1970, broken_down->tm_year + 1900); } -#ifdef __BIONIC__ +#if __BIONIC__ TEST(time, mktime_10310929) { struct tm t; memset(&t, 0, sizeof(tm)); @@ -63,7 +63,23 @@ TEST(time, mktime_10310929) { t.tm_mon = 2; t.tm_mday = 10; +#if !defined(__LP64__) + // 32-bit bionic stupidly had a signed 32-bit time_t. ASSERT_EQ(-1, mktime(&t)); ASSERT_EQ(-1, mktime_tz(&t, "UTC")); +#else + // Everyone else should be using a signed 64-bit time_t. + ASSERT_GE(sizeof(time_t) * 8, 64U); + + setenv("TZ", "America/Los_Angeles", 1); + tzset(); + ASSERT_EQ(static_cast(4108348800U), mktime(&t)); + ASSERT_EQ(static_cast(4108320000U), mktime_tz(&t, "UTC")); + + setenv("TZ", "UTC", 1); + tzset(); + ASSERT_EQ(static_cast(4108320000U), mktime(&t)); + ASSERT_EQ(static_cast(4108348800U), mktime_tz(&t, "America/Los_Angeles")); +#endif } #endif