For compatibility with other m4 implementations, sysval returns
[m4/ericb.git] / checks / check-them
blobc17f021c40dfb8da4480a954af5228253d3ba6c4
1 #!/bin/sh
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
6 m4 --version
8 # Clean up temp files on exit
9 pwd=`pwd`
10 tmp=m4-tmp.$$
11 trap 'stat=$?; cd $pwd; rm -rf $tmp && exit $stat' 0
12 trap '(exit $?); exit $?' 1 2 13 15
14 # Create scratch dir
15 framework_failure=0
16 mkdir $tmp || framework_failure=1
18 if test $framework_failure = 1; then
19 echo "$0: failure in testing framework" 1>&2
20 (exit 1); exit 1
23 out=$tmp/m4-out
24 err=$tmp/m4-err
25 xout=$tmp/m4-xout
26 xerr=$tmp/m4-xerr
27 failed=
28 skipped=
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.
35 for file
37 echo "Checking $file"
38 LC_MESSAGES=C m4 -d -I ../examples $file >$out 2>$err
40 if test $? == 77 ; then
41 skipped="$skipped $file"
42 continue
45 sed -e '/^dnl @result{}/!d' -e 's///' -e "s/m4.input/$file/" $file > $xout
47 if cmp -s $out $xout; then
49 else
50 failed="$failed $file:out"
51 echo `sed -e 's/^dnl //' -e 1q $file`
52 echo "$file: stdout mismatch"
53 diff $xout $out
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
61 else
62 failed="$failed $file:err"
63 echo `sed -e 's/^dnl //' -e 1q $file`
64 echo "$file: stderr mismatch"
65 diff $xerr $err
68 done
70 rm -f $out $err $xout $xerr
72 echo
73 if test -n "$skipped"; then
74 echo "Skipped checks were:"
75 echo " $skipped"
77 if test -z "$failed"; then
78 echo "All checks successful"
79 stat=0
80 else
81 echo "Failed checks were:"
82 echo " $failed"
83 stat=1
85 (exit $stat); exit $stat