1// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
2// See https://llvm.org/LICENSE.txt for license information.
3// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
4
5// Test that fuzzer we can reload artifacts with any bytes inside.
6#include <algorithm>
7#include <cstdint>
8#include <cstdlib>
9#include <numeric>
10#include <set>
11
12extern "C" size_t LLVMFuzzerCustomMutator(uint8_t *Data, size_t Size,
13 size_t MaxSize, unsigned int Seed) {
14 std::srand(seed: Seed);
15 std::generate(first: Data, last: Data + MaxSize, gen: std::rand);
16 return MaxSize;
17}
18
19extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
20 if (Size > 5000 && std::set<uint8_t>(Data, Data + Size).size() > 255 &&
21 (uint8_t)std::accumulate(first: Data, last: Data + Size, init: uint8_t(Size)) == 0)
22 abort();
23 return 0;
24}
25

source code of compiler-rt/test/fuzzer/ReloadTest.cpp