xref: /aosp_15_r20/external/AFLplusplus/test/test-fpExtra.sh (revision 08b48e0b10e97b33e7b60c5b6e2243bd915777f2)
1#!/bin/sh
2
3. ./test-pre.sh
4
5test -e ../afl-clang-fast -a -e ../split-switches-pass.so && {
6  $ECHO "$GREY[*] llvm_mode laf-intel/compcov testing splitting floating point types with Nan, infinity, minusZero"
7  for testcase in ./test-fp_minusZerocases.c ./test-fp_Infcases.c ./test-fp_NaNcases.c; do
8  #for testcase in ./test-fp_cases.c ./test-fp_Infcases.c ./test-fp_NaNcases.c ./test-fp_minusZerocases.c ; do
9    for I in float double "long double"; do
10    #for I in double; do
11      for BITS in 64 32 16 8; do
12      #for BITS in 64; do
13        bin="$testcase-split-$I-$BITS.compcov"
14#AFL_DONT_OPTIMIZE=1 AFL_LLVM_INSTRUMENT=AFL AFL_DEBUG=1 AFL_LLVM_LAF_SPLIT_COMPARES_BITW=$BITS AFL_LLVM_LAF_SPLIT_COMPARES=1 AFL_LLVM_LAF_SPLIT_FLOATS=1 ../afl-clang-fast -DFLOAT_TYPE="$I" -S "$testcase"
15#AFL_DONT_OPTIMIZE=1 AFL_LLVM_INSTRUMENT=AFL AFL_DEBUG=1 AFL_LLVM_LAF_SPLIT_COMPARES_BITW=$BITS AFL_LLVM_LAF_SPLIT_COMPARES=1 AFL_LLVM_LAF_SPLIT_FLOATS=1 ../afl-clang-fast -DFLOAT_TYPE="$I" -S -emit-llvm "$testcase"
16AFL_DONT_OPTIMIZE=1 AFL_LLVM_INSTRUMENT=AFL AFL_DEBUG=1 AFL_LLVM_LAF_SPLIT_COMPARES_BITW=$BITS AFL_LLVM_LAF_SPLIT_COMPARES=1 AFL_LLVM_LAF_SPLIT_FLOATS=1 ../afl-clang-fast -DFLOAT_TYPE="$I" -o "$bin" "$testcase" > test.out 2>&1;
17        if ! test -e "$bin"; then
18            cat test.out
19            $ECHO "$RED[!] llvm_mode laf-intel/compcov float splitting failed! ($testcase with type $I split to $BITS)!";
20            CODE=1
21            break
22        fi
23        if ! "$bin"; then
24            $ECHO "$RED[!] llvm_mode laf-intel/compcov float splitting resulted in miscompilation (type $I split to $BITS)!";
25            CODE=1
26            break
27        fi
28        rm -f "$bin" test.out || true
29      done
30    done
31  done
32  rm -f test-fp_cases*.compcov test.out
33
34} || {
35  $ECHO "$YELLOW[-] llvm_mode not compiled, cannot test"
36  INCOMPLETE=1
37}
38
39. ./test-post.sh
40