Always output the wire trace with the injected error format

The fuzzers will be updated to always expect this format. If
the fuzzer doesn't do error injection, it will simply skip
these bytes.

Bug: dawn:629
Change-Id: I894e95ce9c1048eda81593219f7fc5d91e123392
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/40121
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Stephen White <senorblanco@chromium.org>
This commit is contained in:
Austin Eng 2021-02-03 19:25:02 +00:00 committed by Commit Bot service account
parent 3aa929b6f6
commit c00bc90b7c
1 changed files with 7 additions and 1 deletions

View File

@ -38,7 +38,7 @@ namespace utils {
WireServerTraceLayer(const char* dir, dawn_wire::CommandHandler* handler)
: dawn_wire::CommandHandler(), mDir(dir), mHandler(handler) {
const char* sep = GetPathSeparator();
if (mDir.back() != *sep) {
if (mDir.size() > 0 && mDir.back() != *sep) {
mDir += sep;
}
}
@ -56,6 +56,12 @@ namespace utils {
ASSERT(!mFile.is_open());
mFile.open(filename,
std::ios_base::out | std::ios_base::binary | std::ios_base::trunc);
// Write the initial 8 bytes. This means the fuzzer should never inject an
// error.
const uint64_t injectedErrorIndex = 0xFFFF'FFFF'FFFF'FFFF;
mFile.write(reinterpret_cast<const char*>(&injectedErrorIndex),
sizeof(injectedErrorIndex));
}
const volatile char* HandleCommands(const volatile char* commands,