diff options
author | Christopher Ferris <cferris@google.com> | 2013-12-20 18:43:21 -0800 |
---|---|---|
committer | Christopher Ferris <cferris@google.com> | 2014-02-06 20:12:21 -0800 |
commit | f04935c85e0b466f0d30d2cd4c0fa2fff62e7d6d (patch) | |
tree | 8f1c6af75517892648f49adad9d4d5d44c20f49c /tests/string_test.cpp | |
parent | e163a3986aa7d1c67fe3274eb9204812be0a6245 (diff) |
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
Diffstat (limited to 'tests/string_test.cpp')
-rw-r--r-- | tests/string_test.cpp | 35 |
1 files changed, 23 insertions, 12 deletions
diff --git a/tests/string_test.cpp b/tests/string_test.cpp index 1a7e27d92..c35976a3e 100644 --- a/tests/string_test.cpp +++ b/tests/string_test.cpp @@ -46,14 +46,16 @@ TEST(string, strerror) { ASSERT_STREQ("Unknown error 1234", strerror(1234)); } -#if __BIONIC__ // glibc's strerror isn't thread safe, only its strsignal. - +#if defined(__BIONIC__) static void* ConcurrentStrErrorFn(void*) { bool equal = (strcmp("Unknown error 2002", strerror(2002)) == 0); return reinterpret_cast<void*>(equal); } +#endif // __BIONIC__ +// glibc's strerror isn't thread safe, only its strsignal. TEST(string, strerror_concurrent) { +#if defined(__BIONIC__) const char* strerror1001 = strerror(1001); ASSERT_STREQ("Unknown error 1001", strerror1001); @@ -64,12 +66,13 @@ TEST(string, strerror_concurrent) { ASSERT_TRUE(static_cast<bool>(result)); ASSERT_STREQ("Unknown error 1001", strerror1001); +#else // __BIONIC__ + GTEST_LOG_(INFO) << "This test does nothing.\n"; +#endif // __BIONIC__ } -#endif - -#if __BIONIC__ // glibc's strerror_r doesn't even have the same signature as the POSIX one. TEST(string, strerror_r) { +#if defined(__BIONIC__) // glibc's strerror_r doesn't even have the same signature as the POSIX one. char buf[256]; // Valid. @@ -87,8 +90,10 @@ TEST(string, strerror_r) { // Buffer too small. ASSERT_EQ(-1, strerror_r(0, buf, 2)); ASSERT_EQ(ERANGE, errno); +#else // __BIONIC__ + GTEST_LOG_(INFO) << "This test does nothing.\n"; +#endif // __BIONIC__ } -#endif TEST(string, strsignal) { // A regular signal. @@ -478,8 +483,8 @@ TEST(string, strcpy) { } -#if __BIONIC__ TEST(string, strlcat) { +#if defined(__BIONIC__) StringTestState<char> state(SMALL); for (size_t i = 0; i < state.n; i++) { for (size_t j = 0; j < POS_ITER; j++) { @@ -504,11 +509,13 @@ TEST(string, strlcat) { ASSERT_TRUE(memcmp(state.ptr, state.ptr2, state.MAX_LEN + state.len[i]) == 0); } } +#else // __BIONIC__ + GTEST_LOG_(INFO) << "This test does nothing.\n"; +#endif // __BIONIC__ } -#endif -#if __BIONIC__ TEST(string, strlcpy) { +#if defined(__BIONIC__) StringTestState<char> state(SMALL); for (size_t j = 0; j < POS_ITER; j++) { state.NewIteration(); @@ -539,8 +546,10 @@ TEST(string, strlcpy) { ASSERT_FALSE((memcmp(state.ptr1, state.ptr, state.MAX_LEN) != 0) || (memcmp(state.ptr2, state.ptr + state.MAX_LEN, state.MAX_LEN) != 0)); } +#else // __BIONIC__ + GTEST_LOG_(INFO) << "This test does nothing.\n"; +#endif // __BIONIC__ } -#endif TEST(string, strncat) { StringTestState<char> state(SMALL); @@ -732,10 +741,10 @@ TEST(string, memcmp) { } } -#if defined(__BIONIC__) extern "C" int __memcmp16(const unsigned short *ptr1, const unsigned short *ptr2, size_t n); TEST(string, __memcmp16) { +#if defined(__BIONIC__) StringTestState<unsigned short> state(SMALL); for (size_t i = 0; i < state.n; i++) { @@ -758,8 +767,10 @@ TEST(string, __memcmp16) { ASSERT_EQ(expected, actual); } } +#else // __BIONIC__ + GTEST_LOG_(INFO) << "This test does nothing.\n"; +#endif // __BIONIC__ } -#endif TEST(string, wmemcmp) { StringTestState<wchar_t> state(SMALL); |