Commit a55c82d4 authored by Clemens Backes's avatar Clemens Backes Committed by V8 LUCI CQ

Reland "[wasm][test] Fix test expectation"

This is a reland of 6f9cde1e, with
special handling for MSan as well.

Original change's description:
> [wasm][test] Fix test expectation
>
> In the mprotect case, there could be one or multiple succeeding writes
> until we finally crash. Thus do not check that we never successfully
> write, but just check that the last printed statement is *before* a
> write.
>
> R=jkummerow@chromium.org
>
> Bug: v8:12226
> Change-Id: I04209691a9320a9b29dd0ec364539e062ad2dc03
> Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3160343
> Commit-Queue: Clemens Backes <clemensb@chromium.org>
> Reviewed-by: Jakob Kummerow <jkummerow@chromium.org>
> Cr-Commit-Position: refs/heads/main@{#76829}

Bug: v8:12226
Cq-Include-Trybots: luci.v8.try:v8_linux64_msan_rel_ng
Change-Id: I85ca98be43fc1d933d39a4602194e1771c33007c
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3162037Reviewed-by: 's avatarJakob Kummerow <jkummerow@chromium.org>
Commit-Queue: Clemens Backes <clemensb@chromium.org>
Cr-Commit-Position: refs/heads/main@{#76839}
parent b7355768
......@@ -9,6 +9,7 @@
#include <signal.h>
#endif // V8_OS_POSIX && !V8_OS_FUCHSIA
#include "src/base/macros.h"
#include "src/flags/flags.h"
#include "src/wasm/code-space-access.h"
#include "src/wasm/module-compiler.h"
......@@ -230,10 +231,10 @@ class ParameterizedMemoryProtectionTestWithSignalHandling
if (uint8_t* write_address = current_handler_scope_->code_address_) {
// Print to the error output such that we can check against this message
// in the ASSERT_DEATH_IF_SUPPORTED below.
fprintf(stderr, "Writing to %p.\n", write_address);
fprintf(stderr, "Writing to code.\n");
// This write will crash if code is protected.
*write_address = 0;
fprintf(stderr, "Successfully wrote to %p.\n", write_address);
fprintf(stderr, "Successfully wrote to code.\n");
}
}
......@@ -315,10 +316,16 @@ TEST_P(ParameterizedMemoryProtectionTestWithSignalHandling, TestSignalHandler) {
pthread_kill(pthread_self(), SIGPROF);
base::OS::Sleep(base::TimeDelta::FromMilliseconds(10));
} while (uses_mprotect()), // Only loop for mprotect.
// Check that the subprocess tried to write, but did not succeed.
::testing::AllOf(
::testing::HasSubstr("Writing to"),
::testing::Not(::testing::HasSubstr("Successfully wrote"))));
// Check that the subprocess tried to write, but did not succeed.
#if V8_USE_ADDRESS_SANITIZER
::testing::ContainsRegex(
"Writing to code.\nAddressSanitizer:DEADLYSIGNAL"));
#elif V8_USE_MEMORY_SANITIZER
::testing::ContainsRegex(
"Writing to code.\nMemorySanitizer:DEADLYSIGNAL"));
#else
::testing::EndsWith("Writing to code.\n"));
#endif // V8_USE_ADDRESS_SANITIZER
#endif // GTEST_HAS_DEATH_TEST
} else {
base::Optional<CodeSpaceWriteScope> write_scope;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment