mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-08-05 13:26:55 +00:00
[fuzzer] Add support for token-based fuzzing (e.g. for C++). Allow string flags.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@233745 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -6,6 +6,7 @@ set(CMAKE_CXX_FLAGS_RELEASE "${LIBFUZZER_FLAGS_BASE} -O0 -fsanitize-coverage=4")
|
||||
|
||||
set(Tests
|
||||
CounterTest
|
||||
CxxTokensTest
|
||||
FourIndependentBranchesTest
|
||||
FullCoverageSetTest
|
||||
InfiniteTest
|
||||
|
24
lib/Fuzzer/test/CxxTokensTest.cpp
Normal file
24
lib/Fuzzer/test/CxxTokensTest.cpp
Normal file
@@ -0,0 +1,24 @@
|
||||
// Simple test for a fuzzer. The fuzzer must find a sequence of C++ tokens.
|
||||
#include <cstdint>
|
||||
#include <cstdlib>
|
||||
#include <cstddef>
|
||||
#include <cstring>
|
||||
#include <iostream>
|
||||
|
||||
static void Found() {
|
||||
std::cout << "Found the target, exiting\n";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
extern "C" void TestOneInput(const uint8_t *Data, size_t Size) {
|
||||
// looking for "thread_local unsigned A;"
|
||||
if (Size < 24) return;
|
||||
if (0 == memcmp(&Data[0], "thread_local", 12))
|
||||
if (Data[12] == ' ')
|
||||
if (0 == memcmp(&Data[13], "unsigned", 8))
|
||||
if (Data[21] == ' ')
|
||||
if (Data[22] == 'A')
|
||||
if (Data[23] == ';')
|
||||
Found();
|
||||
}
|
||||
|
@@ -23,3 +23,6 @@ CounterTest: BINGO
|
||||
|
||||
RUN: not ./LLVMFuzzer-DFSanSimpleCmpTest -seed=1 -timeout=15 2>&1 | FileCheck %s --check-prefix=DFSanSimpleCmpTest
|
||||
DFSanSimpleCmpTest: Found the target:
|
||||
|
||||
RUN: not ./LLVMFuzzer-CxxTokensTest -seed=1 -timeout=15 -tokens=%S/../cxx_fuzzer_tokens.txt 2>&1 | FileCheck %s --check-prefix=CxxTokensTest
|
||||
CxxTokensTest: Found the target, exiting
|
||||
|
Reference in New Issue
Block a user