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

Side by Side Diff: fuzz/FuzzParsePath.cpp

Issue 2389853002: Add fuzz executable to GN (Closed)
Patch Set: Trim down deps Created 4 years, 2 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 unified diff | Download patch
« no previous file with comments | « BUILD.gn ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2016 Google Inc. 2 * Copyright 2016 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "Fuzz.h" 8 #include "Fuzz.h"
9 #include "SkString.h" 9 #include "SkString.h"
10 #include "SkParsePath.h" 10 #include "SkParsePath.h"
11 #include <stdlib.h> 11 #include <stdlib.h>
12 12
13 // Most of this is taken from random_parse_path.cpp and adapted to use the Fuzz 13 // Most of this is taken from random_parse_path.cpp and adapted to use the Fuzz
14 // instead of SKRandom 14 // instead of SKRandom
15 15
16 const struct Legal { 16 static const struct Legal {
17 char fSymbol; 17 char fSymbol;
18 int fScalars; 18 int fScalars;
19 } gLegal[] = { 19 } gLegal[] = {
20 { 'M', 2 }, 20 { 'M', 2 },
21 { 'H', 1 }, 21 { 'H', 1 },
22 { 'V', 1 }, 22 { 'V', 1 },
23 { 'L', 2 }, 23 { 'L', 2 },
24 { 'Q', 4 }, 24 { 'Q', 4 },
25 { 'T', 2 }, 25 { 'T', 2 },
26 { 'C', 6 }, 26 { 'C', 6 },
27 { 'S', 4 }, 27 { 'S', 4 },
28 { 'A', 4 }, 28 { 'A', 4 },
29 { 'Z', 0 }, 29 { 'Z', 0 },
30 }; 30 };
31 31
32 bool gEasy = false; // set to true while debugging to suppress unusual whitespa ce 32 static bool gEasy = false; // set to true while debugging to suppress unusual w hitespace
33 33
34 // mostly do nothing, then bias towards spaces 34 // mostly do nothing, then bias towards spaces
35 const char gWhiteSpace[] = { 0, 0, 0, 0, 0, 0, 0, 0, ' ', ' ', ' ', ' ', 0x09, 0 x0D, 0x0A }; 35 static const char gWhiteSpace[] = { 0, 0, 0, 0, 0, 0, 0, 0, ' ', ' ', ' ', ' ', 0x09, 0x0D, 0x0A };
36 36
37 static void add_white(Fuzz* fuzz, SkString* atom) { 37 static void add_white(Fuzz* fuzz, SkString* atom) {
38 if (gEasy) { 38 if (gEasy) {
39 atom->append(" "); 39 atom->append(" ");
40 return; 40 return;
41 } 41 }
42 int reps = fuzz->nextRangeU(0, 2); 42 int reps = fuzz->nextRangeU(0, 2);
43 for (int rep = 0; rep < reps; ++rep) { 43 for (int rep = 0; rep < reps; ++rep) {
44 int index = fuzz->nextRangeU(0, (int) SK_ARRAY_COUNT(gWhiteSpace) - 1); 44 int index = fuzz->nextRangeU(0, (int) SK_ARRAY_COUNT(gWhiteSpace) - 1);
45 if (gWhiteSpace[index]) { 45 if (gWhiteSpace[index]) {
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 SkString spec; 106 SkString spec;
107 uint32_t count = fuzz->nextRangeU(0, 40); 107 uint32_t count = fuzz->nextRangeU(0, 40);
108 for (uint32_t i = 0; i < count; ++i) { 108 for (uint32_t i = 0; i < count; ++i) {
109 spec.append(MakeRandomParsePathPiece(fuzz)); 109 spec.append(MakeRandomParsePathPiece(fuzz));
110 } 110 }
111 SkDebugf("SkParsePath::FromSVGString(%s, &path);\n",spec.c_str()); 111 SkDebugf("SkParsePath::FromSVGString(%s, &path);\n",spec.c_str());
112 if (!SkParsePath::FromSVGString(spec.c_str(), &path)){ 112 if (!SkParsePath::FromSVGString(spec.c_str(), &path)){
113 fuzz->signalBug(); 113 fuzz->signalBug();
114 } 114 }
115 } 115 }
OLDNEW
« no previous file with comments | « BUILD.gn ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698