55 lines · bash
1#!/bin/sh2 3DFSAN_DIR=$(dirname "$0")/../4DFSAN_CUSTOM_TESTS=${DFSAN_DIR}/../../test/dfsan/custom.cpp5DFSAN_CUSTOM_WRAPPERS=${DFSAN_DIR}/dfsan_custom.cpp6DFSAN_ABI_LIST=${DFSAN_DIR}/done_abilist.txt7 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/null15 rm -f ${ERRORLOG} 2> /dev/null16 rm -f ${DIFF_A} 2> /dev/null17 rm -f ${DIFF_B} 2> /dev/null18}19 20# Ignore __sanitizer_cov_trace* because they are implemented elsewhere.21trap on_exit EXIT22grep -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_A25grep -E "__dfsw.*\(" ${DFSAN_CUSTOM_WRAPPERS} \26 | grep -v "__sanitizer_cov_trace" \27 | sed "s/.*__dfsw_\(.*\)(.*/\1/" | sort | uniq > $DIFF_B28diff -u $DIFF_A $DIFF_B > ${DIFFOUT}29if [ $? -ne 0 ]30then31 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}34fi35 36grep -E __dfsw_ ${DFSAN_CUSTOM_WRAPPERS} \37 | grep -v "__sanitizer_cov_trace" \38 | sed "s/.*__dfsw_\([^(]*\).*/\1/" | sort | uniq > $DIFF_A39grep -E "^[[:space:]]*test_.*\(\);" ${DFSAN_CUSTOM_TESTS} \40 | sed "s/.*test_\(.*\)();/\1/" | sort > $DIFF_B41diff -u $DIFF_A $DIFF_B > ${DIFFOUT}42if [ $? -ne 0 ]43then44 echo -n "The following differences between the implemented " >> ${ERRORLOG}45 echo "custom wrappers and the tests have been found:" >> ${ERRORLOG}46 cat ${DIFFOUT} >> ${ERRORLOG}47fi48 49if [ -s ${ERRORLOG} ]50then51 cat ${ERRORLOG}52 exit 153fi54 55