[compiler-rt] r312697 - [libFuzzer] simplify CustomCrossOverTest even more
Kostya Serebryany via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 6 22:33:05 PDT 2017
Author: kcc
Date: Wed Sep 6 22:33:05 2017
New Revision: 312697
URL: http://llvm.org/viewvc/llvm-project?rev=312697&view=rev
Log:
[libFuzzer] simplify CustomCrossOverTest even more
Modified:
compiler-rt/trunk/test/fuzzer/CustomCrossOverTest.cpp
compiler-rt/trunk/test/fuzzer/fuzzer-customcrossover.test
Modified: compiler-rt/trunk/test/fuzzer/CustomCrossOverTest.cpp
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/fuzzer/CustomCrossOverTest.cpp?rev=312697&r1=312696&r2=312697&view=diff
==============================================================================
--- compiler-rt/trunk/test/fuzzer/CustomCrossOverTest.cpp (original)
+++ compiler-rt/trunk/test/fuzzer/CustomCrossOverTest.cpp Wed Sep 6 22:33:05 2017
@@ -15,12 +15,20 @@
static const char *Separator = "-########-";
static const char *Target = "A-########-B";
+static volatile int sink;
+
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
assert(Data);
std::string Str(reinterpret_cast<const char *>(Data), Size);
static const size_t TargetHash = std::hash<std::string>{}(std::string(Target));
size_t StrHash = std::hash<std::string>{}(Str);
+ // Ensure we have 'A' and 'B' in the corpus.
+ if (Size == 1 && *Data == 'A')
+ sink++;
+ if (Size == 1 && *Data == 'B')
+ sink--;
+
if (TargetHash == StrHash) {
std::cout << "BINGO; Found the target, exiting\n" << std::flush;
exit(1);
Modified: compiler-rt/trunk/test/fuzzer/fuzzer-customcrossover.test
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/fuzzer/fuzzer-customcrossover.test?rev=312697&r1=312696&r2=312697&view=diff
==============================================================================
--- compiler-rt/trunk/test/fuzzer/fuzzer-customcrossover.test (original)
+++ compiler-rt/trunk/test/fuzzer/fuzzer-customcrossover.test Wed Sep 6 22:33:05 2017
@@ -1,13 +1,8 @@
RUN: %cpp_compiler %S/CustomCrossOverTest.cpp -o %t-CustomCrossOverTest
-RUN: rm -rf %t/CustomCrossover
-RUN: mkdir -p %t/CustomCrossover
-RUN: echo -n A > %t/CustomCrossover/digits
-RUN: echo -n B > %t/CustomCrossover/chars
-RUN: not %t-CustomCrossOverTest -seed=1 -runs=100000 %t/CustomCrossover 2>&1 | FileCheck %s --check-prefix=CHECK_CO
+RUN: not %t-CustomCrossOverTest -seed=1 -runs=100000 2>&1 | FileCheck %s --check-prefix=CHECK_CO
Disable cross_over, verify that we can't find the target w/o it.
-RUN: %t-CustomCrossOverTest -seed=1 -runs=1000000 %t/CustomCrossover -cross_over=0 2>&1 | FileCheck %s --check-prefix=CHECK_NO_CO
-RUN: rm -rf %t/CustomCrossover
+RUN: %t-CustomCrossOverTest -seed=1 -runs=1000000 -cross_over=0 2>&1 | FileCheck %s --check-prefix=CHECK_NO_CO
CHECK_CO: In LLVMFuzzerCustomCrossover
CHECK_CO: BINGO
More information about the llvm-commits
mailing list