Index: net/spdy/spdy_framer_test.cc |
diff --git a/net/spdy/spdy_framer_test.cc b/net/spdy/spdy_framer_test.cc |
index eafa89ec06fdd5fb58bafc83acd568da0fe5a501..35b8a46c33f8d74a6fdedd52098fdd886340eea4 100644 |
--- a/net/spdy/spdy_framer_test.cc |
+++ b/net/spdy/spdy_framer_test.cc |
@@ -2039,8 +2039,8 @@ |
{ |
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,70 +2077,15 @@ |
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()) { |
- // 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)); |
- } |
+ CompareFrame(kDescription, *frame, kV2FrameData, arraysize(kV2FrameData)); |
} else if (IsSpdy3()) { |
- if (memcmp(frame_data, |
- kV3SIMDFrameData, |
- std::min(arraysize(kV3SIMDFrameData), frame->size())) != 0) { |
- CompareCharArraysWithHexError(kDescription, |
- frame_data, |
- frame->size(), |
- kV3FrameData, |
- arraysize(kV3FrameData)); |
- } |
+ CompareFrame(kDescription, *frame, kV3FrameData, arraysize(kV3FrameData)); |
} else { |
LOG(FATAL) << "Unsupported version in test."; |
} |
@@ -2329,66 +2274,14 @@ |
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()) { |
- // 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)); |
- } |
+ CompareFrame(kDescription, *frame, kV2FrameData, arraysize(kV2FrameData)); |
} else if (IsSpdy3()) { |
- if (memcmp(frame_data, |
- kV3SIMDFrameData, |
- std::min(arraysize(kV3SIMDFrameData), frame->size())) != 0) { |
- CompareCharArraysWithHexError(kDescription, |
- frame_data, |
- frame->size(), |
- kV3FrameData, |
- arraysize(kV3FrameData)); |
- } |
+ CompareFrame(kDescription, *frame, kV3FrameData, arraysize(kV3FrameData)); |
} else { |
LOG(FATAL) << "Unsupported version in test."; |
} |
@@ -2958,66 +2851,14 @@ |
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()) { |
- // 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)); |
- } |
+ CompareFrame(kDescription, *frame, kV2FrameData, arraysize(kV2FrameData)); |
} else if (IsSpdy3()) { |
- if (memcmp(frame_data, |
- kV3SIMDFrameData, |
- std::min(arraysize(kV3SIMDFrameData), frame->size())) != 0) { |
- CompareCharArraysWithHexError(kDescription, |
- frame_data, |
- frame->size(), |
- kV3FrameData, |
- arraysize(kV3FrameData)); |
- } |
+ CompareFrame(kDescription, *frame, kV3FrameData, arraysize(kV3FrameData)); |
} else { |
// Deflate compression doesn't apply to HPACK. |
} |