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

Side by Side Diff: lib/Bitcode/NaCl/TestUtils/NaClFuzz.cpp

Issue 1156103003: Initial implementation of a record-level bitcode fuzzer. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-llvm.git@fuzz
Patch Set: Fix issues in last patch. Created 5 years, 6 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
OLDNEW
(Empty)
1 //===- NaClFuzz.cpp - Fuzz PNaCl bitcode records --------------------------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file implements a basic fuzzer for a list of PNaCl bitcode records.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #include "llvm/ADT/STLExtras.h"
15 #include "llvm/Bitcode/NaCl/NaClFuzz.h"
16
17 using namespace llvm;
18
19 namespace {
20
21 // Names for edit actions.
22 const char *ActionNameArray[] = {
23 "Insert",
24 "Mutate",
25 "Remove",
26 "Replace",
27 "Swap"
28 };
29
30 } // end of anonymous namespace
31
32 namespace naclfuzz {
33
34 const char *RecordFuzzer::actionName(EditAction Action) {
35 return Action < array_lengthof(ActionNameArray)
36 ? ActionNameArray[Action] : "???";
37 }
38
39 RecordFuzzer::RecordFuzzer(NaClMungedBitcode &Bitcode,
40 RandomNumberGenerator &Generator)
41 : Bitcode(Bitcode), Generator(Generator) {
42 if (Bitcode.getBaseRecords().empty())
43 report_fatal_error(
44 "Sorry, the fuzzer doesn't know how to fuzz an empty record list");
45 }
46
47 RecordFuzzer::~RecordFuzzer() {}
48
49 void RecordFuzzer::clear() {
50 Bitcode.removeEdits();
51 }
52
53 } // end of namespace naclfuzz
OLDNEW
« no previous file with comments | « lib/Bitcode/NaCl/TestUtils/CMakeLists.txt ('k') | lib/Bitcode/NaCl/TestUtils/NaClRandNumGen.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698