Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "net/spdy/fuzzing/hpack_fuzz_util.h" | 5 #include "net/spdy/fuzzing/hpack_fuzz_util.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 | 8 |
| 9 #include "base/base_paths.h" | 9 #include "base/base_paths.h" |
| 10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 88 | 88 |
| 89 TEST(HpackFuzzUtilTest, SerializedHeaderBlockPrefixes) { | 89 TEST(HpackFuzzUtilTest, SerializedHeaderBlockPrefixes) { |
| 90 EXPECT_EQ(string("\x00\x00\x00\x00", 4), HpackFuzzUtil::HeaderBlockPrefix(0)); | 90 EXPECT_EQ(string("\x00\x00\x00\x00", 4), HpackFuzzUtil::HeaderBlockPrefix(0)); |
| 91 EXPECT_EQ(string("\x00\x00\x00\x05", 4), HpackFuzzUtil::HeaderBlockPrefix(5)); | 91 EXPECT_EQ(string("\x00\x00\x00\x05", 4), HpackFuzzUtil::HeaderBlockPrefix(5)); |
| 92 EXPECT_EQ(string("\x4f\xb3\x0a\x91", 4), | 92 EXPECT_EQ(string("\x4f\xb3\x0a\x91", 4), |
| 93 HpackFuzzUtil::HeaderBlockPrefix(1337133713)); | 93 HpackFuzzUtil::HeaderBlockPrefix(1337133713)); |
| 94 } | 94 } |
| 95 | 95 |
| 96 TEST(HpackFuzzUtilTest, PassValidInputThroughAllStages) { | 96 TEST(HpackFuzzUtilTest, PassValidInputThroughAllStages) { |
| 97 // Example lifted from HpackDecoderTest.SectionD3RequestHuffmanExamples. | 97 // Example lifted from HpackDecoderTest.SectionD3RequestHuffmanExamples. |
| 98 string input = a2b_hex("828786448ce7cf9bebe89b6fb16fa9b6ff"); | 98 string input = a2b_hex("828786448cf1e3c2e5f23a6ba0ab90f4" |
| 99 "ff"); | |
|
Ryan Hamilton
2014/06/25 23:28:30
out of curiosity, why is this wrapped?
Johnny
2014/06/26 16:22:39
These examples are copy-pasted out of the spec doc
| |
| 99 | 100 |
| 100 HpackFuzzUtil::FuzzerContext context; | 101 HpackFuzzUtil::FuzzerContext context; |
| 101 HpackFuzzUtil::InitializeFuzzerContext(&context); | 102 HpackFuzzUtil::InitializeFuzzerContext(&context); |
| 102 | 103 |
| 103 EXPECT_TRUE( | 104 EXPECT_TRUE( |
| 104 HpackFuzzUtil::RunHeaderBlockThroughFuzzerStages(&context, input)); | 105 HpackFuzzUtil::RunHeaderBlockThroughFuzzerStages(&context, input)); |
| 105 | 106 |
| 106 std::map<string, string> expect; | 107 std::map<string, string> expect; |
| 107 expect[":method"] = "GET"; | 108 expect[":method"] = "GET"; |
| 108 expect[":scheme"] = "http"; | 109 expect[":scheme"] = "http"; |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 142 EXPECT_EQ(unmodified, buffer); | 143 EXPECT_EQ(unmodified, buffer); |
| 143 HpackFuzzUtil::FlipBits(reinterpret_cast<uint8*>(buffer), | 144 HpackFuzzUtil::FlipBits(reinterpret_cast<uint8*>(buffer), |
| 144 arraysize(buffer) - 1, | 145 arraysize(buffer) - 1, |
| 145 1); | 146 1); |
| 146 EXPECT_NE(unmodified, buffer); | 147 EXPECT_NE(unmodified, buffer); |
| 147 } | 148 } |
| 148 | 149 |
| 149 } // namespace | 150 } // namespace |
| 150 | 151 |
| 151 } // namespace net | 152 } // namespace net |
| OLD | NEW |