]> git.proxmox.com Git - rustc.git/blob - src/libcompiler_builtins/compiler-rt/test/fuzzer/SimpleThreadedTest.cpp
New upstream version 1.25.0+dfsg1
[rustc.git] / src / libcompiler_builtins / compiler-rt / test / fuzzer / SimpleThreadedTest.cpp
1 // This file is distributed under the University of Illinois Open Source
2 // License. See LICENSE.TXT for details.
3
4 // Threaded test for a fuzzer. The fuzzer should find "H"
5 #include <assert.h>
6 #include <cstddef>
7 #include <cstdint>
8 #include <cstring>
9 #include <iostream>
10 #include <ostream>
11 #include <thread>
12
13 extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
14 auto C = [&] {
15 if (Size >= 2 && Data[0] == 'H') {
16 std::cout << "BINGO; Found the target, exiting\n" << std::flush;
17 abort();
18 }
19 };
20 std::thread T[] = {std::thread(C), std::thread(C), std::thread(C),
21 std::thread(C), std::thread(C), std::thread(C)};
22 for (auto &X : T)
23 X.join();
24 return 0;
25 }
26