Home | History | Annotate | Download | only in scripts
      1 #!/bin/sh
      2 
      3 DFSAN_DIR=$(dirname "$0")/../
      4 DFSAN_CUSTOM_TESTS=${DFSAN_DIR}/../../test/dfsan/custom.cc
      5 DFSAN_CUSTOM_WRAPPERS=${DFSAN_DIR}/dfsan_custom.cc
      6 DFSAN_ABI_LIST=${DFSAN_DIR}/done_abilist.txt
      7 
      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)
     12 
     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
     18 }
     19 
     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\|__sanitizer_cov_trace" \
     24   | sed "s/^fun:\(.*\)=custom.*/\1/" | sort > $DIFF_A
     25 grep -E "__dfsw.*\(" ${DFSAN_CUSTOM_WRAPPERS} \
     26   | sed "s/.*__dfsw_\(.*\)(.*/\1/" | sort > $DIFF_B
     27 diff -u $DIFF_A $DIFF_B > ${DIFFOUT}
     28 if [ $? -ne 0 ]
     29 then
     30   echo -n "The following differences between the ABI list and ">> ${ERRORLOG}
     31   echo "the implemented custom wrappers have been found:" >> ${ERRORLOG}
     32   cat ${DIFFOUT} >> ${ERRORLOG}
     33 fi
     34 
     35 grep -E __dfsw_ ${DFSAN_CUSTOM_WRAPPERS} \
     36   | sed "s/.*__dfsw_\([^(]*\).*/\1/" | sort > $DIFF_A
     37 grep -E "^[[:space:]]*test_.*\(\);" ${DFSAN_CUSTOM_TESTS} \
     38   | sed "s/.*test_\(.*\)();/\1/" | sort > $DIFF_B
     39 diff -u $DIFF_A $DIFF_B > ${DIFFOUT}
     40 if [ $? -ne 0 ]
     41 then
     42   echo -n "The following differences between the implemented " >> ${ERRORLOG}
     43   echo "custom wrappers and the tests have been found:" >> ${ERRORLOG}
     44   cat ${DIFFOUT} >> ${ERRORLOG}
     45 fi
     46 
     47 if [ -s ${ERRORLOG} ]
     48 then
     49   cat ${ERRORLOG}
     50   exit 1
     51 fi
     52 
     53