2020-02-26 07:22:14 +08:00
|
|
|
#/usr/bin/env bash
|
2018-09-01 01:26:19 +08:00
|
|
|
# Compile a source file with '-funparse-with-symbols' and verify
|
|
|
|
# we get the right symbols in the output, i.e. the output should be
|
|
|
|
# the same as the input, except for the copyright comment.
|
|
|
|
# Change the compiler by setting the F18 environment variable.
|
2019-07-13 03:37:16 +08:00
|
|
|
|
2018-09-01 01:26:19 +08:00
|
|
|
srcdir=$(dirname $0)
|
2019-07-13 03:37:16 +08:00
|
|
|
source $srcdir/common.sh
|
|
|
|
|
2020-02-26 07:22:14 +08:00
|
|
|
FileCheck=internal_check
|
2018-09-01 01:26:19 +08:00
|
|
|
|
|
|
|
function internal_check() {
|
|
|
|
r=true
|
|
|
|
linput="$1"
|
|
|
|
lstdin=`mktemp`
|
|
|
|
lcheck=`mktemp`
|
|
|
|
cat - > ${lstdin}
|
|
|
|
egrep '^[[:space:]]*![[:space:]]*CHECK:[[:space:]]*' ${linput} | sed -e 's/^[[:space:]]*![[:space:]]*CHECK:[[:space:]]*//' > ${lcheck} 2>/dev/null
|
|
|
|
while read p; do
|
|
|
|
if egrep "${p}" ${lstdin} >/dev/null 2>&1; then
|
|
|
|
true
|
|
|
|
else
|
|
|
|
echo "Not found: ${p}" >&2
|
|
|
|
r=false
|
|
|
|
fi
|
|
|
|
done < ${lcheck}
|
|
|
|
egrep '^[[:space:]]*![[:space:]]*CHECK-NOT:[[:space:]]*' ${linput} | sed -e 's/^[[:space:]]*![[:space:]]*CHECK-NOT:[[:space:]]*//' > ${lcheck} 2>/dev/null
|
|
|
|
while read p; do
|
2018-10-03 07:42:15 +08:00
|
|
|
if egrep "${p}" ${lstdin} >/dev/null 2>&1; then
|
2018-09-01 01:26:19 +08:00
|
|
|
echo "Found: ${p}" >&2
|
|
|
|
r=false
|
|
|
|
fi
|
|
|
|
done < ${lcheck}
|
2019-09-06 01:05:45 +08:00
|
|
|
egrep '^[[:space:]]*![[:space:]]*CHECK-ONCE:[[:space:]]*' ${linput} | sed -e 's/^[[:space:]]*![[:space:]]*CHECK-ONCE:[[:space:]]*//' > ${lcheck} 2>/dev/null
|
|
|
|
while read p; do
|
|
|
|
count=$(egrep -o -e "${p}" ${lstdin} | wc -l)
|
|
|
|
if [ ${count} -eq 0 ]; then
|
|
|
|
echo "Not found: ${p}" >&2
|
|
|
|
r=false
|
|
|
|
fi
|
|
|
|
if [ ${count} -gt 1 ]; then
|
|
|
|
echo "Found duplicates: ${p}" >&2
|
|
|
|
r=false
|
|
|
|
fi
|
|
|
|
done < ${lcheck}
|
2018-09-01 01:26:19 +08:00
|
|
|
rm -f ${lstdin} ${lcheck}
|
|
|
|
${r}
|
|
|
|
}
|
|
|
|
|
2018-09-07 00:55:29 +08:00
|
|
|
gr=0
|
2020-03-06 19:21:36 +08:00
|
|
|
for input in $1; do
|
2019-10-29 01:34:47 +08:00
|
|
|
[[ ! -f $input ]] && die "File not found: $input"
|
2020-03-06 19:21:36 +08:00
|
|
|
CMD=$(cat ${input} | egrep '^[[:space:]]*![[:space:]]*EXEC:[[:space:]]*' | sed -e 's/^[[:space:]]*![[:space:]]*EXEC:[[:space:]]*//')
|
2018-09-07 00:55:29 +08:00
|
|
|
CMD=$(echo ${CMD} | sed -e "s:%s:${input}:g")
|
2019-08-27 06:16:57 +08:00
|
|
|
if egrep -q -e '%t' <<< ${CMD} ; then
|
2019-09-19 04:17:48 +08:00
|
|
|
CMD=$(echo ${CMD} | sed -e "s:%t:$temp/t:g")
|
2019-08-27 06:16:57 +08:00
|
|
|
fi
|
2019-07-13 03:37:16 +08:00
|
|
|
if $(eval $CMD); then
|
2018-09-07 00:55:29 +08:00
|
|
|
echo "PASS ${input}"
|
|
|
|
else
|
|
|
|
echo "FAIL ${input}"
|
|
|
|
gr=1
|
|
|
|
fi
|
2018-09-01 01:26:19 +08:00
|
|
|
done
|
2018-09-07 00:55:29 +08:00
|
|
|
exit $gr
|