-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathscc.test-07.sh
94 lines (85 loc) · 2.07 KB
/
scc.test-07.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
93
94
#!/bin/ksh
#
# @(#)$Id: scc.test-07.sh,v 8.1 2022/04/07 00:40:18 jleffler Exp $
#
# Test driver for SCC: Handling of Unicode characters and strings
T_SCC=./scc # Version of SCC under test
RCSKWCMP="${RCSKWCMP:-./rcskwcmp}"
RCSKWREDUCE="${RCSKWREDUCE:-./rcskwreduce}"
export RCSKWCMP RCSKWREDUCE
[ -x "$T_SCC" ] || ${MAKE:-make} "$T_SCC" || exit 1
usage()
{
echo "Usage: $(basename $0 .sh) [-gq]" >&2
exit 1
}
# -g Generate result files
# -q Quiet mode
qflag=no
gflag=no
while getopts gq opt
do
case "$opt" in
(q) qflag=yes;;
(g) gflag=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
EXAMPLE_C=scc-test.rawstring
{
suffix=".cpp"
fail=0
pass=0
# Don't quote file name or options - spaces need trimming
for standard in c11 c++11 c++14 c++17
do
base=$EXAMPLE_C
test=0
"$T_SCC" -n -S "$standard" "${base}${suffix}" > "$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 $RCSKWCMP "$tmp.1" "$EXPOUT"
then : OK
else
echo "Differences: $base-$standard.c - standard output (wanted vs actual)"
diff "$EXPOUT" "$tmp.1"
test=1
fi
if [ "$gflag" = yes ]
then cp "$tmp.2" "$EXPERR"
elif $RCSKWCMP "$tmp.2" "$EXPERR"
then : OK
else
echo "Differences: $base-$standard.c - 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.c)"
: $((pass++))
else
echo "!! FAIL !! ($standard: $base.c)"
: $((fail++))
fi
rm -f "$tmp".?
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