Commit a4ccd684 by Gert Wollny Committed by Angle LUCI CQ

Capture/Replay: Write some bytes when serializing blobs

Seeing a few bytes of the buffers might help to get an understanding of what goes wrong when blob check sums don't match. Bug: None Change-Id: I482af2b3d885afca39057d0841923449ec65d611 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2900218 Commit-Queue: Gert Wollny <gert.wollny@collabora.com> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarCody Northrop <cnorthrop@google.com>
parent ce45bd1c
......@@ -61,7 +61,17 @@ void JsonSerializer::addBlob(const std::string &name, const uint8_t *blob, size_
{
os << kASCII[hash[i] & 0xf] << kASCII[hash[i] >> 4];
}
addString(name, os.str());
std::ostringstream hash_name;
hash_name << name << "-hash";
addString(hash_name.str(), os.str());
std::vector<uint8_t> data(length < 16 ? length : (size_t)16);
std::copy(blob, blob + data.size(), data.begin());
std::ostringstream raw_name;
raw_name << name << "-raw[0-" << data.size() - 1 << ']';
addVector(raw_name.str(), data);
}
void JsonSerializer::addCString(const std::string &name, const char *value)
......
......@@ -105,7 +105,14 @@ TEST_F(JsonSerializerTest, ByteArrayValue)
const std::string expect =
R"({
"context": {
"test2": "SHA1:4315724B1AB1EB2C0128E8E9DAD6D76254BA711D"
"test2-hash": "SHA1:4315724B1AB1EB2C0128E8E9DAD6D76254BA711D",
"test2-raw[0-4]": [
10,
0,
204,
255,
170
]
}
})";
......@@ -142,7 +149,21 @@ TEST_F(JsonSerializerTest, IntVectorAsBlobValue)
const std::string expect =
R"({
"context": {
"test2": "SHA1:6216A439C16A113E2F1E53AB63FB88877D3597F5"
"test2-hash": "SHA1:6216A439C16A113E2F1E53AB63FB88877D3597F5",
"test2-raw[0-11]": [
0,
0,
0,
0,
1,
0,
0,
0,
255,
255,
255,
255
]
}
})";
check(expect);
......@@ -172,7 +193,15 @@ TEST_F(JsonSerializerTest, ShortVectorAsBlobValue)
const std::string expect =
R"({
"context": {
"test2": "SHA1:0BA7C0DE700CE0F8018D084B8CF447B150A9465D"
"test2-hash": "SHA1:0BA7C0DE700CE0F8018D084B8CF447B150A9465D",
"test2-raw[0-5]": [
0,
0,
1,
0,
255,
255
]
}
})";
check(expect);
......
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