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

Unified Diff: fuzz/fuzz.cpp

Issue 1589493006: Restore creature comforts to fuzz binary (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: whoops 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
« no previous file with comments | « no previous file | 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
index 55f6046f6ebde515d36ebef34073ff5db1e10d1b..343e25b45303527a8a5cbfb5cc33bcebfb747afa 100644
--- a/fuzz/fuzz.cpp
+++ b/fuzz/fuzz.cpp
@@ -6,29 +6,31 @@
*/
#include "Fuzz.h"
-#include <stdlib.h>
+#include "SkCommandLineFlags.h"
#include <signal.h>
+#include <stdlib.h>
+
+DEFINE_string2(bytes, b, "", "A path to a file containing fuzzed bytes.");
+DEFINE_string2(match, m, "", "The usual --match, applied to DEF_FUZZ names.");
int main(int argc, char** argv) {
- if (argc < 3) {
- SkDebugf("Usage: %s <fuzz name> <path/to/fuzzed.data>\n", argv[0]);
+ SkCommandLineFlags::Parse(argc, argv);
+
+ if (FLAGS_bytes.isEmpty()) {
+ SkDebugf("Usage: %s -b <path/to/fuzzed.data> [-m pattern]\n", argv[0]);
kjlubick 2016/01/15 14:05:20 Protip: afl-fuzz also has a -m flag. It can be co
return 1;
}
- const char* name = argv[1];
- const char* path = argv[2];
-
- SkAutoTUnref<SkData> bytes(SkData::NewFromFileName(path));
- Fuzz fuzz(bytes);
+ SkAutoTUnref<SkData> bytes(SkData::NewFromFileName(FLAGS_bytes[0]));
for (auto r = SkTRegistry<Fuzzable>::Head(); r; r = r->next()) {
auto fuzzable = r->factory();
- if (0 == strcmp(name, fuzzable.name)) {
- SkDebugf("Running %s\n", fuzzable.name);
+ if (!SkCommandLineFlags::ShouldSkip(FLAGS_match, fuzzable.name)) {
+ SkDebugf("Fuzzing %s...\n", fuzzable.name);
+ Fuzz fuzz(bytes);
fuzzable.fn(&fuzz);
- return 0;
}
}
- return 1;
+ return 0;
}
« no previous file with comments | « no previous file | gyp/fuzz.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698