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
diff --git a/tests/libgen_test.cpp b/tests/libgen_test.cpp
index c2c01f6..cae646f 100644
--- a/tests/libgen_test.cpp
+++ b/tests/libgen_test.cpp
@@ -38,7 +38,9 @@
free(writable_in);
}
-TEST(libgen, basename) {
+// Do not use basename as the test name, it's defined to another value in glibc
+// so leads to a differently named test on host versus target architectures.
+TEST(libgen, basename_smoke) {
TestBasename(NULL, ".");
TestBasename("", ".");
TestBasename("/usr/lib", "lib");
@@ -62,8 +64,7 @@
TestDirname("/", "/");
}
-#if __BIONIC__
-
+#if defined(__BIONIC__)
static void TestBasename(const char* in, const char* expected_out, int expected_rc,
char* buf, size_t buf_size, int expected_errno) {
errno = 0;
@@ -85,8 +86,10 @@
}
ASSERT_EQ(expected_errno, errno) << in;
}
+#endif // __BIONIC__
TEST(libgen, basename_r) {
+#if defined(__BIONIC__)
char buf[256];
TestBasename("", ".", 1, NULL, 0, 0);
TestBasename("", ".", -1, buf, 0, ERANGE);
@@ -99,9 +102,13 @@
TestBasename("/", "/", 1, buf, sizeof(buf), 0);
TestBasename(".", ".", 1, buf, sizeof(buf), 0);
TestBasename("..", "..", 2, buf, sizeof(buf), 0);
+#else // __BIONIC__
+ GTEST_LOG_(INFO) << "This test does nothing.\n";
+#endif // __BIONIC__
}
TEST(libgen, dirname_r) {
+#if defined(__BIONIC__)
char buf[256];
TestDirname("", ".", 1, NULL, 0, 0);
TestDirname("", ".", -1, buf, 0, ERANGE);
@@ -112,6 +119,7 @@
TestDirname("usr", ".", 1, buf, sizeof(buf), 0);
TestDirname(".", ".", 1, buf, sizeof(buf), 0);
TestDirname("..", ".", 1, buf, sizeof(buf), 0);
+#else // __BIONIC__
+ GTEST_LOG_(INFO) << "This test does nothing.\n";
+#endif // __BIONIC__
}
-
-#endif