2 # Check GNU m4 against examples from the manual source.
3 # Copyright (C) 1992, 2006 Free Software Foundation, Inc.
5 # Sanity check what we are testing
8 # Clean up temp files on exit
11 trap 'stat=$?; cd $pwd; rm -rf $tmp && exit $stat' 0
12 trap '(exit $?); exit $?' 1 2 13 15
16 mkdir
$tmp || framework_failure
=1
18 if test $framework_failure = 1; then
19 echo "$0: failure in testing framework" 1>&2
31 # Find out how the executable prints argv[0]
32 m4=`m4 --help | sed -e 's/Usage: \(.*\) \[OPTION.*/\1/' \
33 -e 's/\\\\/\\\\\\\\/g' -e 1q`
35 # Find out if we should strip \r in the output
37 m4 --version |
tr -d '\015' > $xout
38 if cmp -s $out $xout; then
41 echo "Ignoring carriage returns"
45 # Find out where the examples live.
47 if test "x$1" = x-I
; then
56 echo "No such file: $file"
60 sed -e '/^dnl @/d' -e '/^\^D$/q' "$file" \
61 | LC_MESSAGES
=C
m4 -d -I "$examples" - >$out 2>$err
63 if test $?
= 77 ; then
64 skipped
="$skipped $file"
69 sed -e '/^dnl @result{}/!d' -e 's///' -e "s|\.\./examples|$examples|" \
71 sed -e '/^dnl @error{}/!d' -e 's///' -e "s|^m4:|$m4:|" "$file" > $xerr
73 # For the benefit of mingw, normalize \r\n line endings
74 if $strip_needed ; then
75 tr -d '\015' < $out > $out.t
77 tr -d '\015' < $xout > $xout.t
79 tr -d '\015' < $err > $err.t
81 tr -d '\015' < $xerr > $xerr.t
85 if cmp -s $out $xout; then
88 failed
="$failed $file:out"
89 echo `sed -e 's/^dnl //' -e 1q $file`
90 echo "$file: stdout mismatch"
94 if cmp -s $err $xerr; then
97 failed
="$failed $file:err"
98 echo `sed -e 's/^dnl //' -e 1q $file`
99 echo "$file: stderr mismatch"
105 rm -f $out $err $xout $xerr
108 if test -n "$skipped"; then
109 echo "Skipped checks were:"
112 if test -z "$failed"; then
113 echo "All checks successful"
116 echo "Failed checks were:"
120 (exit $stat); exit $stat