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

Unified Diff: fuzz/fuzz.cpp

Issue 1589563002: Add new fuzz binary. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: simplify gyp Created 4 years, 11 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
« fuzz/Fuzz.h ('K') | « fuzz/FuzzPaeth.cpp ('k') | gyp/fuzz.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: fuzz/fuzz.cpp
diff --git a/fuzz/fuzz.cpp b/fuzz/fuzz.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..6e3179095103916661273bef6fadd4e5c7d6f51c
--- /dev/null
+++ b/fuzz/fuzz.cpp
@@ -0,0 +1,40 @@
+/*
+ * Copyright 2016 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "Fuzz.h"
+#include "SkCommandLineFlags.h"
+
+DEFINE_string2(match, m, "", "The usual match patterns, applied to name.");
+DEFINE_string2(bytes, b, "", "Path to file containing fuzzed bytes.");
+
+int main(int argc, char** argv) {
+ SkCommandLineFlags::Parse(argc, argv);
+ SkAutoTUnref<SkData> bytes;
+ if (!FLAGS_bytes.isEmpty()) {
+ bytes.reset(SkData::NewFromFileName(FLAGS_bytes[0]));
+ }
+
+ for (auto r = SkTRegistry<Fuzzable>::Head(); r; r = r->next()) {
+ auto fuzzable = r->factory();
+ if (!SkCommandLineFlags::ShouldSkip(FLAGS_match, fuzzable.name)) {
+ SkDebugf("Running %s...\n", fuzzable.name);
+ Fuzz fuzz(bytes);
+ fuzzable.fn(&fuzz);
+ }
+ }
+ return 0;
+}
+
+
+Fuzz::Fuzz(SkData* bytes) : fBytes(SkSafeRef(bytes)) {}
+
+// These methods are all TODO(kjlubick).
+uint32_t Fuzz::nextU() { return 0; }
+float Fuzz::nextF() { return 0.0f; }
+uint32_t Fuzz::nextURange(uint32_t min, uint32_t max) { return min; }
+float Fuzz::nextFRange(float min, float max) { return min; }
+
« fuzz/Fuzz.h ('K') | « fuzz/FuzzPaeth.cpp ('k') | gyp/fuzz.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698