1#!/bin/sh 2 3DFSAN_DIR=$(dirname "$0")/../ 4DFSAN_CUSTOM_TESTS=${DFSAN_DIR}/../../test/dfsan/custom.cc 5DFSAN_CUSTOM_WRAPPERS=${DFSAN_DIR}/dfsan_custom.cc 6DFSAN_ABI_LIST=${DFSAN_DIR}/done_abilist.txt 7 8DIFFOUT=$(mktemp -q /tmp/tmp.XXXXXXXXXX) 9ERRORLOG=$(mktemp -q /tmp/tmp.XXXXXXXXXX) 10DIFF_A=$(mktemp -q /tmp/tmp.XXXXXXXXXX) 11DIFF_B=$(mktemp -q /tmp/tmp.XXXXXXXXXX) 12 13on_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. 21trap on_exit EXIT 22grep -E "^fun:.*=custom" ${DFSAN_ABI_LIST} \ 23 | grep -v "dfsan_get_label\|__sanitizer_cov_trace" \ 24 | sed "s/^fun:\(.*\)=custom.*/\1/" | sort > $DIFF_A 25grep -E "__dfsw.*\(" ${DFSAN_CUSTOM_WRAPPERS} \ 26 | sed "s/.*__dfsw_\(.*\)(.*/\1/" | sort > $DIFF_B 27diff -u $DIFF_A $DIFF_B > ${DIFFOUT} 28if [ $? -ne 0 ] 29then 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} 33fi 34 35grep -E __dfsw_ ${DFSAN_CUSTOM_WRAPPERS} \ 36 | sed "s/.*__dfsw_\([^(]*\).*/\1/" | sort > $DIFF_A 37grep -E "^[[:space:]]*test_.*\(\);" ${DFSAN_CUSTOM_TESTS} \ 38 | sed "s/.*test_\(.*\)();/\1/" | sort > $DIFF_B 39diff -u $DIFF_A $DIFF_B > ${DIFFOUT} 40if [ $? -ne 0 ] 41then 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} 45fi 46 47if [ -s ${ERRORLOG} ] 48then 49 cat ${ERRORLOG} 50 exit 1 51fi 52 53