Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / compiler-rt / lib / dfsan / scripts / check_custom_wrappers.sh
blob5f7160eb14784e008921b68ca3b18ab8bd03cc78
1 #!/bin/sh
3 DFSAN_DIR=$(dirname "$0")/../
4 DFSAN_CUSTOM_TESTS=${DFSAN_DIR}/../../test/dfsan/custom.cpp
5 DFSAN_CUSTOM_WRAPPERS=${DFSAN_DIR}/dfsan_custom.cpp
6 DFSAN_ABI_LIST=${DFSAN_DIR}/done_abilist.txt
8 DIFFOUT=$(mktemp -q /tmp/tmp.XXXXXXXXXX)
9 ERRORLOG=$(mktemp -q /tmp/tmp.XXXXXXXXXX)
10 DIFF_A=$(mktemp -q /tmp/tmp.XXXXXXXXXX)
11 DIFF_B=$(mktemp -q /tmp/tmp.XXXXXXXXXX)
13 on_exit() {
14 rm -f ${DIFFOUT} 2> /dev/null
15 rm -f ${ERRORLOG} 2> /dev/null
16 rm -f ${DIFF_A} 2> /dev/null
17 rm -f ${DIFF_B} 2> /dev/null
20 # Ignore __sanitizer_cov_trace* because they are implemented elsewhere.
21 trap on_exit EXIT
22 grep -E "^fun:.*=custom" ${DFSAN_ABI_LIST} \
23 | grep -v "dfsan_get_label\|dfsan_get_origin\|__sanitizer_cov_trace" \
24 | sed "s/^fun:\(.*\)=custom.*/\1/" | sort > $DIFF_A
25 grep -E "__dfsw.*\(" ${DFSAN_CUSTOM_WRAPPERS} \
26 | grep -v "__sanitizer_cov_trace" \
27 | sed "s/.*__dfsw_\(.*\)(.*/\1/" | sort | uniq > $DIFF_B
28 diff -u $DIFF_A $DIFF_B > ${DIFFOUT}
29 if [ $? -ne 0 ]
30 then
31 echo -n "The following differences between the ABI list and ">> ${ERRORLOG}
32 echo "the implemented custom wrappers have been found:" >> ${ERRORLOG}
33 cat ${DIFFOUT} >> ${ERRORLOG}
36 grep -E __dfsw_ ${DFSAN_CUSTOM_WRAPPERS} \
37 | grep -v "__sanitizer_cov_trace" \
38 | sed "s/.*__dfsw_\([^(]*\).*/\1/" | sort | uniq > $DIFF_A
39 grep -E "^[[:space:]]*test_.*\(\);" ${DFSAN_CUSTOM_TESTS} \
40 | sed "s/.*test_\(.*\)();/\1/" | sort > $DIFF_B
41 diff -u $DIFF_A $DIFF_B > ${DIFFOUT}
42 if [ $? -ne 0 ]
43 then
44 echo -n "The following differences between the implemented " >> ${ERRORLOG}
45 echo "custom wrappers and the tests have been found:" >> ${ERRORLOG}
46 cat ${DIFFOUT} >> ${ERRORLOG}
49 if [ -s ${ERRORLOG} ]
50 then
51 cat ${ERRORLOG}
52 exit 1