LLVM
5.0.0
Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
lib
Fuzzer
test
Switch2Test.cpp
Go to the documentation of this file.
1
// This file is distributed under the University of Illinois Open Source
2
// License. See LICENSE.TXT for details.
3
4
// Simple test for a fuzzer. The fuzzer must find the interesting switch value.
5
#include <cstddef>
6
#include <cstdint>
7
#include <cstdio>
8
#include <cstdlib>
9
#include <cstring>
10
11
int
Switch
(
int
a) {
12
switch
(a) {
13
case
100001:
return
1;
14
case
100002:
return
2;
15
case
100003:
return
4;
16
}
17
return
0;
18
}
19
20
extern
"C"
int
LLVMFuzzerTestOneInput
(
const
uint8_t *
Data
,
size_t
Size
) {
21
const
int
N
= 3;
22
if
(Size < N *
sizeof
(
int
))
return
0;
23
int
Res = 0;
24
for
(
int
i = 0; i <
N
; i++) {
25
int
X
;
26
memcpy(&X, Data + i *
sizeof
(
int
),
sizeof
(
int
));
27
Res +=
Switch
(X);
28
}
29
if
(Res == 5 || Res == 3 || Res == 6 || Res == 7) {
30
fprintf(stderr,
"BINGO; Found the target, exiting; Res=%d\n"
, Res);
31
exit(1);
32
}
33
return
0;
34
}
35
llvm::Data
Definition:
SIMachineScheduler.h:59
Switch
int Switch(int a)
Definition:
Switch2Test.cpp:11
X
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang","erlang-compatible garbage collector")
N
const size_t N
Definition:
TableLookupTest.cpp:13
LLVMFuzzerTestOneInput
int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size)
Definition:
Switch2Test.cpp:20
llvm::AMDGPU::CodeObject::Kernel::Arg::Key::Size
constexpr char Size[]
Key for Kernel::Arg::Metadata::mSize.
Definition:
AMDGPUCodeObjectMetadata.h:154
Generated on Fri Sep 1 2017 14:13:37 for LLVM by
1.8.6