blob: 9a80cb9c6ffd694b74d5ef6c4d27f72abfa0a40d [file] [log] [blame]
Ed Mastee4320f52014-10-08 18:35:16 +00001#!/bin/sh
Lorenzo Martignoni085bf662013-11-27 11:50:44 +00002
3DFSAN_DIR=$(dirname "$0")/../
Lorenzo Martignoni60ebffc2014-10-08 10:01:42 +00004DFSAN_CUSTOM_TESTS=${DFSAN_DIR}/../../test/dfsan/custom.cc
Lorenzo Martignoni085bf662013-11-27 11:50:44 +00005DFSAN_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)
Ed Mastee4320f52014-10-08 18:35:16 +000010DIFF_A=$(mktemp -q /tmp/tmp.XXXXXXXXXX)
11DIFF_B=$(mktemp -q /tmp/tmp.XXXXXXXXXX)
Lorenzo Martignoni085bf662013-11-27 11:50:44 +000012
13on_exit() {
14 rm -f ${DIFFOUT} 2> /dev/null
15 rm -f ${ERRORLOG} 2> /dev/null
Ed Mastee4320f52014-10-08 18:35:16 +000016 rm -f ${DIFF_A} 2> /dev/null
17 rm -f ${DIFF_B} 2> /dev/null
Lorenzo Martignoni085bf662013-11-27 11:50:44 +000018}
19
Kostya Serebryanya86398e2015-05-06 22:41:34 +000020# Ignore __sanitizer_cov_trace* because they are implemented elsewhere.
Lorenzo Martignoni085bf662013-11-27 11:50:44 +000021trap on_exit EXIT
Kostya Serebryanya86398e2015-05-06 22:41:34 +000022grep -E "^fun:.*=custom" ${DFSAN_ABI_LIST} \
23 | grep -v "dfsan_get_label\|__sanitizer_cov_trace" \
Ed Mastee4320f52014-10-08 18:35:16 +000024 | sed "s/^fun:\(.*\)=custom.*/\1/" | sort > $DIFF_A
25grep -E "__dfsw.*\(" ${DFSAN_CUSTOM_WRAPPERS} \
Kostya Serebryanyd74d04a2018-06-01 21:59:25 +000026 | grep -v "__sanitizer_cov_trace" \
Ed Mastee4320f52014-10-08 18:35:16 +000027 | sed "s/.*__dfsw_\(.*\)(.*/\1/" | sort > $DIFF_B
28diff -u $DIFF_A $DIFF_B > ${DIFFOUT}
Lorenzo Martignoni085bf662013-11-27 11:50:44 +000029if [ $? -ne 0 ]
30then
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}
34fi
35
Ed Mastee4320f52014-10-08 18:35:16 +000036grep -E __dfsw_ ${DFSAN_CUSTOM_WRAPPERS} \
Kostya Serebryanyd74d04a2018-06-01 21:59:25 +000037 | grep -v "__sanitizer_cov_trace" \
Ed Mastee4320f52014-10-08 18:35:16 +000038 | sed "s/.*__dfsw_\([^(]*\).*/\1/" | sort > $DIFF_A
Dimitry Andric66749022015-04-12 10:54:46 +000039grep -E "^[[:space:]]*test_.*\(\);" ${DFSAN_CUSTOM_TESTS} \
Ed Mastee4320f52014-10-08 18:35:16 +000040 | sed "s/.*test_\(.*\)();/\1/" | sort > $DIFF_B
41diff -u $DIFF_A $DIFF_B > ${DIFFOUT}
Lorenzo Martignoni085bf662013-11-27 11:50:44 +000042if [ $? -ne 0 ]
43then
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}
47fi
48
Ed Mastee4320f52014-10-08 18:35:16 +000049if [ -s ${ERRORLOG} ]
Lorenzo Martignoni085bf662013-11-27 11:50:44 +000050then
51 cat ${ERRORLOG}
52 exit 1
53fi
54