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

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

Issue 1273743002: Add CompareSpdyHeaderBlocks() test helper method. (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 | « no previous file | net/spdy/hpack/hpack_decoder_test.cc » ('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"
11 #include "base/files/file_util.h" 11 #include "base/files/file_util.h"
12 #include "base/path_service.h" 12 #include "base/path_service.h"
13 #include "net/spdy/spdy_test_utils.h" 13 #include "net/spdy/spdy_test_utils.h"
14 #include "testing/gmock/include/gmock/gmock.h" 14 #include "testing/gmock/include/gmock/gmock.h"
15 #include "testing/gtest/include/gtest/gtest.h" 15 #include "testing/gtest/include/gtest/gtest.h"
16 16
17 namespace net { 17 namespace net {
18 18 namespace test {
19 namespace {
20 19
21 using base::StringPiece; 20 using base::StringPiece;
22 using std::map; 21 using std::map;
23 using std::string; 22 using std::string;
24 using test::a2b_hex; 23 using test::a2b_hex;
25 24
26 TEST(HpackFuzzUtilTest, GeneratorContextInitialization) { 25 TEST(HpackFuzzUtilTest, GeneratorContextInitialization) {
27 HpackFuzzUtil::GeneratorContext context; 26 HpackFuzzUtil::GeneratorContext context;
28 HpackFuzzUtil::InitializeGeneratorContext(&context); 27 HpackFuzzUtil::InitializeGeneratorContext(&context);
29 28
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 HpackFuzzUtil::InitializeFuzzerContext(&context); 101 HpackFuzzUtil::InitializeFuzzerContext(&context);
103 102
104 EXPECT_TRUE( 103 EXPECT_TRUE(
105 HpackFuzzUtil::RunHeaderBlockThroughFuzzerStages(&context, input)); 104 HpackFuzzUtil::RunHeaderBlockThroughFuzzerStages(&context, input));
106 105
107 SpdyHeaderBlock expect; 106 SpdyHeaderBlock expect;
108 expect[":method"] = "GET"; 107 expect[":method"] = "GET";
109 expect[":scheme"] = "http"; 108 expect[":scheme"] = "http";
110 expect[":path"] = "/"; 109 expect[":path"] = "/";
111 expect[":authority"] = "www.example.com"; 110 expect[":authority"] = "www.example.com";
112 EXPECT_EQ(expect, context.third_stage->decoded_block()); 111 EXPECT_TRUE(
112 CompareSpdyHeaderBlocks(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));
118 118
119 // Load the example fixtures versioned with the source tree. 119 // Load the example fixtures versioned with the source tree.
120 HpackFuzzUtil::Input input; 120 HpackFuzzUtil::Input input;
121 ASSERT_TRUE(base::ReadFileToString( 121 ASSERT_TRUE(base::ReadFileToString(
122 source_root.Append(FILE_PATH_LITERAL("net")) 122 source_root.Append(FILE_PATH_LITERAL("net"))
(...skipping 17 matching lines...) Expand all
140 char buffer[] = "testbuffer1234567890"; 140 char buffer[] = "testbuffer1234567890";
141 string unmodified(buffer, arraysize(buffer) - 1); 141 string unmodified(buffer, arraysize(buffer) - 1);
142 142
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 test
151
152 } // namespace net 151 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | net/spdy/hpack/hpack_decoder_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698