Revert "Revert "Do not look for tzdata file in /data.""
This reverts commit 4e013233b85ad14b3e23dcbe15c1b7130ccce527.
Issue was in unexpected returned fd and errno value combination.
See comments in bionic.cpp and time_test.cpp.
Bug: 236967833
Fix: 236967833
Test: atest CtsBionicTestCases
Test: atest toybox-tests
Change-Id: I51b3e1527ff16b2a6ea4d6fedf8102019f7fd896
diff --git a/tests/time_test.cpp b/tests/time_test.cpp
index 983a823..d86550d 100644
--- a/tests/time_test.cpp
+++ b/tests/time_test.cpp
@@ -84,6 +84,16 @@
ASSERT_EQ(1970, broken_down->tm_year + 1900);
}
+TEST(time, mktime_TZ_as_UTC_and_offset) {
+ struct tm tm = {.tm_year = 70, .tm_mon = 0, .tm_mday = 1};
+
+ // This TZ value is not a valid Olson ID and is not present in tzdata file,
+ // but is a valid TZ string according to POSIX standard.
+ setenv("TZ", "UTC+08:00:00", 1);
+ tzset();
+ ASSERT_EQ(static_cast<time_t>(8 * 60 * 60), mktime(&tm));
+}
+
static void* gmtime_no_stack_overflow_14313703_fn(void*) {
const char* original_tz = getenv("TZ");
// Ensure we'll actually have to enter tzload by using a time zone that doesn't exist.