aboutsummaryrefslogtreecommitdiffhomepage
path: root/fuzz
diff options
context:
space:
mode:
authorGravatar mtklein <mtklein@chromium.org>2016-01-21 06:13:52 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2016-01-21 06:13:52 -0800
commitd4387ea99369ee1b89bbc9ffc0d8c203a8923515 (patch)
treed58aad12f55cfeba350c949bf49ce1feb331d34f /fuzz
parentdba57344090631bba798e64e78f776bf6afba89c (diff)
fuzz: list API fuzzing options if -t api and -n matches nothing.
Today we segfault if --name is empty. This fixes that too. This updates some terms: -t api lets us fuzz an API. BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1617713003 Review URL: https://codereview.chromium.org/1617713003
Diffstat (limited to 'fuzz')
-rw-r--r--fuzz/fuzz.cpp25
1 files changed, 17 insertions, 8 deletions
diff --git a/fuzz/fuzz.cpp b/fuzz/fuzz.cpp
index 91be1543bd..d879f298b2 100644
--- a/fuzz/fuzz.cpp
+++ b/fuzz/fuzz.cpp
@@ -23,13 +23,13 @@
__SK_FORCE_IMAGE_DECODER_LINKING;
DEFINE_string2(bytes, b, "", "A path to a file. This can be the fuzz bytes or a binary to parse.");
-DEFINE_string2(name, n, "", "If --type is 'api', run the DEF_FUZZ API fuzz with this name.");
+DEFINE_string2(name, n, "", "If --type is 'api', fuzz the API with this name.");
DEFINE_string2(type, t, "api", "How to interpret --bytes, either 'image', 'skp', or 'api'.");
DEFINE_string2(dump, d, "", "If not empty, dump 'image' or 'skp' types as a PNG with this name.");
static int printUsage(const char* name) {
- SkDebugf("Usage: %s -t <type> -b <path/to/file> [-n api_fuzz_name]\n", name);
+ SkDebugf("Usage: %s -t <type> -b <path/to/file> [-n api-to-fuzz]\n", name);
return 1;
}
@@ -47,25 +47,34 @@ int main(int argc, char** argv) {
return 2;
}
- switch (FLAGS_type[0][0]) {
- case 'a': return fuzz_api(bytes);
- case 'i': return fuzz_img(bytes);
- case 's': return fuzz_skp(bytes);
+ if (!FLAGS_type.isEmpty()) {
+ switch (FLAGS_type[0][0]) {
+ case 'a': return fuzz_api(bytes);
+ case 'i': return fuzz_img(bytes);
+ case 's': return fuzz_skp(bytes);
+ }
}
return printUsage(argv[0]);
}
int fuzz_api(SkData* bytes) {
+ const char* name = FLAGS_name.isEmpty() ? "" : FLAGS_name[0];
+
for (auto r = SkTRegistry<Fuzzable>::Head(); r; r = r->next()) {
auto fuzzable = r->factory();
- if (0 == strcmp(FLAGS_name[0], fuzzable.name)) {
+ if (0 == strcmp(name, fuzzable.name)) {
SkDebugf("Fuzzing %s...\n", fuzzable.name);
Fuzz fuzz(bytes);
fuzzable.fn(&fuzz);
return 0;
}
}
- SkDebugf("API fuzz %s not found\n", FLAGS_name[0]);
+
+ SkDebugf("When using --type api, please choose an API to fuzz with --name/-n:\n");
+ for (auto r = SkTRegistry<Fuzzable>::Head(); r; r = r->next()) {
+ auto fuzzable = r->factory();
+ SkDebugf("\t%s\n", fuzzable.name);
+ }
return 1;
}