diff options
Diffstat (limited to 'llvm/lib/Fuzzer/test')
-rw-r--r-- | llvm/lib/Fuzzer/test/CMakeLists.txt | 1 | ||||
-rw-r--r-- | llvm/lib/Fuzzer/test/UserSuppliedFuzzerTest.cpp | 51 | ||||
-rw-r--r-- | llvm/lib/Fuzzer/test/fuzzer.test | 2 |
3 files changed, 0 insertions, 54 deletions
diff --git a/llvm/lib/Fuzzer/test/CMakeLists.txt b/llvm/lib/Fuzzer/test/CMakeLists.txt index f7ed87e251f..709e96bf615 100644 --- a/llvm/lib/Fuzzer/test/CMakeLists.txt +++ b/llvm/lib/Fuzzer/test/CMakeLists.txt @@ -37,7 +37,6 @@ set(Tests ) set(CustomMainTests - UserSuppliedFuzzerTest ) set(UninstrumentedTests diff --git a/llvm/lib/Fuzzer/test/UserSuppliedFuzzerTest.cpp b/llvm/lib/Fuzzer/test/UserSuppliedFuzzerTest.cpp deleted file mode 100644 index 59f83b57bfa..00000000000 --- a/llvm/lib/Fuzzer/test/UserSuppliedFuzzerTest.cpp +++ /dev/null @@ -1,51 +0,0 @@ -// Simple test for a fuzzer. -// The fuzzer must find the string "Hi!" preceded by a magic value. -// Uses UserSuppliedFuzzer which ensures that the magic is present. -#include <cstdint> -#include <cassert> -#include <cstdlib> -#include <cstddef> -#include <cstring> -#include <iostream> - -#include "FuzzerInterface.h" - -static const uint64_t kMagic = 8860221463604ULL; - -class MyFuzzer : public fuzzer::UserSuppliedFuzzer { - public: - MyFuzzer(fuzzer::FuzzerRandomBase *Rand) - : fuzzer::UserSuppliedFuzzer(Rand) {} - int TargetFunction(const uint8_t *Data, size_t Size) { - if (Size <= 10) return 0; - if (memcmp(Data, &kMagic, sizeof(kMagic))) return 0; - // It's hard to get here w/o advanced fuzzing techniques (e.g. cmp tracing). - // So, we simply 'fix' the data in the custom mutator. - if (Data[8] == 'H') { - if (Data[9] == 'i') { - if (Data[10] == '!') { - std::cout << "BINGO; Found the target, exiting\n"; - exit(1); - } - } - } - return 0; - } - // Custom mutator. - virtual size_t Mutate(uint8_t *Data, size_t Size, size_t MaxSize) { - assert(MaxSize > sizeof(kMagic)); - if (Size < sizeof(kMagic)) - Size = sizeof(kMagic); - // "Fix" the data, then mutate. - memcpy(Data, &kMagic, std::min(MaxSize, sizeof(kMagic))); - return fuzzer::UserSuppliedFuzzer::Mutate( - Data + sizeof(kMagic), Size - sizeof(kMagic), MaxSize - sizeof(kMagic)); - } - // No need to redefine CrossOver() here. -}; - -int main(int argc, char **argv) { - fuzzer::FuzzerRandomLibc Rand(0); - MyFuzzer F(&Rand); - fuzzer::FuzzerDriver(argc, argv, F); -} diff --git a/llvm/lib/Fuzzer/test/fuzzer.test b/llvm/lib/Fuzzer/test/fuzzer.test index 4638b97ed6b..4b1e524e251 100644 --- a/llvm/lib/Fuzzer/test/fuzzer.test +++ b/llvm/lib/Fuzzer/test/fuzzer.test @@ -24,8 +24,6 @@ RUN: not LLVMFuzzer-CallerCalleeTest -cross_over=0 -max_len= # LLVMFuzzer-CallerCalleeTest -use_indir_calls=0 -cross_over=0 -max_len=6 -seed=1 -runs=1000000 2>&1 | FileCheck %s --check-prefix=Done1000000 -RUN: not LLVMFuzzer-UserSuppliedFuzzerTest -seed=1 -timeout=15 2>&1 | FileCheck %s - RUN: not LLVMFuzzer-UninstrumentedTest-Uninstrumented 2>&1 | FileCheck %s --check-prefix=UNINSTRUMENTED UNINSTRUMENTED: ERROR: __sanitizer_set_death_callback is not defined. Exiting. |