Commit 94d1509e authored by Clemens Hammacher's avatar Clemens Hammacher Committed by Commit Bot

[wasm] [fuzzer] Also test validation

After compiling a function, check that validation produces the same
success/error result.

R=ahaas@chromium.org

Change-Id: I617881e125dccff485f5572557b19709de488d55
Reviewed-on: https://chromium-review.googlesource.com/565722Reviewed-by: 's avatarAndreas Haas <ahaas@chromium.org>
Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#46561}
parent 6f48866d
......@@ -127,26 +127,35 @@ int WasmExecutionFuzzer::FuzzWasmModule(
SyncCompile(i_isolate, &interpreter_thrower, wire_bytes);
// Clear the flag so that the WebAssembly code is not printed twice.
FLAG_wasm_code_fuzzer_gen_test = false;
if (compiled_module.is_null()) {
if (generate_test) {
bool compiles = !compiled_module.is_null();
if (generate_test) {
OFStream os(stdout);
os << " ])" << std::endl
<< " .exportFunc();" << std::endl;
if (compiles) {
os << " var module = builder.instantiate();" << std::endl
<< " module.exports.test(1, 2, 3);" << std::endl;
} else {
OFStream os(stdout);
os << " ])" << std::endl;
os << " .exportFunc();" << std::endl;
os << " assertThrows(function() { builder.instantiate(); });"
<< std::endl;
os << "})();" << std::endl;
}
return 0;
}
if (generate_test) {
OFStream os(stdout);
os << " ])" << std::endl;
os << " .exportFunc();" << std::endl;
os << " var module = builder.instantiate();" << std::endl;
os << " module.exports.test(1, 2, 3);" << std::endl;
os << "})();" << std::endl;
}
bool validates = wasm::SyncValidate(i_isolate, wire_bytes);
if (compiles != validates) {
uint32_t hash = StringHasher::HashSequentialString(
data, static_cast<int>(size), WASM_CODE_FUZZER_HASH_SEED);
V8_Fatal(__FILE__, __LINE__,
"compiles != validates (%d vs %d); WasmCodeFuzzerHash=%x",
compiles, validates, hash);
}
if (!compiles) return 0;
int32_t result_interpreted;
bool possible_nondeterminism = false;
{
......
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