blob: b446f47f2b2f71f4cc710e308e9b89defb683384 (
plain)
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
|
#!/bin/sh
# Check GNU m4 against examples from the manual source.
# Copyright (C) 1992, 2006, 2007 Free Software Foundation, Inc.
# Sanity check what we are testing
m4 --version
# Clean up temp files on exit
pwd=`pwd`
tmp=m4-tmp.$$
trap 'stat=$?; cd "$pwd"; rm -rf $tmp && exit $stat' 0
trap '(exit $?); exit $?' 1 2 13 15
# Create scratch dir
framework_failure=0
mkdir $tmp || framework_failure=1
if test $framework_failure = 1; then
echo "$0: failure in testing framework" 1>&2
(exit 1); exit 1
fi
out=$tmp/m4-out
err=$tmp/m4-err
xout=$tmp/m4-xout
xerr=$tmp/m4-xerr
failed=
skipped=
strip_needed=false
# Find out how the executable prints argv[0]
m4=`m4 --help | sed -e 's/Usage: \(.*\) \[OPTION.*/\1/' \
-e 's/\\\\/\\\\\\\\/g' -e 1q`
# Find out if we should strip \r in the output
m4 --version > $out
m4 --version | tr -d '\015' > $xout
if cmp -s $out $xout; then
:
else
echo "Ignoring carriage returns"
strip_needed=:
fi
# Find out where the examples live.
examples=.
if test "x$1" = x-I ; then
examples="$2"
shift; shift
fi
# Run the tests.
for file
do
test -f "$file" || {
echo "No such file: $file"
continue
}
echo "Checking $file"
options=`sed -ne '3s/^dnl @ extra options: //p;3q' "$file"`
sed -e '/^dnl @/d' -e '/^\^D$/q' "$file" \
| LC_MESSAGES=C m4 -d -I "$examples" $options - >$out 2>$err
stat=$?
xstat=`sed -ne '2s/^dnl @ expected status: //p;2q' "$file"`
case $stat in
77)
skipped="$skipped $file"
cat $err
continue
;;
$xstat) ;;
*)
failed="$failed $file:status"
echo `sed -e 's/^dnl //' -e 1q $file`
echo "$file: status was $stat, expected $xstat"
;;
esac
sed -e '/^dnl @result{}/!d' -e 's///' -e "s|\.\./examples|$examples|" \
"$file" > $xout
sed -e '/^dnl @error{}/!d' -e 's///' -e "s|^m4:|$m4:|" "$file" > $xerr
# For the benefit of mingw, normalize \r\n line endings
if $strip_needed ; then
tr -d '\015' < $out > $out.t
mv $out.t $out
tr -d '\015' < $xout > $xout.t
mv $xout.t $xout
tr -d '\015' < $err > $err.t
mv $err.t $err
tr -d '\015' < $xerr > $xerr.t
mv $xerr.t $xerr
fi
if cmp -s $out $xout; then
:
else
failed="$failed $file:out"
echo `sed -e 's/^dnl //' -e 1q $file`
echo "$file: stdout mismatch"
diff $xout $out
fi
if cmp -s $err $xerr; then
:
else
failed="$failed $file:err"
echo `sed -e 's/^dnl //' -e 1q $file`
echo "$file: stderr mismatch"
diff $xerr $err
fi
done
rm -f $out $err $xout $xerr
echo
if test -n "$skipped"; then
echo "Skipped checks were:"
echo " $skipped"
fi
if test -z "$failed"; then
echo "All checks successful"
stat=0
else
echo "Failed checks were:"
echo " $failed"
stat=1
fi
(exit $stat); exit $stat
|