xref: /llvm-project/compiler-rt/test/fuzzer/focus-function.test (revision 3b79468c07c772750ec5f022ea1e0379ac48282f)
1# Tests -focus_function
2#
3# TODO: don't require linux.
4# Requires full shell support for the `for` loop syntax.
5# REQUIRES: shell, linux
6UNSUPPORTED: target=aarch64{{.*}}
7
8RUN: %cpp_compiler %S/OnlySomeBytesTest.cpp -o %t-exe
9
10RUN: %t-exe -runs=100 2>&1 | FileCheck %s --check-prefix=FOCUS_NONE
11FOCUS_NONE-NOT: INFO: Focus function is set to
12FOCUS_NONE-NOT: INFO: {{.*}} inputs touch the focus function
13
14RUN: not %t-exe -runs=100 -focus_function=WRONG 2>&1 | FileCheck %s --check-prefix=FOCUS_WRONG
15FOCUS_WRONG-NOT: INFO: Focus function is set to
16FOCUS_WRONG: ERROR: Failed to set focus function
17
18RUN: %t-exe -runs=100 -focus_function=f0 2>&1 | FileCheck %s --check-prefix=FOCUS_F0
19FOCUS_F0: INFO: Focus function is set to 'f0'
20FOCUS_F0: INFO: 0/1 inputs touch the focus function
21
22RUN: rm -rf %t-corpus
23RUN: mkdir %t-corpus
24# ABC triggers the focus function, others don't.
25RUN: echo ABC$(for((i=0;i<2048;i++)); do echo -n x; done) > %t-corpus/ABC
26RUN: echo AXY$(for((i=0;i<2048;i++)); do echo -n x; done) > %t-corpus/AXY
27RUN: echo ABX$(for((i=0;i<2048;i++)); do echo -n x; done) > %t-corpus/ABX
28
29RUN: %t-exe -runs=10000 -focus_function=f0 %t-corpus 2>&1 | FileCheck %s --check-prefix=CORPUS_1_3
30CORPUS_1_3: INFO: 1/3 inputs touch the focus function
31CORPUS_1_3: DONE {{.*}} focus:
32