-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathscc.test-04.sh
92 lines (84 loc) · 2.19 KB
/
scc.test-04.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#!/bin/ksh
#
# @(#)$Id: scc.test-04.sh,v 8.1 2022/04/07 00:40:18 jleffler Exp $
#
# Test driver for SCC: -S C++14 and binary numbers, numeric punctuation
T_SCC=./scc # Version of SCC under test
[ -x "$T_SCC" ] || ${MAKE:-make} "$T_SCC" || exit 1
usage()
{
echo "Usage: $(basename $0 .sh) [-gq]" >&2
exit 1
}
gflag=no
qflag=no
while getopts gq opt
do
case "$opt" in
(g) gflag=yes;;
(q) qflag=yes;;
(*) usage;;
esac
done
shift $((OPTIND - 1))
[ "$#" = 0 ] || usage
tmp=${TMPDIR:-/tmp}/scc-test
trap "rm -f $tmp.?; exit 1" 0 1 2 3 13 15
OUTPUT_DIR=Output
TEST_BINARY=scc-test.binary
TEST_NUMPUNCT=scc-test.numpunct
BOGUS_BINARY=scc-bogus.binary
TEST_HEXFLOAT=scc-test.hexfloat
{
fail=0
pass=0
# Don't quote file name or options - spaces need trimming
for base in $TEST_BINARY $TEST_NUMPUNCT $BOGUS_BINARY
do
for standard in c c++11 c++14 c++17
do
test=0
"$T_SCC" -n -S $standard "${base}.cpp" > "$tmp.1" 2> "$tmp.2"
EXPOUT="$OUTPUT_DIR/$base-$standard.1"
EXPERR="$OUTPUT_DIR/$base-$standard.2"
if [ "$gflag" = yes ]
then cp "$tmp.1" "$EXPOUT"
elif cmp -s "$tmp.1" "$EXPOUT"
then : OK
else
echo "Differences: $base.cpp ($standard) - standard output (wanted vs actual)"
diff "$EXPOUT" "$tmp.1"
test=1
fi
if [ "$gflag" = yes ]
then cp "$tmp.2" "$EXPERR"
elif cmp -s "$tmp.2" "$EXPERR"
then : OK
else
echo "Differences: $base.cpp ($standard) - standard error (wanted vs actual)"
diff "$EXPERR" "$tmp.2"
test=1
fi
if [ "$gflag" = yes ]
then
echo "== GENERATED == ($standard: $base.c)"
echo " ($EXPOUT $EXPERR)"
: $((pass++))
elif [ $test = 0 ]
then
echo "== PASS == ($standard: $base.cpp)"
: $((pass++))
else
echo "!! FAIL !! ($standard: $base.cpp)"
: $((fail++))
fi
rm -f "$tmp".?
done
done
if [ $fail = 0 ]
then echo "== PASS == ($pass tests OK)"
else echo "!! FAIL !! ($pass tests OK, $fail tests failed)"
fi
}
rm -f $tmp.?
trap 0