1# Tests the data flow tracer. 2REQUIRES: linux 3 4# Build the tracer and the test. 5RUN: %no_fuzzer_cpp_compiler -c -fno-sanitize=all -fsanitize=dataflow -fsanitize-coverage=trace-pc-guard,pc-table,func,trace-cmp %S/ThreeFunctionsTest.cpp -o %t-ThreeFunctionsTest.o 6RUN: %no_fuzzer_cpp_compiler -fno-sanitize=all -fsanitize=dataflow %t-ThreeFunctionsTest.o %S/../../lib/fuzzer/dataflow/DataFlow.cpp -o %t-ThreeFunctionsTestDF 7 8# Dump the function list. 9RUN: %t-ThreeFunctionsTestDF 2>&1 | FileCheck %s --check-prefix=FUNC_LIST 10FUNC_LIST-DAG: LLVMFuzzerTestOneInput 11FUNC_LIST-DAG: Func1 12FUNC_LIST-DAG: Func2 13 14# Prepare the inputs. 15RUN: rm -rf %t/IN 16RUN: mkdir -p %t/IN 17RUN: echo -n ABC > %t/IN/ABC 18RUN: echo -n FUABC > %t/IN/FUABC 19RUN: echo -n FUZZR > %t/IN/FUZZR 20RUN: echo -n FUZZM > %t/IN/FUZZM 21RUN: echo -n FUZZMU > %t/IN/FUZZMU 22 23# ABC: No data is used, the only used label is 4 (corresponds to the size) 24RUN:%t-ThreeFunctionsTestDF %t/IN/ABC | FileCheck %s --check-prefix=IN_ABC 25IN_ABC: LEN: 3 26IN_ABC: LABELS: 4 27IN_ABC: F{{[012]}} 4 28IN_ABC-NOT: F 29 30# FUABC: First 3 bytes are checked, Func1/Func2 are not called. 31RUN:%t-ThreeFunctionsTestDF %t/IN/FUABC | FileCheck %s --check-prefix=IN_FUABC 32IN_FUABC: LEN: 5 33IN_FUABC: LABELS: 34IN_FUABC: L{{.*}} 1 35IN_FUABC: L{{.*}} 2 36IN_FUABC: L{{.*}} 3 37IN_FUABC-NOT: L{{.*}} 4 38IN_FUABC: F{{[012]}} 39IN_FUABC-NOT: F 40 41# FUZZR: 5 bytes are used (4 in one function, 5-th in the other), Func2 is not called. 42RUN:%t-ThreeFunctionsTestDF %t/IN/FUZZR | FileCheck %s --check-prefix=IN_FUZZR 43IN_FUZZR: LEN: 5 44IN_FUZZR: LABELS: 45IN_FUZZR: L{{.*}} 1 46IN_FUZZR: L{{.*}} 2 47IN_FUZZR: L{{.*}} 3 48IN_FUZZR: L[[L0:[0-9]*]] 4 49IN_FUZZR-DAG: F{{[012]}} 5 50IN_FUZZR-DAG: F{{[012]}} [[L0]] 51IN_FUZZR-NOT: F 52 53# FUZZM: 5 bytes are used, both Func1 and Func2 are called, Func2 depends only on size (label 6). 54RUN:%t-ThreeFunctionsTestDF %t/IN/FUZZM | FileCheck %s --check-prefix=IN_FUZZM 55IN_FUZZM: LEN: 5 56IN_FUZZM: LABELS: 57IN_FUZZM: L{{.*}} 1 58IN_FUZZM: L{{.*}} 2 59IN_FUZZM: L{{.*}} 3 60IN_FUZZM: L{{.*}} 4 61IN_FUZZM-DAG: F{{[012]}} 6 62IN_FUZZM-DAG: F{{[012]}} 5 63IN_FUZZM-DAG: F 64 65# FUZZMU: 6 bytes are used, both Func1 and Func2 are called, Func2 depends on byte 6 and size (label 7) 66RUN:%t-ThreeFunctionsTestDF %t/IN/FUZZMU | FileCheck %s --check-prefix=IN_FUZZMU 67IN_FUZZMU: LEN: 6 68IN_FUZZMU: LABELS: 69IN_FUZZMU: L{{.*}} 1 70IN_FUZZMU: L{{.*}} 2 71IN_FUZZMU: L{{.*}} 3 72IN_FUZZMU: L{{.*}} 4 73IN_FUZZMU: L[[L2:[0-9]*]] 6 7 74IN_FUZZMU-DAG: F{{[012]}} 5 75IN_FUZZMU-DAG: F{{[012]}} [[L2]] 76IN_FUZZMU-DAG: F 77