From b56d1182d1067e70910584cf0c8fd797a262d82a Mon Sep 17 00:00:00 2001 From: Evgeny Eltsin Date: Mon, 8 Jun 2020 21:12:56 +0200 Subject: [PATCH 1/2] Add util to skip tests with native_bridge Bug: 37920774 Bug: 157394871 Test: bionic-unit-tests Change-Id: Id949c9e568fd068daaf405a377813ee1480c2df7 --- tests/utils.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/tests/utils.h b/tests/utils.h index a9b8513ef..c1b7f65c8 100644 --- a/tests/utils.h +++ b/tests/utils.h @@ -25,6 +25,10 @@ #include #include +#if defined(__BIONIC__) +#include +#endif + #if defined(__BIONIC__) #include #else @@ -72,6 +76,21 @@ static inline bool running_with_hwasan() { #define SKIP_WITH_HWASAN if (running_with_hwasan()) GTEST_SKIP() +static inline bool running_with_native_bridge() { +#if defined(__BIONIC__) +#if defined(__arm__) + static const prop_info* pi = __system_property_find("ro.dalvik.vm.isa.arm"); + return pi != nullptr; +#elif defined(__aarch64__) + static const prop_info* pi = __system_property_find("ro.dalvik.vm.isa.arm64"); + return pi != nullptr; +#endif +#endif + return false; +} + +#define SKIP_WITH_NATIVE_BRIDGE if (running_with_native_bridge()) GTEST_SKIP() + #if defined(__linux__) #include From 45b36c2921c8d5986820d4c07864c7366ad7efd6 Mon Sep 17 00:00:00 2001 From: Evgeny Eltsin Date: Mon, 8 Jun 2020 21:19:12 +0200 Subject: [PATCH 2/2] Skip pthread_leak* tests with native_bridge Bug: 37920774 Bug: 157394871 Test: bionic-unit-tests --gtest_filter=*leak* Change-Id: Ifc5b66e4b640d1abae4dcf8dbc28612d24c7e972 --- tests/leak_test.cpp | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/tests/leak_test.cpp b/tests/leak_test.cpp index e0a3d5772..4ebf41f59 100644 --- a/tests/leak_test.cpp +++ b/tests/leak_test.cpp @@ -109,23 +109,21 @@ std::ostream& operator<<(std::ostream& os, const LeakChecker& lc) { // http://b/36045112 TEST(pthread_leak, join) { + SKIP_WITH_NATIVE_BRIDGE; // http://b/37920774 + LeakChecker lc; - for (size_t pass = 0; pass < 2; ++pass) { - for (int i = 0; i < 100; ++i) { - pthread_t thread; - ASSERT_EQ(0, pthread_create(&thread, nullptr, [](void*) -> void* { return nullptr; }, nullptr)); - ASSERT_EQ(0, pthread_join(thread, nullptr)); - } - - // A native bridge implementation might need a warm up pass to reach a steady state. - // http://b/37920774. - if (pass == 0) lc.Reset(); + for (int i = 0; i < 100; ++i) { + pthread_t thread; + ASSERT_EQ(0, pthread_create(&thread, nullptr, [](void*) -> void* { return nullptr; }, nullptr)); + ASSERT_EQ(0, pthread_join(thread, nullptr)); } } // http://b/36045112 TEST(pthread_leak, detach) { + SKIP_WITH_NATIVE_BRIDGE; // http://b/37920774 + LeakChecker lc; // Ancient devices with only 2 cores need a lower limit. @@ -158,8 +156,7 @@ TEST(pthread_leak, detach) { WaitUntilAllThreadsExited(tids, thread_count); - // A native bridge implementation might need a warm up pass to reach a steady state. - // http://b/37920774. + // TODO(b/158573595): the test is flaky without the warmup pass. if (pass == 0) lc.Reset(); } }