| 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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 } | 87 } |
| 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.SectionD4RequestHuffmanExamples. |
| 98 string input = a2b_hex("828786448cf1e3c2e5f23a6ba0ab90f4" | 98 string input = a2b_hex("828684418cf1e3c2e5f23a6ba0ab90f4" |
| 99 "ff"); | 99 "ff"); |
| 100 | 100 |
| 101 HpackFuzzUtil::FuzzerContext context; | 101 HpackFuzzUtil::FuzzerContext context; |
| 102 HpackFuzzUtil::InitializeFuzzerContext(&context); | 102 HpackFuzzUtil::InitializeFuzzerContext(&context); |
| 103 | 103 |
| 104 EXPECT_TRUE( | 104 EXPECT_TRUE( |
| 105 HpackFuzzUtil::RunHeaderBlockThroughFuzzerStages(&context, input)); | 105 HpackFuzzUtil::RunHeaderBlockThroughFuzzerStages(&context, input)); |
| 106 | 106 |
| 107 std::map<string, string> expect; | 107 std::map<string, string> expect; |
| 108 expect[":method"] = "GET"; | 108 expect[":method"] = "GET"; |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 EXPECT_EQ(unmodified, buffer); | 143 EXPECT_EQ(unmodified, buffer); |
| 144 HpackFuzzUtil::FlipBits(reinterpret_cast<uint8*>(buffer), | 144 HpackFuzzUtil::FlipBits(reinterpret_cast<uint8*>(buffer), |
| 145 arraysize(buffer) - 1, | 145 arraysize(buffer) - 1, |
| 146 1); | 146 1); |
| 147 EXPECT_NE(unmodified, buffer); | 147 EXPECT_NE(unmodified, buffer); |
| 148 } | 148 } |
| 149 | 149 |
| 150 } // namespace | 150 } // namespace |
| 151 | 151 |
| 152 } // namespace net | 152 } // namespace net |
| OLD | NEW |