Fix assertion strings and tidy up memcpy call
These changes were intended for submission as part of 58386.
Change-Id: I23f7ada1e8940dce6855176724ade1f2bb7687f8
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/59024
Auto-Submit: Alastair Donaldson <afdx@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Alastair Donaldson <afdx@google.com>
diff --git a/fuzzers/tint_common_fuzzer.cc b/fuzzers/tint_common_fuzzer.cc
index 88f0107..590ff15 100644
--- a/fuzzers/tint_common_fuzzer.cc
+++ b/fuzzers/tint_common_fuzzer.cc
@@ -205,8 +205,8 @@
// sizeof(uint32_t)` uint32_t values. If `size` is not a multiple of
// sizeof(uint32_t) then not all of `data` can be copied into
// `spirv_input`, and any trailing bytes are discarded.
- const size_t adjusted_size = (size / sizeof(uint32_t)) * sizeof(uint32_t);
- std::memcpy(spirv_input.data(), data, adjusted_size);
+ std::memcpy(spirv_input.data(), data,
+ spirv_input.size() * sizeof(uint32_t));
if (spirv_input.empty()) {
return 0;
}
diff --git a/fuzzers/tint_spirv_tools_fuzzer/fuzzer.cc b/fuzzers/tint_spirv_tools_fuzzer/fuzzer.cc
index dac05dc..6ca8b46 100644
--- a/fuzzers/tint_spirv_tools_fuzzer/fuzzer.cc
+++ b/fuzzers/tint_spirv_tools_fuzzer/fuzzer.cc
@@ -102,7 +102,8 @@
unsigned seed) {
assert((size % 4) == 0 &&
"A valid SPIR-V binary's size must be a multiple of 4, and the "
- "SPIR-V Tools fuzzer should only work with valid binaries.");
+ "SPIR-V Tools fuzzer should only work with valid binaries. Check that "
+ "the fuzzer has been correctly configured.");
std::vector<uint32_t> binary(size / sizeof(uint32_t));
std::memcpy(binary.data(), data, size);
@@ -175,8 +176,10 @@
}
assert((size % 4) == 0 &&
- "A valid SPIR-V binary's size is a multiple of 4 bytes, and the "
- "SPIR-V Tools fuzzer should only work with valid binaries.");
+ "By design, the SPIR-V Tools fuzzer should only ever test using valid "
+ "SPIR-V binaries, whose sizes should be multiples of 4 bytes. Check "
+ "that the fuzzer has been configured correctly, with a corpus of "
+ "valid SPIR-V binaries, and with only the custom mutator enabled.");
CommonFuzzer spv_to_wgsl(InputFormat::kSpv, OutputFormat::kWGSL);
spv_to_wgsl.EnableInspector();