]>
git.proxmox.com Git - rustc.git/blob - src/libcompiler_builtins/compiler-rt/test/fuzzer/RepeatedBytesTest.cpp
1 // This file is distributed under the University of Illinois Open Source
2 // License. See LICENSE.TXT for details.
4 // Simple test for a fuzzer. The fuzzer must find repeated bytes.
12 extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data
, size_t Size
) {
14 // Looking for AAAAAAAAAAAAAAAAAAAAAA or some such.
15 size_t CurA
= 0, MaxA
= 0;
16 for (size_t i
= 0; i
< Size
; i
++) {
17 // Make sure there are no conditionals in the loop so that
18 // coverage can't help the fuzzer.
19 int EQ
= Data
[i
] == 'A';
20 CurA
= EQ
* (CurA
+ 1);
22 MaxA
= GT
* CurA
+ (!GT
) * MaxA
;
25 std::cout
<< "BINGO; Found the target (Max: " << MaxA
<< "), exiting\n"