[llvm] r292509 - [libFuzzer] add two tests for experimenting with equivalence fuzzing
Kostya Serebryany via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 19 11:07:26 PST 2017
Author: kcc
Date: Thu Jan 19 13:07:26 2017
New Revision: 292509
URL: http://llvm.org/viewvc/llvm-project?rev=292509&view=rev
Log:
[libFuzzer] add two tests for experimenting with equivalence fuzzing
Added:
llvm/trunk/lib/Fuzzer/test/EquivalenceATest.cpp
llvm/trunk/lib/Fuzzer/test/EquivalenceBTest.cpp
Modified:
llvm/trunk/lib/Fuzzer/FuzzerLoop.cpp
llvm/trunk/lib/Fuzzer/test/CMakeLists.txt
Modified: llvm/trunk/lib/Fuzzer/FuzzerLoop.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Fuzzer/FuzzerLoop.cpp?rev=292509&r1=292508&r2=292509&view=diff
==============================================================================
--- llvm/trunk/lib/Fuzzer/FuzzerLoop.cpp (original)
+++ llvm/trunk/lib/Fuzzer/FuzzerLoop.cpp Thu Jan 19 13:07:26 2017
@@ -814,4 +814,7 @@ size_t LLVMFuzzerMutate(uint8_t *Data, s
assert(fuzzer::F);
return fuzzer::F->GetMD().DefaultMutate(Data, Size, MaxSize);
}
+
+// Experimental
+void LLVMFuzzerAnnounceOutput(const uint8_t *Data, size_t Size) {}
} // extern "C"
Modified: llvm/trunk/lib/Fuzzer/test/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Fuzzer/test/CMakeLists.txt?rev=292509&r1=292508&r2=292509&view=diff
==============================================================================
--- llvm/trunk/lib/Fuzzer/test/CMakeLists.txt (original)
+++ llvm/trunk/lib/Fuzzer/test/CMakeLists.txt Thu Jan 19 13:07:26 2017
@@ -72,6 +72,8 @@ set(Tests
CustomMutatorTest
DivTest
EmptyTest
+ EquivalenceATest
+ EquivalenceBTest
FourIndependentBranchesTest
FullCoverageSetTest
InitializeTest
Added: llvm/trunk/lib/Fuzzer/test/EquivalenceATest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Fuzzer/test/EquivalenceATest.cpp?rev=292509&view=auto
==============================================================================
--- llvm/trunk/lib/Fuzzer/test/EquivalenceATest.cpp (added)
+++ llvm/trunk/lib/Fuzzer/test/EquivalenceATest.cpp Thu Jan 19 13:07:26 2017
@@ -0,0 +1,15 @@
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+#include <stddef.h>
+#include <stdint.h>
+
+// Test for libFuzzer's "equivalence" fuzzing, part A.
+extern "C" void LLVMFuzzerAnnounceOutput(const uint8_t *Data, size_t Size);
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
+ if (Size > 100) return 0;
+ uint8_t Result[100];
+ for (size_t i = 0; i < Size; i++)
+ Result[Size - i - 1] = Data[i];
+ LLVMFuzzerAnnounceOutput(Result, Size);
+ return 0;
+}
Added: llvm/trunk/lib/Fuzzer/test/EquivalenceBTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Fuzzer/test/EquivalenceBTest.cpp?rev=292509&view=auto
==============================================================================
--- llvm/trunk/lib/Fuzzer/test/EquivalenceBTest.cpp (added)
+++ llvm/trunk/lib/Fuzzer/test/EquivalenceBTest.cpp Thu Jan 19 13:07:26 2017
@@ -0,0 +1,26 @@
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+#include <stddef.h>
+#include <stdint.h>
+#include <stdio.h>
+
+// Test for libFuzzer's "equivalence" fuzzing, part B.
+extern "C" void LLVMFuzzerAnnounceOutput(const uint8_t *Data, size_t Size);
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
+ if (Size > 100) return 0;
+ uint8_t Result[100];
+ for (size_t i = 0; i < Size; i++)
+ Result[Size - i - 1] = Data[i];
+
+ // Be a bit different from EquivalenceATest
+ if (Size > 42 && Data[10] == 'B') {
+ static int c;
+ if (!c)
+ fprintf(stderr, "ZZZZZZZ\n");
+ c = 1;
+ Result[42]++;
+ }
+
+ LLVMFuzzerAnnounceOutput(Result, Size);
+ return 0;
+}
More information about the llvm-commits
mailing list