Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(473)

Unified Diff: net/spdy/spdy_framer_test.cc

Issue 677713002: Reland "Integrate SIMD optimisations for zlib" (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add MSan suppression, prevent crc_fold_copy reading outside allocated memory, inline insert_string_… Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | third_party/zlib/BUILD.gn » ('j') | third_party/zlib/deflate.c » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/spdy/spdy_framer_test.cc
diff --git a/net/spdy/spdy_framer_test.cc b/net/spdy/spdy_framer_test.cc
index 35b8a46c33f8d74a6fdedd52098fdd886340eea4..eafa89ec06fdd5fb58bafc83acd568da0fe5a501 100644
--- a/net/spdy/spdy_framer_test.cc
+++ b/net/spdy/spdy_framer_test.cc
@@ -2039,8 +2039,8 @@ TEST_P(SpdyFramerTest, CreateSynStreamCompressed) {
{
const char kDescription[] =
"SYN_STREAM frame, low pri, no FIN";
-
const SpdyPriority priority = IsSpdy2() ? 2 : 4;
+
const unsigned char kV2FrameData[] = {
0x80, spdy_version_ch_, 0x00, 0x01,
0x00, 0x00, 0x00, 0x36,
@@ -2077,15 +2077,70 @@ TEST_P(SpdyFramerTest, CreateSynStreamCompressed) {
0x80, 0x00, 0x00, 0x00,
0x00, 0xFF, 0xFF,
};
+ const unsigned char kV2SIMDFrameData[] = {
+ 0x80, spdy_version_ch_, 0x00, 0x01,
+ 0x00, 0x00, 0x00, 0x33,
+ 0x00, 0x00, 0x00, 0x01,
+ 0x00, 0x00, 0x00, 0x00,
+ 0x80, 0x00, 0x38, 0xea,
+ 0xdf, 0xa2, 0x51, 0xb2,
+ 0x62, 0x60, 0x62, 0x60,
+ 0x4e, 0x4a, 0x2c, 0x62,
+ 0x60, 0x06, 0x08, 0xa0,
+ 0xb4, 0xfc, 0x7c, 0x80,
+ 0x00, 0x62, 0x60, 0x06,
+ 0x13, 0x00, 0x01, 0x94,
+ 0x94, 0x58, 0x04, 0x10,
+ 0x40, 0x00, 0x00, 0x00,
+ 0x00, 0xff, 0xff,
+ };
+ const unsigned char kV3SIMDFrameData[] = {
+ 0x80, spdy_version_ch_, 0x00, 0x01,
+ 0x00, 0x00, 0x00, 0x32,
+ 0x00, 0x00, 0x00, 0x01,
+ 0x00, 0x00, 0x00, 0x00,
+ 0x80, 0x00, 0x38, 0xea,
+ 0xe3, 0xc6, 0xa7, 0xc2,
+ 0x02, 0xe5, 0x0e, 0x50,
+ 0xc2, 0x4b, 0x4a, 0x04,
+ 0xe5, 0x0b, 0x66, 0x80,
+ 0x00, 0x4a, 0xcb, 0xcf,
+ 0x07, 0x08, 0x20, 0x24,
+ 0x0a, 0x20, 0x80, 0x92,
+ 0x12, 0x8b, 0x00, 0x02,
+ 0x08, 0x00, 0x00, 0x00,
+ 0xff, 0xff,
+ };
+
SpdySynStreamIR syn_stream(1);
syn_stream.set_priority(priority);
syn_stream.SetHeader("bar", "foo");
syn_stream.SetHeader("foo", "bar");
scoped_ptr<SpdyFrame> frame(framer.SerializeSynStream(syn_stream));
+ const unsigned char* frame_data =
+ reinterpret_cast<const unsigned char*>(frame->data());
if (IsSpdy2()) {
- CompareFrame(kDescription, *frame, kV2FrameData, arraysize(kV2FrameData));
+ // Try comparing with SIMD version, if that fails, do a failing check
+ // with pretty printing against non-SIMD version
+ if (memcmp(frame_data,
+ kV2SIMDFrameData,
+ std::min(arraysize(kV2SIMDFrameData), frame->size())) != 0) {
+ CompareCharArraysWithHexError(kDescription,
+ frame_data,
+ frame->size(),
+ kV2FrameData,
+ arraysize(kV2FrameData));
+ }
} else if (IsSpdy3()) {
- CompareFrame(kDescription, *frame, kV3FrameData, arraysize(kV3FrameData));
+ if (memcmp(frame_data,
+ kV3SIMDFrameData,
+ std::min(arraysize(kV3SIMDFrameData), frame->size())) != 0) {
+ CompareCharArraysWithHexError(kDescription,
+ frame_data,
+ frame->size(),
+ kV3FrameData,
+ arraysize(kV3FrameData));
+ }
} else {
LOG(FATAL) << "Unsupported version in test.";
}
@@ -2274,14 +2329,66 @@ TEST_P(SpdyFramerTest, CreateSynReplyCompressed) {
0x00, 0x00, 0x00, 0xff,
0xff,
};
+ const unsigned char kV2SIMDFrameData[] = {
+ 0x80, spdy_version_ch_, 0x00, 0x02,
+ 0x00, 0x00, 0x00, 0x2f,
+ 0x00, 0x00, 0x00, 0x01,
+ 0x00, 0x00, 0x38, 0xea,
+ 0xdf, 0xa2, 0x51, 0xb2,
+ 0x62, 0x60, 0x62, 0x60,
+ 0x4e, 0x4a, 0x2c, 0x62,
+ 0x60, 0x06, 0x08, 0xa0,
+ 0xb4, 0xfc, 0x7c, 0x80,
+ 0x00, 0x62, 0x60, 0x06,
+ 0x13, 0x00, 0x01, 0x94,
+ 0x94, 0x58, 0x04, 0x10,
+ 0x40, 0x00, 0x00, 0x00,
+ 0x00, 0xff, 0xff,
+ };
+ const unsigned char kV3SIMDFrameData[] = {
+ 0x80, spdy_version_ch_, 0x00, 0x02,
+ 0x00, 0x00, 0x00, 0x2c,
+ 0x00, 0x00, 0x00, 0x01,
+ 0x38, 0xea, 0xe3, 0xc6,
+ 0xa7, 0xc2, 0x02, 0xe5,
+ 0x0e, 0x50, 0xc2, 0x4b,
+ 0x4a, 0x04, 0xe5, 0x0b,
+ 0x66, 0x80, 0x00, 0x4a,
+ 0xcb, 0xcf, 0x07, 0x08,
+ 0x20, 0x24, 0x0a, 0x20,
+ 0x80, 0x92, 0x12, 0x8b,
+ 0x00, 0x02, 0x08, 0x00,
+ 0x00, 0x00, 0xff, 0xff,
+ };
+
SpdySynReplyIR syn_reply(1);
syn_reply.SetHeader("bar", "foo");
syn_reply.SetHeader("foo", "bar");
scoped_ptr<SpdyFrame> frame(framer.SerializeSynReply(syn_reply));
+ const unsigned char* frame_data =
+ reinterpret_cast<const unsigned char*>(frame->data());
if (IsSpdy2()) {
- CompareFrame(kDescription, *frame, kV2FrameData, arraysize(kV2FrameData));
+ // Try comparing with SIMD version, if that fails, do a failing check
+ // with pretty printing against non-SIMD version
+ if (memcmp(frame_data,
+ kV2SIMDFrameData,
+ std::min(arraysize(kV2SIMDFrameData), frame->size())) != 0) {
+ CompareCharArraysWithHexError(kDescription,
+ frame_data,
+ frame->size(),
+ kV2FrameData,
+ arraysize(kV2FrameData));
+ }
} else if (IsSpdy3()) {
- CompareFrame(kDescription, *frame, kV3FrameData, arraysize(kV3FrameData));
+ if (memcmp(frame_data,
+ kV3SIMDFrameData,
+ std::min(arraysize(kV3SIMDFrameData), frame->size())) != 0) {
+ CompareCharArraysWithHexError(kDescription,
+ frame_data,
+ frame->size(),
+ kV3FrameData,
+ arraysize(kV3FrameData));
+ }
} else {
LOG(FATAL) << "Unsupported version in test.";
}
@@ -2851,14 +2958,66 @@ TEST_P(SpdyFramerTest, CreateHeadersCompressed) {
0x00, 0x00, 0x00, 0xff,
0xff,
};
+ const unsigned char kV2SIMDFrameData[] = {
+ 0x80, spdy_version_ch_, 0x00, 0x08,
+ 0x00, 0x00, 0x00, 0x2f,
+ 0x00, 0x00, 0x00, 0x01,
+ 0x00, 0x00, 0x38, 0xea,
+ 0xdf, 0xa2, 0x51, 0xb2,
+ 0x62, 0x60, 0x62, 0x60,
+ 0x4e, 0x4a, 0x2c, 0x62,
+ 0x60, 0x06, 0x08, 0xa0,
+ 0xb4, 0xfc, 0x7c, 0x80,
+ 0x00, 0x62, 0x60, 0x06,
+ 0x13, 0x00, 0x01, 0x94,
+ 0x94, 0x58, 0x04, 0x10,
+ 0x40, 0x00, 0x00, 0x00,
+ 0x00, 0xff, 0xff,
+ };
+ const unsigned char kV3SIMDFrameData[] = {
+ 0x80, spdy_version_ch_, 0x00, 0x08,
+ 0x00, 0x00, 0x00, 0x2c,
+ 0x00, 0x00, 0x00, 0x01,
+ 0x38, 0xea, 0xe3, 0xc6,
+ 0xa7, 0xc2, 0x02, 0xe5,
+ 0x0e, 0x50, 0xc2, 0x4b,
+ 0x4a, 0x04, 0xe5, 0x0b,
+ 0x66, 0x80, 0x00, 0x4a,
+ 0xcb, 0xcf, 0x07, 0x08,
+ 0x20, 0x24, 0x0a, 0x20,
+ 0x80, 0x92, 0x12, 0x8b,
+ 0x00, 0x02, 0x08, 0x00,
+ 0x00, 0x00, 0xff, 0xff,
+ };
+
SpdyHeadersIR headers_ir(1);
headers_ir.SetHeader("bar", "foo");
headers_ir.SetHeader("foo", "bar");
scoped_ptr<SpdyFrame> frame(framer.SerializeHeaders(headers_ir));
+ const unsigned char* frame_data =
+ reinterpret_cast<const unsigned char*>(frame->data());
if (IsSpdy2()) {
- CompareFrame(kDescription, *frame, kV2FrameData, arraysize(kV2FrameData));
+ // Try comparing with SIMD version, if that fails, do a failing check
+ // with pretty printing against non-SIMD version
+ if (memcmp(frame_data,
+ kV2SIMDFrameData,
+ std::min(arraysize(kV2SIMDFrameData), frame->size())) != 0) {
+ CompareCharArraysWithHexError(kDescription,
+ frame_data,
+ frame->size(),
+ kV2FrameData,
+ arraysize(kV2FrameData));
+ }
} else if (IsSpdy3()) {
- CompareFrame(kDescription, *frame, kV3FrameData, arraysize(kV3FrameData));
+ if (memcmp(frame_data,
+ kV3SIMDFrameData,
+ std::min(arraysize(kV3SIMDFrameData), frame->size())) != 0) {
+ CompareCharArraysWithHexError(kDescription,
+ frame_data,
+ frame->size(),
+ kV3FrameData,
+ arraysize(kV3FrameData));
+ }
} else {
// Deflate compression doesn't apply to HPACK.
}
« no previous file with comments | « no previous file | third_party/zlib/BUILD.gn » ('j') | third_party/zlib/deflate.c » ('J')

Powered by Google App Engine
This is Rietveld 408576698