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
5 // Test for a fuzzer. The fuzzer must find the string
7 // We use it as a test for each of CrossOver functionalities
8 // by passing the following sets of two inputs to it:
9 // {ABCDE00000, ZZZZZFGHIJ}
10 // {ABCDEHIJ, ZFG} to specifically test InsertPartOf
11 // {ABCDE00HIJ, ZFG} to specifically test CopyPartOf
20 static volatile int Sink
;
21 static volatile int *NullPtr
;
23 // A modified jenkins_one_at_a_time_hash initialized by non-zero,
24 // so that simple_hash(0) != 0. See also
25 // https://en.wikipedia.org/wiki/Jenkins_hash_function
26 static uint32_t simple_hash(const uint8_t *Data
, size_t Size
) {
27 uint32_t Hash
= 0x12039854;
28 for (uint32_t i
= 0; i
< Size
; i
++) {
39 // Don't leave the string in the binary, so that fuzzer don't cheat;
40 // const char *ABC = "ABCDEFGHIJ";
41 // static uint32_t ExpectedHash = simple_hash((const uint8_t *)ABC, 10);
42 static const uint32_t ExpectedHash
= 0xe1677acb;
44 extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data
, size_t Size
) {
45 // fprintf(stderr, "ExpectedHash: %x\n", ExpectedHash);
46 if (Size
== 10 && ExpectedHash
== simple_hash(Data
, Size
))