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

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.h - Fuzz PNaCl bitcode records ----------------------------===//
jvoung (off chromium) 2015/06/02 16:14:03 NaClFuzz.cpp
Karl 2015/06/02 16:40:23 Done.
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 #include "llvm/Support/Format.h"
jvoung (off chromium) 2015/06/02 16:14:03 can some of this be trimmed?
Karl 2015/06/02 16:40:23 Done. Removed Format.h
17
18 #include <array>
19 #include <cmath>
20 #include <cstdlib>
21 #include <map>
jvoung (off chromium) 2015/06/02 16:14:03 where is <map> <set> <cmath> etc. used?
Karl 2015/06/02 16:40:23 Removed all <...> includes.
22 #include <set>
23
24
25 using namespace llvm;
26 using namespace naclfuzz;
jvoung (off chromium) 2015/06/02 16:14:03 Do you really need "using namespace naclfuzz"? Mos
Karl 2015/06/02 16:40:23 Sorry for all the unnecessary boilerplate. Most of
27
28 namespace {
29
30 // Names for edit actions.
31 const char *ActionNameArray[] = {
32 "Insert",
33 "Mutate",
34 "Remove",
35 "Replace",
36 "Swap"
37 };
38
39 } // end of anonymous namespace
40
41 namespace naclfuzz {
42
43 const char *RecordFuzzer::actionName(EditAction Action) {
44 return Action < array_lengthof(ActionNameArray)
45 ? ActionNameArray[Action] : "???";
46 }
47
48 RecordFuzzer::RecordFuzzer(NaClMungedBitcode &Bitcode,
49 RandomNumberGenerator &Generator)
50 : Bitcode(Bitcode), Generator(Generator) {
51 if (Bitcode.getBaseRecords().empty())
52 report_fatal_error(
53 "Sorry, the fuzzer doesn't know how to fuzz an empty record list");
54 }
55
56 RecordFuzzer::~RecordFuzzer() {}
57
58 void RecordFuzzer::clear() {
59 Bitcode.removeEdits();
60 }
61
62 } // end of namespace naclfuzz
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698