aboutsummaryrefslogtreecommitdiffhomepage
path: root/fuzz
diff options
context:
space:
mode:
authorGravatar Florin Malita <fmalita@chromium.org>2018-06-08 12:25:38 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-06-08 17:45:33 +0000
commit7796f00dcfd09ca52140c4133ddc9bc197b832db (patch)
treeea438f8ab65f69a8d5e1b93c1d759d347a928959 /fuzz
parent61e66867ae10451fd365a676747a2c853bdd723d (diff)
SkJson
For now this is only wired to a bench and a couple of tests. Local numbers, for a ~500KB BM "compressed" json: micros bench 2456.54 json_rapidjson nonrendering 1192.38 json_skjson nonrendering Change-Id: I7b3514f84c7c525d1787722c43ad6095e3692563 Reviewed-on: https://skia-review.googlesource.com/127622 Reviewed-by: Mike Klein <mtklein@google.com> Commit-Queue: Florin Malita <fmalita@chromium.org>
Diffstat (limited to 'fuzz')
-rw-r--r--fuzz/fuzz.cpp64
1 files changed, 44 insertions, 20 deletions
diff --git a/fuzz/fuzz.cpp b/fuzz/fuzz.cpp
index 0917747790..ce0119c1a9 100644
--- a/fuzz/fuzz.cpp
+++ b/fuzz/fuzz.cpp
@@ -28,10 +28,6 @@
#include "SkSLCompiler.h"
#endif
-#if defined(SK_ENABLE_SKOTTIE)
-#include "Skottie.h"
-#endif
-
#include <iostream>
#include <map>
#include <regex>
@@ -47,22 +43,31 @@ DEFINE_string2(name, n, "", "If --type is 'api', fuzz the API with this name.");
DEFINE_string2(dump, d, "", "If not empty, dump 'image*' or 'skp' types as a "
"PNG with this name.");
DEFINE_bool2(verbose, v, false, "Print more information while fuzzing.");
-DEFINE_string2(type, t, "", "How to interpret --bytes, one of:\n"
- "animated_image_decode\n"
- "api\n"
- "color_deserialize\n"
- "filter_fuzz (equivalent to Chrome's filter_fuzz_stub)\n"
- "image_decode\n"
- "image_mode\n"
- "image_scale\n"
- "path_deserialize\n"
- "pipe\n"
- "region_deserialize\n"
- "region_set_path\n"
- "skp\n"
- "sksl2glsl\n"
- "skottie_json\n"
- "textblob");
+
+// This cannot be inlined in DEFINE_string2 due to interleaved ifdefs
+static constexpr char g_type_message[] = "How to interpret --bytes, one of:\n"
+ "animated_image_decode\n"
+ "api\n"
+ "color_deserialize\n"
+ "filter_fuzz (equivalent to Chrome's filter_fuzz_stub)\n"
+ "image_decode\n"
+ "image_mode\n"
+ "image_scale\n"
+ "path_deserialize\n"
+ "pipe\n"
+ "region_deserialize\n"
+ "region_set_path\n"
+#if defined(SK_ENABLE_SKJSON)
+ "skjson\n"
+#endif
+ "skp\n"
+ "sksl2glsl\n"
+#if defined(SK_ENABLE_SKOTTIE)
+ "skottie_json\n"
+#endif
+ "textblob";
+
+DEFINE_string2(type, t, "", g_type_message);
static int fuzz_file(SkString path, SkString type);
static uint8_t calculate_option(SkData*);
@@ -87,6 +92,10 @@ static void print_api_names();
static void fuzz_sksl2glsl(sk_sp<SkData>);
#endif
+#if defined(SK_ENABLE_SKJSON)
+static void fuzz_skjson(sk_sp<SkData>);
+#endif
+
#if defined(SK_ENABLE_SKOTTIE)
static void fuzz_skottie_json(sk_sp<SkData>);
#endif
@@ -181,6 +190,12 @@ static int fuzz_file(SkString path, SkString type) {
fuzz_skpipe(bytes);
return 0;
}
+#if defined(SK_ENABLE_SKJSON)
+ if (type.equals("skjson")) {
+ fuzz_skjson(bytes);
+ return 0;
+ }
+#endif
#if defined(SK_ENABLE_SKOTTIE)
if (type.equals("skottie_json")) {
fuzz_skottie_json(bytes);
@@ -266,6 +281,15 @@ static SkString try_auto_detect(SkString path, SkString* name) {
return SkString("");
}
+#if defined(SK_ENABLE_SKJSON)
+void FuzzSkJSON(sk_sp<SkData> bytes);
+
+static void fuzz_skjson(sk_sp<SkData> bytes){
+ FuzzSkJSON(bytes);
+ SkDebugf("[terminated] Done parsing!\n");
+}
+#endif
+
#if defined(SK_ENABLE_SKOTTIE)
void FuzzSkottieJSON(sk_sp<SkData> bytes);