diff options
author | Evgenii Stepanov <eugenis@google.com> | 2022-01-21 11:12:11 -0800 |
---|---|---|
committer | Evgenii Stepanov <eugenis@google.com> | 2022-01-21 19:55:54 +0000 |
commit | e37ca53157a8e67ed79a3677264df9b3c57311e1 (patch) | |
tree | 779b32b78e571b57111cc56782e2c0fd68d49258 | |
parent | b838fbda2a91955404f41e5ca2a7671f69b38f4e (diff) | |
download | bionic-e37ca53157a8e67ed79a3677264df9b3c57311e1.tar.gz |
Fix MemtagNoteTest and make it runnable on non-MTE devices.
Update the path to the helper binary, and run the test on non-MTE
hardware with the expectation that the bug is not detected.
Test: bionic-unit-tests
Bug: none
Change-Id: I34eb4dc46d0bacd83824d307398f7891d4806686
-rw-r--r-- | tests/heap_tagging_level_test.cpp | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/tests/heap_tagging_level_test.cpp b/tests/heap_tagging_level_test.cpp index edbd995d9..cfb2490f1 100644 --- a/tests/heap_tagging_level_test.cpp +++ b/tests/heap_tagging_level_test.cpp @@ -197,24 +197,33 @@ class MemtagNoteTest : public testing::TestWithParam<std::tuple<MemtagNote, bool TEST_P(MemtagNoteTest, SEGV) { #if defined(__BIONIC__) && defined(__aarch64__) - if (!(getauxval(AT_HWCAP2) & HWCAP2_MTE)) { - GTEST_SKIP() << "requires MTE support"; - } + // Note that we do not check running_with_hwasan() - what matters here is whether the test binary + // itself is built with HWASan. + bool withHWASAN = __has_feature(hwaddress_sanitizer); + bool withMTE = getauxval(AT_HWCAP2) & HWCAP2_MTE; const char* kNoteSuffix[] = {"disabled", "async", "sync"}; - const char* kExpectedOutput[] = {"normal exit\n", "SEGV_MTEAERR\n", "SEGV_MTESERR\n"}; + const char* kExpectedOutputHWASAN[] = {".*tag-mismatch.*", ".*tag-mismatch.*", + ".*tag-mismatch.*"}; + const char* kExpectedOutputMTE[] = {"normal exit\n", "SEGV_MTEAERR\n", "SEGV_MTESERR\n"}; + const char* kExpectedOutputNonMTE[] = {"normal exit\n", "normal exit\n", "normal exit\n"}; + const char** kExpectedOutput = + withHWASAN ? kExpectedOutputHWASAN : (withMTE ? kExpectedOutputMTE : kExpectedOutputNonMTE); + const int kExpectedExitStatus = withHWASAN ? -SIGABRT : 0; MemtagNote note = std::get<0>(GetParam()); bool isStatic = std::get<1>(GetParam()); std::string helper_base = std::string("heap_tagging_") + (isStatic ? "static_" : "") + kNoteSuffix[static_cast<int>(note)] + "_helper"; fprintf(stderr, "=== %s\n", helper_base.c_str()); - std::string helper = GetTestlibRoot() + "/" + helper_base + "/" + helper_base; + std::string helper = GetTestlibRoot() + "/" + helper_base; chmod(helper.c_str(), 0755); ExecTestHelper eth; eth.SetArgs({helper.c_str(), nullptr}); - eth.Run([&]() { execve(helper.c_str(), eth.GetArgs(), eth.GetEnv()); }, 0, + eth.Run([&]() { execve(helper.c_str(), eth.GetArgs(), eth.GetEnv()); }, kExpectedExitStatus, kExpectedOutput[static_cast<int>(note)]); +#else + GTEST_SKIP() << "bionic/arm64 only"; #endif } |