Chromium Code Reviews| Index: lib/Bitcode/NaCl/TestUtils/NaClFuzz.cpp |
| diff --git a/lib/Bitcode/NaCl/TestUtils/NaClFuzz.cpp b/lib/Bitcode/NaCl/TestUtils/NaClFuzz.cpp |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..c7baa6d1563ba168c92e0ccc27e7803f5d086a4a |
| --- /dev/null |
| +++ b/lib/Bitcode/NaCl/TestUtils/NaClFuzz.cpp |
| @@ -0,0 +1,60 @@ |
| +//===- NaClFuzz.h - Fuzz PNaCl bitcode records ------------------*- C++ -*-===// |
|
jvoung (off chromium)
2015/06/01 17:26:35
NaClFuzz.cpp
No need to have the -*- C++... stuff
Karl
2015/06/01 22:40:54
Done.
|
| +// |
| +// The LLVM Compiler Infrastructure |
| +// |
| +// This file is distributed under the University of Illinois Open Source |
| +// License. See LICENSE.TXT for details. |
| +// |
| +//===----------------------------------------------------------------------===// |
| +// |
| +// This file implements a basic fuzzer for a list of PNaCl bitcode records. |
|
jvoung (off chromium)
2015/06/01 17:26:35
//===---------------------------------------------
Karl
2015/06/01 22:40:54
Done.
|
| + |
| +#include "llvm/ADT/STLExtras.h" |
| +#include "llvm/Bitcode/NaCl/NaClFuzz.h" |
| +#include "llvm/Support/Format.h" |
| + |
| +#include <array> |
| +#include <cmath> |
| +#include <cstdlib> |
| +#include <map> |
| +#include <set> |
| + |
| + |
| +using namespace llvm; |
| +using namespace naclfuzz; |
| + |
| +namespace { |
| + |
| +// Names for edit actions. |
| +const char *ActionNameArray[] = { |
| + "Insert", |
| + "Mutate", |
| + "Remove", |
| + "Replace", |
| + "Swap" |
| +}; |
| + |
| +} // end of namespace naclfuzz |
|
jvoung (off chromium)
2015/06/01 17:26:35
This is anonymous namespace instead of namespace n
Karl
2015/06/01 22:40:54
Done.
|
| + |
| +namespace naclfuzz { |
| + |
| +const char *RecordFuzzer::actionName(EditAction Action) { |
| + return Action < array_lengthof(ActionNameArray) |
| + ? ActionNameArray[Action] : "???"; |
| +} |
| + |
| +RecordFuzzer::RecordFuzzer(NaClMungedBitcode &Bitcode, |
| + RandomNumberGenerator &Generator) |
| + : Bitcode(Bitcode), Generator(Generator) { |
| + if (Bitcode.getBaseRecords().empty()) |
| + report_fatal_error( |
| + "Sorry, the fuzzer doesn't know how to fuzz an empty record list"); |
| +} |
| + |
| +RecordFuzzer::~RecordFuzzer() {} |
| + |
| +void RecordFuzzer::clear() { |
| + Bitcode.removeEdits(); |
| +} |
| + |
| +} // end of namespace naclfuzz |