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

Unified Diff: net/spdy/fuzzing/hpack_fuzz_util_test.cc

Issue 269183008: HPACK changes required for specification draft '07 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Write '07 examples as a new file name. Remove previous one. Created 6 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: net/spdy/fuzzing/hpack_fuzz_util_test.cc
diff --git a/net/spdy/fuzzing/hpack_fuzz_util_test.cc b/net/spdy/fuzzing/hpack_fuzz_util_test.cc
index ebf400ce999bd6c17b60ff8656959def8ee82b01..e46907b8a550d7be26907ef93fb474604aceea33 100644
--- a/net/spdy/fuzzing/hpack_fuzz_util_test.cc
+++ b/net/spdy/fuzzing/hpack_fuzz_util_test.cc
@@ -10,15 +10,26 @@
#include "base/file_util.h"
#include "base/files/file.h"
#include "base/path_service.h"
+#include "base/strings/string_number_conversions.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace net {
+namespace {
+
using base::StringPiece;
using std::map;
using std::string;
+std::string a2b_hex(const char* hex_data) {
+ std::vector<uint8> output;
+ std::string result;
+ if (base::HexStringToBytes(hex_data, &output))
+ result.assign(reinterpret_cast<const char*>(&output[0]), output.size());
+ return result;
+}
+
TEST(HpackFuzzUtilTest, GeneratorContextInitialization) {
HpackFuzzUtil::GeneratorContext context;
HpackFuzzUtil::InitializeGeneratorContext(&context);
@@ -91,15 +102,13 @@ TEST(HpackFuzzUtilTest, SerializedHeaderBlockPrefixes) {
TEST(HpackFuzzUtilTest, PassValidInputThroughAllStages) {
// Example lifted from HpackDecoderTest.SectionD3RequestHuffmanExamples.
- char input[] =
- "\x82\x87\x86\x04\x8b\xdb\x6d\x88\x3e\x68\xd1\xcb\x12\x25\xba\x7f";
+ string input = a2b_hex("828786448ce7cf9bebe89b6fb16fa9b6ff");
HpackFuzzUtil::FuzzerContext context;
HpackFuzzUtil::InitializeFuzzerContext(&context);
- EXPECT_TRUE(HpackFuzzUtil::RunHeaderBlockThroughFuzzerStages(
- &context,
- StringPiece(input, arraysize(input) - 1)));
+ EXPECT_TRUE(
+ HpackFuzzUtil::RunHeaderBlockThroughFuzzerStages(&context, input));
std::map<string, string> expect;
expect[":method"] = "GET";
@@ -119,7 +128,7 @@ TEST(HpackFuzzUtilTest, ValidFuzzExamplesRegressionTest) {
source_root.Append(FILE_PATH_LITERAL("net"))
.Append(FILE_PATH_LITERAL("data"))
.Append(FILE_PATH_LITERAL("spdy_tests"))
- .Append(FILE_PATH_LITERAL("examples.hpack")),
+ .Append(FILE_PATH_LITERAL("examples_07.hpack")),
&input.input));
HpackFuzzUtil::FuzzerContext context;
@@ -144,4 +153,6 @@ TEST(HpackFuzzUtilTest, FlipBitsMutatesBuffer) {
EXPECT_NE(unmodified, buffer);
}
+} // namespace
+
} // namespace net

Powered by Google App Engine
This is Rietveld 408576698