blob: 078eb4c3d971398288b1e2bf56bc98a43a755e2b [file] [log] [blame]
Max Moroz08dad542018-07-16 16:01:31 +00001#include <assert.h>
2#include <cstdint>
3#include <cstdio>
4#include <cstdlib>
5
6int x = 0;
7bool skip0 = false;
8bool skip1 = false;
9bool skip2 = false;
10
11__attribute__((noinline)) void det0() { x++; }
12__attribute__((noinline)) void det1() { x++; }
13__attribute__((noinline)) void det2() { x++; }
14__attribute__((noinline)) void det3() { x++; }
15__attribute__((noinline)) void det4() { x++; }
16
17__attribute__((noinline)) void ini0() { x++; }
18__attribute__((noinline)) void ini1() { x++; }
19__attribute__((noinline)) void ini2() { x++; }
20
21__attribute__((noinline)) void t0() { x++; }
22__attribute__((noinline)) void t1() { x++; }
23__attribute__((noinline)) void t2() { x++; }
24__attribute__((noinline)) void t3() { x++; }
25__attribute__((noinline)) void t4() { x++; }
26
27extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
28 if (Size == 1 && Data[0] == 'A' && !skip0) {
29 skip0 = true;
30 ini0();
31 }
32 if (Size == 1 && Data[0] == 'B' && !skip1) {
33 skip1 = true;
34 ini1();
35 }
36 if (Size == 1 && Data[0] == 'C' && !skip2) {
37 skip2 = true;
38 ini2();
39 }
40
41 det0();
42 det1();
43 int a = rand();
44 det2();
45
46 switch (a % 5) {
47 case 0:
48 t0();
49 break;
50 case 1:
51 t1();
52 break;
53 case 2:
54 t2();
55 break;
56 case 3:
57 t3();
58 break;
59 case 4:
60 t4();
61 break;
62 default:
63 assert(false);
64 }
65
66 det3();
67 det4();
68 return 0;
69}