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

Side by Side Diff: net/spdy/fuzzing/hpack_fuzz_util_test.cc

Issue 1263803002: Replace SpdyNameValueBlock typedef with SpdyHeaderBlock. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 4 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 unified diff | Download patch
« no previous file with comments | « net/spdy/fuzzing/hpack_fuzz_util.cc ('k') | net/spdy/hpack_decoder.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/files/file.h" 10 #include "base/files/file.h"
(...skipping 17 matching lines...) Expand all
28 HpackFuzzUtil::InitializeGeneratorContext(&context); 28 HpackFuzzUtil::InitializeGeneratorContext(&context);
29 29
30 // Context was seeded with initial name & value fixtures. 30 // Context was seeded with initial name & value fixtures.
31 EXPECT_LT(0u, context.names.size()); 31 EXPECT_LT(0u, context.names.size());
32 EXPECT_LT(0u, context.values.size()); 32 EXPECT_LT(0u, context.values.size());
33 } 33 }
34 34
35 TEST(HpackFuzzUtil, GeneratorContextExpansion) { 35 TEST(HpackFuzzUtil, GeneratorContextExpansion) {
36 HpackFuzzUtil::GeneratorContext context; 36 HpackFuzzUtil::GeneratorContext context;
37 37
38 map<string, string> headers = HpackFuzzUtil::NextGeneratedHeaderSet(&context); 38 SpdyHeaderBlock headers = HpackFuzzUtil::NextGeneratedHeaderSet(&context);
39 39
40 // Headers were generated, and the generator context was expanded. 40 // Headers were generated, and the generator context was expanded.
41 EXPECT_LT(0u, headers.size()); 41 EXPECT_LT(0u, headers.size());
42 EXPECT_LT(0u, context.names.size()); 42 EXPECT_LT(0u, context.names.size());
43 EXPECT_LT(0u, context.values.size()); 43 EXPECT_LT(0u, context.values.size());
44 } 44 }
45 45
46 // TODO(jgraettinger): A better test would mock a random generator and 46 // TODO(jgraettinger): A better test would mock a random generator and
47 // evaluate SampleExponential along fixed points of the [0,1] domain. 47 // evaluate SampleExponential along fixed points of the [0,1] domain.
48 TEST(HpackFuzzUtilTest, SampleExponentialRegression) { 48 TEST(HpackFuzzUtilTest, SampleExponentialRegression) {
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 // Example lifted from HpackDecoderTest.SectionD4RequestHuffmanExamples. 97 // Example lifted from HpackDecoderTest.SectionD4RequestHuffmanExamples.
98 string input = a2b_hex("828684418cf1e3c2e5f23a6ba0ab90f4" 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 SpdyHeaderBlock expect;
108 expect[":method"] = "GET"; 108 expect[":method"] = "GET";
109 expect[":scheme"] = "http"; 109 expect[":scheme"] = "http";
110 expect[":path"] = "/"; 110 expect[":path"] = "/";
111 expect[":authority"] = "www.example.com"; 111 expect[":authority"] = "www.example.com";
112 EXPECT_EQ(expect, context.third_stage->decoded_block()); 112 EXPECT_EQ(expect, context.third_stage->decoded_block());
113 } 113 }
114 114
115 TEST(HpackFuzzUtilTest, ValidFuzzExamplesRegressionTest) { 115 TEST(HpackFuzzUtilTest, ValidFuzzExamplesRegressionTest) {
116 base::FilePath source_root; 116 base::FilePath source_root;
117 ASSERT_TRUE(PathService::Get(base::DIR_SOURCE_ROOT, &source_root)); 117 ASSERT_TRUE(PathService::Get(base::DIR_SOURCE_ROOT, &source_root));
(...skipping 25 matching lines...) Expand all
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
OLDNEW
« no previous file with comments | « net/spdy/fuzzing/hpack_fuzz_util.cc ('k') | net/spdy/hpack_decoder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698