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
30 # Find out how the executable prints argv[0]
31 m4=`m4 --help | sed -e 's/Usage: \(.*\) \[OPTION.*/\1/' \
32 -e 's/\\\\/\\\\\\\\/g' -e 1q`
34 # Run the tests. This assumes pwd is the checks directory.
38 LC_MESSAGES
=C
m4 -d -I ..
/examples
$file >$out 2>$err
40 if test $?
== 77 ; then
41 skipped
="$skipped $file"
45 sed -e '/^dnl @result{}/!d' -e 's///' -e "s/m4.input/$file/" $file > $xout
47 if cmp -s $out $xout; then
50 failed
="$failed $file:out"
51 echo `sed -e 's/^dnl //' -e 1q $file`
52 echo "$file: stdout mismatch"
56 sed -e '/^dnl @error{}/!d' -e 's///' -e "s/m4.input/$file/" \
57 -e "s| m4:| $m4:|" $file > $xerr
59 if cmp -s $err $xerr; then
62 failed
="$failed $file:err"
63 echo `sed -e 's/^dnl //' -e 1q $file`
64 echo "$file: stderr mismatch"
70 rm -f $out $err $xout $xerr
73 if test -n "$skipped"; then
74 echo "Skipped checks were:"
77 if test -z "$failed"; then
78 echo "All checks successful"
81 echo "Failed checks were:"
85 (exit $stat); exit $stat