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

Unified Diff: tools/gn/parser_fuzzer.cc

Issue 2275683002: Add a fuzzer for gn's parser. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: no c Created 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/gn/BUILD.gn ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/gn/parser_fuzzer.cc
diff --git a/tools/gn/parser_fuzzer.cc b/tools/gn/parser_fuzzer.cc
new file mode 100644
index 0000000000000000000000000000000000000000..c7b432552eb560a913bf0009b9fb18b923d32474
--- /dev/null
+++ b/tools/gn/parser_fuzzer.cc
@@ -0,0 +1,24 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include <stdint.h>
+
+#include "tools/gn/input_file.h"
+#include "tools/gn/parser.h"
+#include "tools/gn/source_file.h"
+#include "tools/gn/tokenizer.h"
+
+extern "C" int LLVMFuzzerTestOneInput(const unsigned char* data, size_t size) {
+ SourceFile source;
+ InputFile input(source);
+ input.SetContents(std::string(reinterpret_cast<const char*>(data), size));
+
+ Err err;
+ std::vector<Token> tokens = Tokenizer::Tokenize(&input, &err);
+
+ if (!err.has_error())
+ Parser::Parse(tokens, &err);
+
+ return 0;
+}
« no previous file with comments | « tools/gn/BUILD.gn ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698