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

Side by Side Diff: fuzz/Fuzz.h

Issue 1702383003: Create ParsePath API fuzz (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: fix float Created 4 years, 10 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 | « no previous file | fuzz/FuzzParsePath.cpp » ('j') | 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 #ifndef Fuzz_DEFINED 8 #ifndef Fuzz_DEFINED
9 #define Fuzz_DEFINED 9 #define Fuzz_DEFINED
10 10
11 #include "SkData.h" 11 #include "SkData.h"
12 #include "SkTRegistry.h" 12 #include "SkTRegistry.h"
13 #include "SkTypes.h" 13 #include "SkTypes.h"
14 14
15 class Fuzz : SkNoncopyable { 15 class Fuzz : SkNoncopyable {
16 public: 16 public:
17 explicit Fuzz(SkData*); 17 explicit Fuzz(SkData*);
18 18
19 bool nextBool();
19 uint8_t nextB(); 20 uint8_t nextB();
20 uint32_t nextU(); 21 uint32_t nextU();
22 // This can be nan, +- infinity, 0, anything.
21 float nextF(); 23 float nextF();
22 24
25 // Return the next fuzzed value [min, max) as an unsigned 32bit integer.
26 uint32_t nextRangeU(uint32_t min, uint32_t max);
27 /**
28 * Returns next fuzzed value [min...max) as a float.
29 * Will not be Infinity or NaN.
30 */
31 float nextRangeF(float min, float max);
32
23 void signalBug (); // Tell afl-fuzz these inputs found a bug. 33 void signalBug (); // Tell afl-fuzz these inputs found a bug.
24 void signalBoring(); // Tell afl-fuzz these inputs are not worth testing. 34 void signalBoring(); // Tell afl-fuzz these inputs are not worth testing.
25 35
26 private: 36 private:
27 template <typename T> 37 template <typename T>
28 T nextT(); 38 T nextT();
29 39
30 SkAutoTUnref<SkData> fBytes; 40 SkAutoTUnref<SkData> fBytes;
31 int fNextByte; 41 int fNextByte;
32 }; 42 };
33 43
34 struct Fuzzable { 44 struct Fuzzable {
35 const char* name; 45 const char* name;
36 void (*fn)(Fuzz*); 46 void (*fn)(Fuzz*);
37 }; 47 };
38 48
39 #define DEF_FUZZ(name, f) \ 49 #define DEF_FUZZ(name, f) \
40 static void fuzz_##name(Fuzz*); \ 50 static void fuzz_##name(Fuzz*); \
41 SkTRegistry<Fuzzable> register_##name({#name, fuzz_##name}); \ 51 SkTRegistry<Fuzzable> register_##name({#name, fuzz_##name}); \
42 static void fuzz_##name(Fuzz* f) 52 static void fuzz_##name(Fuzz* f)
43 53
44 #endif//Fuzz_DEFINED 54 #endif//Fuzz_DEFINED
OLDNEW
« no previous file with comments | « no previous file | fuzz/FuzzParsePath.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698