2016-01-13 20:57:57 +00:00
|
|
|
/*
|
|
|
|
* 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"
|
|
|
|
|
|
|
|
class Fuzz : SkNoncopyable {
|
|
|
|
public:
|
|
|
|
explicit Fuzz(SkData*);
|
|
|
|
|
2016-01-14 12:59:42 +00:00
|
|
|
uint8_t nextB();
|
2016-01-13 20:57:57 +00:00
|
|
|
uint32_t nextU();
|
|
|
|
float nextF();
|
|
|
|
|
2016-01-15 13:46:54 +00:00
|
|
|
void signalBug (); // Tell afl-fuzz these inputs found a bug.
|
|
|
|
void signalBoring(); // Tell afl-fuzz these inputs are not worth testing.
|
|
|
|
|
2016-01-13 20:57:57 +00:00
|
|
|
private:
|
2016-01-15 13:46:54 +00:00
|
|
|
template <typename T>
|
|
|
|
T nextT();
|
|
|
|
|
2016-01-13 20:57:57 +00:00
|
|
|
SkAutoTUnref<SkData> fBytes;
|
2016-01-14 12:59:42 +00:00
|
|
|
int fNextByte;
|
2016-01-13 20:57:57 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
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)
|
|
|
|
|
|
|
|
#endif//Fuzz_DEFINED
|