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; |
} |