diff options
author | mtklein <mtklein@chromium.org> | 2016-01-13 12:57:57 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-01-13 12:57:58 -0800 |
commit | 65e5824d3a46c468530aba5de4c11b6c8de4cede (patch) | |
tree | 3364f0bdb819a17fc6ec068f22d0902c4d84f53e /fuzz/Fuzz.h | |
parent | fa8963252e122c5288c8e92b5ecc25a8fea21c3b (diff) |
Add new fuzz binary.
This is designed to have short startup time, for maximum fuzzing throughput.
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1589563002
Review URL: https://codereview.chromium.org/1589563002
Diffstat (limited to 'fuzz/Fuzz.h')
-rw-r--r-- | fuzz/Fuzz.h | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/fuzz/Fuzz.h b/fuzz/Fuzz.h new file mode 100644 index 0000000000..cf5bcb9ead --- /dev/null +++ b/fuzz/Fuzz.h @@ -0,0 +1,43 @@ +/* + * Copyright 2016 Google Inc. + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#ifndef Fuzz_DEFINED +#define Fuzz_DEFINED + +#include "SkData.h" +#include "SkTRegistry.h" +#include "SkTypes.h" +#include <stdlib.h> + +class Fuzz : SkNoncopyable { +public: + explicit Fuzz(SkData*); + + uint32_t nextU(); + float nextF(); + + // These return a value in [min, max). + uint32_t nextURange(uint32_t min, uint32_t max); + float nextFRange(float min, float max); + +private: + SkAutoTUnref<SkData> fBytes; +}; + +struct Fuzzable { + const char* name; + void (*fn)(Fuzz*); +}; + +#define DEF_FUZZ(name, f) \ + static void fuzz_##name(Fuzz*); \ + SkTRegistry<Fuzzable> register_##name({#name, fuzz_##name}); \ + static void fuzz_##name(Fuzz* f) + +#define ASSERT(cond) do { if (!(cond)) abort(); } while(false) + +#endif//Fuzz_DEFINED |