diff options
author | Elliott Hughes <enh@google.com> | 2016-10-19 16:02:31 -0700 |
---|---|---|
committer | Elliott Hughes <enh@google.com> | 2016-10-19 16:02:31 -0700 |
commit | 12443702c28bc589b39ff71c917beab600e03a13 (patch) | |
tree | fe8d583384cb8e17d843a7e10e58f8a9e4a2e574 /tests/time_test.cpp | |
parent | 0759e7f5c147b999e4f9037eb949c1949a9f734c (diff) | |
download | bionic-12443702c28bc589b39ff71c917beab600e03a13.tar.gz |
Add regression test for http://b/31938693.
Bug: http://b/31938693
Bug: https://code.google.com/p/android/issues/detail?id=225132
Test: this is a test
Change-Id: I858962a1dcd56d555a4836a7bfbdf92d5c3042f6
Diffstat (limited to 'tests/time_test.cpp')
-rw-r--r-- | tests/time_test.cpp | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/tests/time_test.cpp b/tests/time_test.cpp index 2a46d8be4..914cb61af 100644 --- a/tests/time_test.cpp +++ b/tests/time_test.cpp @@ -628,3 +628,49 @@ TEST(time, clock_nanosleep_thread_cputime_id) { in.tv_nsec = 0; ASSERT_EQ(EINVAL, clock_nanosleep(CLOCK_THREAD_CPUTIME_ID, 0, &in, nullptr)); } + +TEST(time, bug_31938693) { + // User-visible symptoms in N: + // http://b/31938693 + // https://code.google.com/p/android/issues/detail?id=225132 + + // Actual underlying bug (the code change, not the tzdata upgrade that first exposed the bug): + // http://b/31848040 + + // This isn't a great test, because very few time zones were actually affected, and there's + // no real logic to which ones were affected: it was just a coincidence of the data that came + // after them in the tzdata file. + + time_t t = 1475619727; + struct tm tm; + + setenv("TZ", "America/Los_Angeles", 1); + tzset(); + ASSERT_TRUE(localtime_r(&t, &tm) != nullptr); + EXPECT_EQ(15, tm.tm_hour); + + setenv("TZ", "Europe/London", 1); + tzset(); + ASSERT_TRUE(localtime_r(&t, &tm) != nullptr); + EXPECT_EQ(23, tm.tm_hour); + + setenv("TZ", "America/Atka", 1); + tzset(); + ASSERT_TRUE(localtime_r(&t, &tm) != nullptr); + EXPECT_EQ(13, tm.tm_hour); + + setenv("TZ", "Pacific/Apia", 1); + tzset(); + ASSERT_TRUE(localtime_r(&t, &tm) != nullptr); + EXPECT_EQ(12, tm.tm_hour); + + setenv("TZ", "Pacific/Honolulu", 1); + tzset(); + ASSERT_TRUE(localtime_r(&t, &tm) != nullptr); + EXPECT_EQ(12, tm.tm_hour); + + setenv("TZ", "Asia/Magadan", 1); + tzset(); + ASSERT_TRUE(localtime_r(&t, &tm) != nullptr); + EXPECT_EQ(9, tm.tm_hour); +} |