Home | History | Annotate | Download | only in scripts
      1 #!/usr/bin/env bash
      2 
      3 DFSAN_DIR=$(dirname "$0")/../
      4 DFSAN_CUSTOM_TESTS=${DFSAN_DIR}/../../test/dfsan/custom.c
      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 
     11 on_exit() {
     12   rm -f ${DIFFOUT} 2> /dev/null
     13   rm -f ${ERRORLOG} 2> /dev/null
     14 }
     15 
     16 trap on_exit EXIT
     17 
     18 diff -u \
     19   <(grep -E "^fun:.*=custom" ${DFSAN_ABI_LIST} | grep -v "dfsan_get_label" \
     20     | sed "s/^fun:\(.*\)=custom.*/\1/" | sort ) \
     21   <(grep -E "__dfsw.*\(" ${DFSAN_CUSTOM_WRAPPERS} \
     22     | sed "s/.*__dfsw_\(.*\)(.*/\1/" \
     23     | sort) > ${DIFFOUT}
     24 if [ $? -ne 0 ]
     25 then
     26   echo -n "The following differences between the ABI list and ">> ${ERRORLOG}
     27   echo "the implemented custom wrappers have been found:" >> ${ERRORLOG}
     28   cat ${DIFFOUT} >> ${ERRORLOG}
     29 fi
     30 
     31 diff -u \
     32   <(grep -E __dfsw_ ${DFSAN_CUSTOM_WRAPPERS} \
     33     | sed "s/.*__dfsw_\([^(]*\).*/\1/" \
     34     | sort) \
     35   <(grep -E "^\\s*test_.*\(\);" ${DFSAN_CUSTOM_TESTS} \
     36     | sed "s/.*test_\(.*\)();/\1/" \
     37     | sort) > ${DIFFOUT}
     38 if [ $? -ne 0 ]
     39 then
     40   echo -n "The following differences between the implemented " >> ${ERRORLOG}
     41   echo "custom wrappers and the tests have been found:" >> ${ERRORLOG}
     42   cat ${DIFFOUT} >> ${ERRORLOG}
     43 fi
     44 
     45 if [[ -s ${ERRORLOG} ]]
     46 then
     47   cat ${ERRORLOG}
     48   exit 1
     49 fi
     50 
     51