From: Alexey Samsonov Date: Tue, 21 Jul 2015 22:51:49 +0000 (+0000) Subject: [Fuzzer] Clearly separate regular and DFSan tests. NFC. X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=bb577748c0a1ad96b5861fa42636c2e63779830e;p=oota-llvm.git [Fuzzer] Clearly separate regular and DFSan tests. NFC. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@242850 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Fuzzer/test/CMakeLists.txt b/lib/Fuzzer/test/CMakeLists.txt index a9acec15d4d..2769f6a114a 100644 --- a/lib/Fuzzer/test/CMakeLists.txt +++ b/lib/Fuzzer/test/CMakeLists.txt @@ -5,8 +5,8 @@ set(CMAKE_CXX_FLAGS_RELEASE "${LIBFUZZER_FLAGS_BASE} -O0 -fsanitize-coverage=edge,indirect-calls") set(DFSanTests - DFSanMemcmpTest - DFSanSimpleCmpTest + MemcmpTest + SimpleCmpTest ) set(Tests @@ -16,9 +16,9 @@ set(Tests FullCoverageSetTest InfiniteTest NullDerefTest + SimpleCmpTest SimpleTest TimeoutTest - ${DFSanTests} ) set(CustomMainTests diff --git a/lib/Fuzzer/test/DFSanMemcmpTest.cpp b/lib/Fuzzer/test/DFSanMemcmpTest.cpp deleted file mode 100644 index 510a2439800..00000000000 --- a/lib/Fuzzer/test/DFSanMemcmpTest.cpp +++ /dev/null @@ -1,12 +0,0 @@ -// Simple test for a fuzzer. The fuzzer must find a particular string. -#include -#include -#include -#include - -extern "C" void LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) { - if (Size >= 8 && memcmp(Data, "01234567", 8) == 0) { - fprintf(stderr, "BINGO\n"); - exit(1); - } -} diff --git a/lib/Fuzzer/test/DFSanSimpleCmpTest.cpp b/lib/Fuzzer/test/DFSanSimpleCmpTest.cpp deleted file mode 100644 index ee378146dae..00000000000 --- a/lib/Fuzzer/test/DFSanSimpleCmpTest.cpp +++ /dev/null @@ -1,30 +0,0 @@ -// Simple test for a fuzzer. The fuzzer must find several narrow ranges. -#include -#include -#include -#include - -extern "C" void LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) { - if (Size < 14) return; - uint64_t x = 0; - int64_t y = 0; - int z = 0; - unsigned short a = 0; - memcpy(&x, Data, 8); - memcpy(&y, Data + Size - 8, 8); - memcpy(&z, Data + Size / 2, sizeof(z)); - memcpy(&a, Data + Size / 2 + 4, sizeof(a)); - - if (x > 1234567890 && - x < 1234567895 && - y >= 987654321 && - y <= 987654325 && - z < -10000 && - z >= -10005 && - z != -10003 && - a == 4242) { - fprintf(stderr, "BINGO; Found the target: size %zd (%zd, %zd, %d, %d), exiting.\n", - Size, x, y, z, a); - exit(1); - } -} diff --git a/lib/Fuzzer/test/MemcmpTest.cpp b/lib/Fuzzer/test/MemcmpTest.cpp new file mode 100644 index 00000000000..510a2439800 --- /dev/null +++ b/lib/Fuzzer/test/MemcmpTest.cpp @@ -0,0 +1,12 @@ +// Simple test for a fuzzer. The fuzzer must find a particular string. +#include +#include +#include +#include + +extern "C" void LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) { + if (Size >= 8 && memcmp(Data, "01234567", 8) == 0) { + fprintf(stderr, "BINGO\n"); + exit(1); + } +} diff --git a/lib/Fuzzer/test/SimpleCmpTest.cpp b/lib/Fuzzer/test/SimpleCmpTest.cpp new file mode 100644 index 00000000000..ee378146dae --- /dev/null +++ b/lib/Fuzzer/test/SimpleCmpTest.cpp @@ -0,0 +1,30 @@ +// Simple test for a fuzzer. The fuzzer must find several narrow ranges. +#include +#include +#include +#include + +extern "C" void LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) { + if (Size < 14) return; + uint64_t x = 0; + int64_t y = 0; + int z = 0; + unsigned short a = 0; + memcpy(&x, Data, 8); + memcpy(&y, Data + Size - 8, 8); + memcpy(&z, Data + Size / 2, sizeof(z)); + memcpy(&a, Data + Size / 2 + 4, sizeof(a)); + + if (x > 1234567890 && + x < 1234567895 && + y >= 987654321 && + y <= 987654325 && + z < -10000 && + z >= -10005 && + z != -10003 && + a == 4242) { + fprintf(stderr, "BINGO; Found the target: size %zd (%zd, %zd, %d, %d), exiting.\n", + Size, x, y, z, a); + exit(1); + } +} diff --git a/lib/Fuzzer/test/fuzzer-dfsan.test b/lib/Fuzzer/test/fuzzer-dfsan.test new file mode 100644 index 00000000000..79fbcbb8c80 --- /dev/null +++ b/lib/Fuzzer/test/fuzzer-dfsan.test @@ -0,0 +1,6 @@ +CHECK: BINGO + +RUN: not ./LLVMFuzzer-SimpleCmpTest-DFSan -use_traces=1 -seed=1 -runs=1000000 -timeout=5 2>&1 | FileCheck %s + +RUN: not ./LLVMFuzzer-MemcmpTest-DFSan -use_traces=1 -seed=1 -runs=100 -timeout=5 2>&1 | FileCheck %s + diff --git a/lib/Fuzzer/test/fuzzer.test b/lib/Fuzzer/test/fuzzer.test index b8e672f0fec..ffd2f2034fc 100644 --- a/lib/Fuzzer/test/fuzzer.test +++ b/lib/Fuzzer/test/fuzzer.test @@ -19,10 +19,7 @@ RUN: not ./LLVMFuzzer-FourIndependentBranchesTest -timeout=15 -seed=1 -use_full_ RUN: not ./LLVMFuzzer-CounterTest -use_counters=1 -max_len=6 -seed=1 -timeout=15 2>&1 | FileCheck %s -RUN: not ./LLVMFuzzer-DFSanSimpleCmpTest-DFSan -use_traces=1 -seed=1 -runs=1000000 -timeout=5 2>&1 | FileCheck %s -RUN: not ./LLVMFuzzer-DFSanSimpleCmpTest -use_traces=1 -seed=1 -runs=1000000 -timeout=5 2>&1 | FileCheck %s - -RUN: not ./LLVMFuzzer-DFSanMemcmpTest-DFSan -use_traces=1 -seed=1 -runs=100 -timeout=5 2>&1 | FileCheck %s +RUN: not ./LLVMFuzzer-SimpleCmpTest -use_traces=1 -seed=1 -runs=1000000 -timeout=5 2>&1 | FileCheck %s RUN: not ./LLVMFuzzer-CxxTokensTest -seed=1 -timeout=15 -tokens=%S/../cxx_fuzzer_tokens.txt 2>&1 | FileCheck %s