From ff2ba393a56d9d99dcb76ceada542233db28af9a Mon Sep 17 00:00:00 2001 From: dim Date: Wed, 6 Jan 2016 20:01:02 +0000 Subject: Vendor import of llvm trunk r256945: https://llvm.org/svn/llvm-project/llvm/trunk@256945 --- lib/Fuzzer/test/ThreadedTest.cpp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 lib/Fuzzer/test/ThreadedTest.cpp (limited to 'lib/Fuzzer/test/ThreadedTest.cpp') diff --git a/lib/Fuzzer/test/ThreadedTest.cpp b/lib/Fuzzer/test/ThreadedTest.cpp new file mode 100644 index 0000000..7aa114a --- /dev/null +++ b/lib/Fuzzer/test/ThreadedTest.cpp @@ -0,0 +1,23 @@ +// Threaded test for a fuzzer. The fuzzer should not crash. +#include +#include +#include +#include +#include + +extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) { + if (Size < 8) return 0; + assert(Data); + auto C = [&] { + size_t Res = 0; + for (size_t i = 0; i < Size / 2; i++) + Res += memcmp(Data, Data + Size / 2, 4); + return Res; + }; + std::thread T[] = {std::thread(C), std::thread(C), std::thread(C), + std::thread(C), std::thread(C), std::thread(C)}; + for (auto &X : T) + X.join(); + return 0; +} + -- cgit v1.1