diff options
author | 2016-01-15 06:19:53 -0800 | |
---|---|---|
committer | 2016-01-15 06:19:53 -0800 | |
commit | f5e9782bdea16bbe2983198ed5cd3df8e8af37c1 (patch) | |
tree | d125fa146cb157cae07f1fb8fd960f558709b934 /fuzz | |
parent | a115942ed69762206f87c680ef7ec98de3382fa6 (diff) |
Restore creature comforts to fuzz binary
The hack to remove these niceties didn't seem to make a difference in my
fuzz/s, so we might as well keep them.
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1589493006
Review URL: https://codereview.chromium.org/1589493006
Diffstat (limited to 'fuzz')
-rw-r--r-- | fuzz/fuzz.cpp | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/fuzz/fuzz.cpp b/fuzz/fuzz.cpp index 55f6046f6e..343e25b453 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]); 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; } |