1*08b48e0bSAndroid Build Coastguard Worker#!/bin/sh 2*08b48e0bSAndroid Build Coastguard Worker 3*08b48e0bSAndroid Build Coastguard Worker. ./test-pre.sh 4*08b48e0bSAndroid Build Coastguard Worker 5*08b48e0bSAndroid Build Coastguard Workertest -e ../afl-clang-fast -a -e ../split-switches-pass.so && { 6*08b48e0bSAndroid Build Coastguard Worker $ECHO "$GREY[*] llvm_mode laf-intel/compcov testing splitting floating point types with Nan, infinity, minusZero" 7*08b48e0bSAndroid Build Coastguard Worker for testcase in ./test-fp_minusZerocases.c ./test-fp_Infcases.c ./test-fp_NaNcases.c; do 8*08b48e0bSAndroid Build Coastguard Worker #for testcase in ./test-fp_cases.c ./test-fp_Infcases.c ./test-fp_NaNcases.c ./test-fp_minusZerocases.c ; do 9*08b48e0bSAndroid Build Coastguard Worker for I in float double "long double"; do 10*08b48e0bSAndroid Build Coastguard Worker #for I in double; do 11*08b48e0bSAndroid Build Coastguard Worker for BITS in 64 32 16 8; do 12*08b48e0bSAndroid Build Coastguard Worker #for BITS in 64; do 13*08b48e0bSAndroid Build Coastguard Worker bin="$testcase-split-$I-$BITS.compcov" 14*08b48e0bSAndroid Build Coastguard Worker#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*08b48e0bSAndroid Build Coastguard Worker#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" 16*08b48e0bSAndroid Build Coastguard WorkerAFL_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*08b48e0bSAndroid Build Coastguard Worker if ! test -e "$bin"; then 18*08b48e0bSAndroid Build Coastguard Worker cat test.out 19*08b48e0bSAndroid Build Coastguard Worker $ECHO "$RED[!] llvm_mode laf-intel/compcov float splitting failed! ($testcase with type $I split to $BITS)!"; 20*08b48e0bSAndroid Build Coastguard Worker CODE=1 21*08b48e0bSAndroid Build Coastguard Worker break 22*08b48e0bSAndroid Build Coastguard Worker fi 23*08b48e0bSAndroid Build Coastguard Worker if ! "$bin"; then 24*08b48e0bSAndroid Build Coastguard Worker $ECHO "$RED[!] llvm_mode laf-intel/compcov float splitting resulted in miscompilation (type $I split to $BITS)!"; 25*08b48e0bSAndroid Build Coastguard Worker CODE=1 26*08b48e0bSAndroid Build Coastguard Worker break 27*08b48e0bSAndroid Build Coastguard Worker fi 28*08b48e0bSAndroid Build Coastguard Worker rm -f "$bin" test.out || true 29*08b48e0bSAndroid Build Coastguard Worker done 30*08b48e0bSAndroid Build Coastguard Worker done 31*08b48e0bSAndroid Build Coastguard Worker done 32*08b48e0bSAndroid Build Coastguard Worker rm -f test-fp_cases*.compcov test.out 33*08b48e0bSAndroid Build Coastguard Worker 34*08b48e0bSAndroid Build Coastguard Worker} || { 35*08b48e0bSAndroid Build Coastguard Worker $ECHO "$YELLOW[-] llvm_mode not compiled, cannot test" 36*08b48e0bSAndroid Build Coastguard Worker INCOMPLETE=1 37*08b48e0bSAndroid Build Coastguard Worker} 38*08b48e0bSAndroid Build Coastguard Worker 39*08b48e0bSAndroid Build Coastguard Worker. ./test-post.sh 40