Make sure that the same tests are on all platforms.
In order to be able to generate a list of tests for cts, the same set of tests must exist across all platforms. This CL adds empty tests where a test was conditionally compiled out. This CL creates a single library libBionicTests that includes all of the tests found in bionic-unit-tests-static. Also fix a few missing include files in some test files. Tested by running and compiling the tests for every platform and verifying the same number of tests are on each platform. Change-Id: I9989d4bfebb0f9c409a0ce7e87169299eac605a2
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
Reference in New Issue
Block a user