OLD | NEW |
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 bool nextBool(); |
20 uint8_t nextB(); | 20 uint8_t nextB(); |
21 uint32_t nextU(); | 21 uint32_t nextU(); |
22 // This can be nan, +- infinity, 0, anything. | 22 // This can be nan, +- infinity, 0, anything. |
23 float nextF(); | 23 float nextF(); |
| 24 // Returns a float between [0..1) as a IEEE float |
| 25 float nextF1(); |
24 | 26 |
25 // Return the next fuzzed value [min, max) as an unsigned 32bit integer. | 27 // Return the next fuzzed value [min, max) as an unsigned 32bit integer. |
26 uint32_t nextRangeU(uint32_t min, uint32_t max); | 28 uint32_t nextRangeU(uint32_t min, uint32_t max); |
27 /** | 29 /** |
28 * Returns next fuzzed value [min...max) as a float. | 30 * Returns next fuzzed value [min...max) as a float. |
29 * Will not be Infinity or NaN. | 31 * Will not be Infinity or NaN. |
30 */ | 32 */ |
31 float nextRangeF(float min, float max); | 33 float nextRangeF(float min, float max); |
32 | 34 |
33 void signalBug (); // Tell afl-fuzz these inputs found a bug. | 35 void signalBug (); // Tell afl-fuzz these inputs found a bug. |
(...skipping 11 matching lines...) Expand all Loading... |
45 const char* name; | 47 const char* name; |
46 void (*fn)(Fuzz*); | 48 void (*fn)(Fuzz*); |
47 }; | 49 }; |
48 | 50 |
49 #define DEF_FUZZ(name, f) \ | 51 #define DEF_FUZZ(name, f) \ |
50 static void fuzz_##name(Fuzz*); \ | 52 static void fuzz_##name(Fuzz*); \ |
51 SkTRegistry<Fuzzable> register_##name({#name, fuzz_##name}); \ | 53 SkTRegistry<Fuzzable> register_##name({#name, fuzz_##name}); \ |
52 static void fuzz_##name(Fuzz* f) | 54 static void fuzz_##name(Fuzz* f) |
53 | 55 |
54 #endif//Fuzz_DEFINED | 56 #endif//Fuzz_DEFINED |
OLD | NEW |