Merge "Simplify MemtagNoteTests" am: fe8e5ad222 am: abdc85bf5f

Original change: https://android-review.googlesource.com/c/platform/bionic/+/2636749

Change-Id: I2932d945af6cde5ad55d549ff3b65b6d074cc0af
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Florian Mayer 2023-06-24 01:20:35 +00:00 committed by Automerger Merge Worker
commit efe8a1b789
2 changed files with 10 additions and 7 deletions

View file

@ -231,18 +231,13 @@ TEST_P(MemtagNoteTest, SEGV) {
} }
// Note that we do not check running_with_hwasan() - what matters here is whether the test binary // Note that we do not check running_with_hwasan() - what matters here is whether the test binary
// itself is built with HWASan. // itself is built with HWASan.
bool withHWASAN = __has_feature(hwaddress_sanitizer);
bool withMTE = getauxval(AT_HWCAP2) & HWCAP2_MTE; bool withMTE = getauxval(AT_HWCAP2) & HWCAP2_MTE;
const char* kExpectedOutputHWASAN[] = {".*tag-mismatch.*", ".*tag-mismatch.*",
".*tag-mismatch.*"};
// Note that we do not check the exact si_code of the "async" variant, as it may be auto-upgraded // Note that we do not check the exact si_code of the "async" variant, as it may be auto-upgraded
// to asymm or even sync. // to asymm or even sync.
const char* kExpectedOutputMTE[] = {"normal exit\n", "SEGV_MTE[AS]ERR\n", "SEGV_MTESERR\n"}; const char* kExpectedOutputMTE[] = {"normal exit\n", "SEGV_MTE[AS]ERR\n", "SEGV_MTESERR\n"};
const char* kExpectedOutputNonMTE[] = {"normal exit\n", "normal exit\n", "normal exit\n"}; const char* kExpectedOutputNonMTE[] = {"normal exit\n", "normal exit\n", "normal exit\n"};
const char** kExpectedOutput = const char** kExpectedOutput = withMTE ? kExpectedOutputMTE : kExpectedOutputNonMTE;
withHWASAN ? kExpectedOutputHWASAN : (withMTE ? kExpectedOutputMTE : kExpectedOutputNonMTE);
const int kExpectedExitStatus = withHWASAN ? -SIGABRT : 0;
MemtagNote note = std::get<0>(GetParam()); MemtagNote note = std::get<0>(GetParam());
bool isStatic = std::get<1>(GetParam()); bool isStatic = std::get<1>(GetParam());
@ -252,7 +247,7 @@ TEST_P(MemtagNoteTest, SEGV) {
chmod(helper.c_str(), 0755); chmod(helper.c_str(), 0755);
ExecTestHelper eth; ExecTestHelper eth;
eth.SetArgs({helper.c_str(), nullptr}); eth.SetArgs({helper.c_str(), nullptr});
eth.Run([&]() { execve(helper.c_str(), eth.GetArgs(), eth.GetEnv()); }, kExpectedExitStatus, eth.Run([&]() { execve(helper.c_str(), eth.GetArgs(), eth.GetEnv()); }, 0,
kExpectedOutput[static_cast<int>(note)]); kExpectedOutput[static_cast<int>(note)]);
#else #else
GTEST_SKIP() << "bionic/arm64 only"; GTEST_SKIP() << "bionic/arm64 only";

View file

@ -1621,6 +1621,7 @@ cc_test {
diag: { diag: {
memtag_heap: true, memtag_heap: true,
}, },
hwaddress: false,
}, },
} }
@ -1633,6 +1634,7 @@ cc_test {
diag: { diag: {
memtag_heap: false, memtag_heap: false,
}, },
hwaddress: false,
}, },
} }
@ -1642,6 +1644,7 @@ cc_test {
srcs: ["heap_tagging_helper.cpp"], srcs: ["heap_tagging_helper.cpp"],
sanitize: { sanitize: {
memtag_heap: false, memtag_heap: false,
hwaddress: false,
}, },
} }
@ -1655,6 +1658,7 @@ cc_test {
diag: { diag: {
memtag_heap: true, memtag_heap: true,
}, },
hwaddress: false,
}, },
} }
@ -1668,6 +1672,7 @@ cc_test {
diag: { diag: {
memtag_heap: false, memtag_heap: false,
}, },
hwaddress: false,
}, },
} }
@ -1678,6 +1683,7 @@ cc_test {
static_executable: true, static_executable: true,
sanitize: { sanitize: {
memtag_heap: false, memtag_heap: false,
hwaddress: false,
}, },
} }
@ -1691,6 +1697,7 @@ cc_test {
diag: { diag: {
memtag_heap: true, memtag_heap: true,
}, },
hwaddress: false,
}, },
header_libs: ["bionic_libc_platform_headers"], header_libs: ["bionic_libc_platform_headers"],
cflags: ["-fexceptions"], cflags: ["-fexceptions"],
@ -1707,6 +1714,7 @@ cc_test {
diag: { diag: {
memtag_heap: true, memtag_heap: true,
}, },
hwaddress: false,
}, },
header_libs: ["bionic_libc_platform_headers"], header_libs: ["bionic_libc_platform_headers"],
cflags: ["-fexceptions"], cflags: ["-fexceptions"],