diff options
author | Elliott Hughes <enh@google.com> | 2021-02-18 17:11:56 -0800 |
---|---|---|
committer | Elliott Hughes <enh@google.com> | 2021-02-18 17:23:04 -0800 |
commit | e657eb4f8abc2bb21571df1c0d0e0cbfaadce1c1 (patch) | |
tree | ece8247ab16072e2fd1fca786be9050562bb3f60 | |
parent | 332065d57e734b65f56474d136d22d767e36cbcd (diff) |
Fix some bionic death tests.
These were creating tombstones and spewing to the log.
You need TEST_F() rather than TEST(), and the modern style is apparently
to use `using` rather than an empty subclass.
Bug: http://b/180605583
Test: run tests, check logcat
Change-Id: I1e639d34854aeff6f042c24643b769a6bcfab877
-rw-r--r-- | tests/cfi_test.cpp | 4 | ||||
-rw-r--r-- | tests/pthread_test.cpp | 7 | ||||
-rw-r--r-- | tests/semaphore_test.cpp | 7 | ||||
-rw-r--r-- | tests/setjmp_test.cpp | 7 | ||||
-rw-r--r-- | tests/stdio_test.cpp | 10 |
5 files changed, 21 insertions, 14 deletions
diff --git a/tests/cfi_test.cpp b/tests/cfi_test.cpp index e0ae3afc7..d3cd8d1b8 100644 --- a/tests/cfi_test.cpp +++ b/tests/cfi_test.cpp @@ -35,6 +35,8 @@ void __cfi_slowpath_diag(uint64_t CallSiteTypeId, void* Ptr, void* DiagData); size_t __cfi_shadow_size(); } +using cfi_test_DeathTest = BionicDeathTest; + static void f() {} static void test_cfi_slowpath_with_alloc() { @@ -45,7 +47,7 @@ static void test_cfi_slowpath_with_alloc() { } } -TEST(cfi_test, basic) { +TEST_F(cfi_test_DeathTest, basic) { #if defined(__BIONIC__) void* handle; handle = dlopen("libcfi-test.so", RTLD_NOW | RTLD_LOCAL); diff --git a/tests/pthread_test.cpp b/tests/pthread_test.cpp index d9ad3ccb4..1cbe3de35 100644 --- a/tests/pthread_test.cpp +++ b/tests/pthread_test.cpp @@ -45,6 +45,8 @@ #include "SignalUtils.h" #include "utils.h" +using pthread_DeathTest = BionicDeathTest; + TEST(pthread, pthread_key_create) { pthread_key_t key; ASSERT_EQ(0, pthread_key_create(&key, nullptr)); @@ -352,9 +354,6 @@ struct TestBug37410 { // Even though this isn't really a death test, we have to say "DeathTest" here so gtest knows to // run this test (which exits normally) in its own process. - -class pthread_DeathTest : public BionicDeathTest {}; - TEST_F(pthread_DeathTest, pthread_bug_37410) { // http://code.google.com/p/android/issues/detail?id=37410 ASSERT_EXIT(TestBug37410::main(), ::testing::ExitedWithCode(0), ""); @@ -2468,7 +2467,7 @@ TEST(pthread, pthread_mutex_clocklock_invalid) { #endif // __BIONIC__ } -TEST(pthread, pthread_mutex_using_destroyed_mutex) { +TEST_F(pthread_DeathTest, pthread_mutex_using_destroyed_mutex) { #if defined(__BIONIC__) pthread_mutex_t m; ASSERT_EQ(0, pthread_mutex_init(&m, nullptr)); diff --git a/tests/semaphore_test.cpp b/tests/semaphore_test.cpp index 6ec8b2a85..ed0fcf17e 100644 --- a/tests/semaphore_test.cpp +++ b/tests/semaphore_test.cpp @@ -23,8 +23,11 @@ #include <time.h> #include <unistd.h> -#include "private/bionic_constants.h" +#include "BionicDeathTest.h" #include "SignalUtils.h" +#include "private/bionic_constants.h" + +using semaphore_DeathTest = BionicDeathTest; TEST(semaphore, sem_init) { sem_t s; @@ -158,7 +161,7 @@ TEST(semaphore, sem_clockwait) { #endif // __BIONIC__ } -TEST(semaphore_DeathTest, sem_timedwait_null_timeout) { +TEST_F(semaphore_DeathTest, sem_timedwait_null_timeout) { sem_t s; ASSERT_EQ(0, sem_init(&s, 0, 0)); diff --git a/tests/setjmp_test.cpp b/tests/setjmp_test.cpp index 24767044b..e6b681968 100644 --- a/tests/setjmp_test.cpp +++ b/tests/setjmp_test.cpp @@ -19,8 +19,11 @@ #include <setjmp.h> #include <stdlib.h> +#include "BionicDeathTest.h" #include "SignalUtils.h" +using setjmp_DeathTest = BionicDeathTest; + TEST(setjmp, setjmp_smoke) { int value; jmp_buf jb; @@ -226,7 +229,7 @@ TEST(setjmp, setjmp_fp_registers) { #define __JB_SIGFLAG 8 #endif -TEST(setjmp, setjmp_cookie) { +TEST_F(setjmp_DeathTest, setjmp_cookie) { jmp_buf jb; int value = setjmp(jb); ASSERT_EQ(0, value); @@ -241,7 +244,7 @@ TEST(setjmp, setjmp_cookie) { EXPECT_DEATH(longjmp(jb, 0), ""); } -TEST(setjmp, setjmp_cookie_checksum) { +TEST_F(setjmp_DeathTest, setjmp_cookie_checksum) { jmp_buf jb; int value = setjmp(jb); diff --git a/tests/stdio_test.cpp b/tests/stdio_test.cpp index afbbf2686..5491589a5 100644 --- a/tests/stdio_test.cpp +++ b/tests/stdio_test.cpp @@ -56,8 +56,8 @@ using namespace std::string_literals; -class stdio_DeathTest : public BionicDeathTest {}; -class stdio_nofortify_DeathTest : public BionicDeathTest {}; +using stdio_DeathTest = BionicDeathTest; +using stdio_nofortify_DeathTest = BionicDeathTest; static void SetFileTo(const char* path, const char* content) { FILE* fp; @@ -361,7 +361,7 @@ TEST(STDIO_TEST, snprintf_S) { // Synonym for %ls. EXPECT_STREQ("<hi>", buf); } -TEST(STDIO_TEST, snprintf_n) { +TEST_F(STDIO_DEATHTEST, snprintf_n) { #if defined(__BIONIC__) // http://b/14492135 and http://b/31832608. char buf[32]; @@ -2425,7 +2425,7 @@ TEST(STDIO_TEST, remove) { ASSERT_EQ(ENOENT, errno); } -TEST(STDIO_DEATHTEST, snprintf_30445072_known_buffer_size) { +TEST_F(STDIO_DEATHTEST, snprintf_30445072_known_buffer_size) { char buf[16]; ASSERT_EXIT(snprintf(buf, atol("-1"), "hello"), testing::KilledBySignal(SIGABRT), @@ -2437,7 +2437,7 @@ TEST(STDIO_DEATHTEST, snprintf_30445072_known_buffer_size) { ); } -TEST(STDIO_DEATHTEST, snprintf_30445072_unknown_buffer_size) { +TEST_F(STDIO_DEATHTEST, snprintf_30445072_unknown_buffer_size) { std::string buf = "world"; ASSERT_EXIT(snprintf(&buf[0], atol("-1"), "hello"), testing::KilledBySignal(SIGABRT), |