]> granicus.if.org Git - postgresql/blob - src/test/regress/pg_regress.sh
Provide a --no-locale option for pg_regress and a corresponding NOLOCALE=1
[postgresql] / src / test / regress / pg_regress.sh
1 #! /bin/sh
2 # $PostgreSQL: pgsql/src/test/regress/pg_regress.sh,v 1.61 2005/11/01 15:09:11 adunstan Exp $
3
4 me=`basename $0`
5 : ${TMPDIR=/tmp}
6 TMPFILE=$TMPDIR/pg_regress.$$
7
8 help="\
9 PostgreSQL regression test driver
10
11 Usage: $me [options...] [extra tests...]
12
13 Options:
14   --dbname=DB               use database DB (default \`regression')
15   --debug                   turn on debug mode in programs that are run
16   --inputdir=DIR            take input files from DIR (default \`.')
17   --load-language=lang      load the named language before running the
18                             tests; can appear multiple times
19   --max-connections=N       maximum number of concurrent connections
20                             (default is 0 meaning unlimited)
21   --multibyte=ENCODING      use ENCODING as the multibyte encoding, and
22                             also run a test by the same name
23   --outputdir=DIR           place output files in DIR (default \`.')
24   --schedule=FILE           use test ordering schedule from FILE
25                             (may be used multiple times to concatenate)
26   --temp-install[=DIR]      create a temporary installation (in DIR)
27   --no-locale               use C locale
28
29 Options for \`temp-install' mode:
30   --top-builddir=DIR        (relative) path to top level build directory
31   --temp-port=PORT          port number to start temp postmaster on
32
33 Options for using an existing installation:
34   --host=HOST               use postmaster running on HOST
35   --port=PORT               use postmaster running at PORT
36   --user=USER               connect as USER
37
38 The exit status is 0 if all tests passed, 1 if some tests failed, and 2
39 if the tests could not be run for some reason.
40
41 Report bugs to <pgsql-bugs@postgresql.org>."
42
43
44 message(){
45     _dashes='==============' # 14
46     _spaces='                                      ' # 38
47     _msg=`echo "$1$_spaces" | cut -c 1-38`
48     echo "$_dashes $_msg $_dashes"
49 }
50
51
52 # ----------
53 # Unset locale settings
54 # ----------
55
56 unset LC_COLLATE LC_CTYPE LC_MONETARY LC_MESSAGES LC_NUMERIC LC_TIME LC_ALL LANG LANGUAGE
57
58 # On Windows the default locale may not be English, so force it
59 case $host_platform in
60     *-*-cygwin*|*-*-mingw32*)
61         LANG=en
62         export LANG
63         ;;
64 esac
65
66
67 # ----------
68 # Check for echo -n vs echo \c
69 # ----------
70
71 if echo '\c' | grep c >/dev/null 2>&1; then
72     ECHO_N='echo -n'
73     ECHO_C=''
74 else
75     ECHO_N='echo'
76     ECHO_C='\c'
77 fi
78
79
80 # ----------
81 # Initialize default settings
82 # ----------
83
84 : ${inputdir=.}
85 : ${outputdir=.}
86
87 libdir='@libdir@'
88 bindir='@bindir@'
89 datadir='@datadir@'
90 host_platform='@host_tuple@'
91 enable_shared='@enable_shared@'
92 GCC=@GCC@
93
94 if [ "$GCC" = yes ]; then
95     compiler=gcc
96 else
97     compiler=cc
98 fi
99
100 unset mode
101 unset schedule
102 unset debug
103 unset nolocale
104 unset top_builddir
105 unset temp_install
106 unset multibyte
107
108 dbname=regression
109 hostname=localhost
110 maxconnections=0
111 temp_port=65432
112 load_langs=""
113
114 : ${GMAKE='@GMAKE@'}
115
116
117 # ----------
118 # Parse command line options
119 # ----------
120
121 while [ "$#" -gt 0 ]
122 do
123     case $1 in
124         --help|-\?)
125                 echo "$help"
126                 exit 0;;
127         --version)
128                 echo "pg_regress (PostgreSQL @VERSION@)"
129                 exit 0;;
130         --dbname=*)
131                 dbname=`expr "x$1" : "x--dbname=\(.*\)"`
132                 shift;;
133         --debug)
134                 debug=yes
135                 shift;;
136         --inputdir=*)
137                 inputdir=`expr "x$1" : "x--inputdir=\(.*\)"`
138                 shift;;
139         --load-language=*)
140                 lang=`expr "x$1" : "x--load-language=\(.*\)"`
141                 load_langs="$load_langs $lang"
142                 unset lang
143                 shift;;
144         --multibyte=*)
145                 multibyte=`expr "x$1" : "x--multibyte=\(.*\)"`
146                 shift;;
147         --no-locale)
148                 nolocale=yes
149                 shift;;
150         --temp-install)
151                 temp_install=./tmp_check
152                 shift;;
153         --temp-install=*)
154                 temp_install=`expr "x$1" : "x--temp-install=\(.*\)"`
155                 shift;;
156         --max-connections=*)
157                 maxconnections=`expr "x$1" : "x--max-connections=\(.*\)"`
158                 shift;;
159         --outputdir=*)
160                 outputdir=`expr "x$1" : "x--outputdir=\(.*\)"`
161                 shift;;
162         --schedule=*)
163                 foo=`expr "x$1" : "x--schedule=\(.*\)"`
164                 schedule="$schedule $foo"
165                 shift;;
166         --top-builddir=*)
167                 top_builddir=`expr "x$1" : "x--top-builddir=\(.*\)"`
168                 shift;;
169         --temp-port=*)
170                 temp_port=`expr "x$1" : "x--temp-port=\(.*\)"`
171                 shift;;
172         --host=*)
173                 PGHOST=`expr "x$1" : "x--host=\(.*\)"`
174                 export PGHOST
175                 unset PGHOSTADDR
176                 shift;;
177         --port=*)
178                 PGPORT=`expr "x$1" : "x--port=\(.*\)"`
179                 export PGPORT
180                 shift;;
181         --user=*)
182                 PGUSER=`expr "x$1" : "x--user=\(.*\)"`
183                 export PGUSER
184                 shift;;
185         -*)
186                 echo "$me: invalid argument $1" 1>&2
187                 exit 2;;
188         *)
189                 extra_tests="$extra_tests $1"
190                 shift;;
191     esac
192 done
193
194 # ----------
195 # warn of Cygwin likely failure if maxconnections = 0
196 # and we are running parallel tests
197 # ----------
198
199 case $host_platform in
200     *-*-cygwin*)
201         case "$schedule" in
202             *parallel_schedule*)
203                 if [ $maxconnections -eq 0 ] ; then
204                     echo Using unlimited parallel connections is likely to fail or hang on Cygwin.
205                     echo Try \"$me --max-connections=n\" or \"gmake MAX_CONNECTIONS=n check\"
206                     echo with n = 5 or 10 if this happens.
207                     echo
208                 fi
209                 ;;
210         esac
211         ;;
212 esac
213
214
215 # ----------
216 # On some platforms we can't use Unix sockets.
217 # ----------
218 case $host_platform in
219     *-*-cygwin* | *-*-mingw32* | *-*-qnx* | *beos*)
220         unix_sockets=no;;
221     *)
222         unix_sockets=yes;;
223 esac
224
225
226 # ----------
227 # Set up diff to ignore horizontal white space differences.
228 # ----------
229
230 case $host_platform in
231     *-*-qnx* | *-*-sco3.2v5*)
232         DIFFFLAGS=-b;;
233     *)
234         DIFFFLAGS=-w;;
235 esac
236
237
238 # ----------
239 # Set backend timezone and datestyle explicitly
240 #
241 # To pass the horology test in its current form, the postmaster must be
242 # started with PGDATESTYLE=ISO, while the frontend must be started with
243 # PGDATESTYLE=Postgres.  We set the postmaster values here and change
244 # to the frontend settings after the postmaster has been started.
245 # ----------
246
247 PGTZ='PST8PDT'; export PGTZ
248 PGDATESTYLE='ISO, MDY'; export PGDATESTYLE
249
250
251 # ----------
252 # Exit trap to remove temp file and shut down postmaster
253 # ----------
254
255 # Note:  There are some stupid shells (even among recent ones) that
256 # ignore the argument to exit (as in `exit 1') if there is an exit
257 # trap.  The trap (and thus the shell script) will then always exit
258 # with the result of the last shell command before the `exit'.  Hence
259 # we have to write `(exit x); exit' below this point.
260
261 exit_trap(){ 
262     savestatus=$1
263     if [ -n "$postmaster_pid" ]; then
264         kill -2 "$postmaster_pid"
265         wait "$postmaster_pid"
266         unset postmaster_pid
267     fi
268     rm -f "$TMPFILE" && exit $savestatus
269 }
270
271 trap 'exit_trap $?' 0
272
273 sig_trap() {
274     savestatus=$1
275     echo; echo "caught signal"
276     if [ -n "$postmaster_pid" ]; then
277         echo "signalling fast shutdown to postmaster with pid $postmaster_pid"
278         kill -2 "$postmaster_pid"
279         wait "$postmaster_pid"
280         unset postmaster_pid
281     fi
282     (exit $savestatus); exit
283 }
284
285 trap 'sig_trap $?' 1 2 13 15
286
287
288
289 # ----------
290 # Scan resultmap file to find which platform-specific expected files to use.
291 # The format of each line of the file is
292 #         testname/hostplatformpattern=substitutefile
293 # where the hostplatformpattern is evaluated per the rules of expr(1),
294 # namely, it is a standard regular expression with an implicit ^ at the start.
295 # What hostplatformpattern will be matched against is the config.guess output
296 # followed by either ':gcc' or ':cc' (independent of the actual name of the
297 # compiler executable).
298 #
299 # The tempfile hackery is needed because some shells will run the loop
300 # inside a subshell, whereupon shell variables set therein aren't seen
301 # outside the loop :-(
302 # ----------
303
304 cat /dev/null >$TMPFILE
305 if [ -f "$inputdir/resultmap" ]
306 then
307     while read LINE
308     do
309         HOSTPAT=`expr "$LINE" : '.*/\(.*\)='`
310         if [ `expr "$host_platform:$compiler" : "$HOSTPAT"` -ne 0 ]
311         then
312             # remove hostnamepattern from line so that there are no shell
313             # wildcards in SUBSTLIST; else later 'for' could expand them!
314             TESTNAME=`expr "$LINE" : '\(.*\)/'`
315             SUBST=`echo "$LINE" | sed 's/^.*=//'`
316             echo "$TESTNAME=$SUBST" >> $TMPFILE
317         fi
318     done <"$inputdir/resultmap"
319 fi
320 SUBSTLIST=`cat $TMPFILE`
321 rm -f $TMPFILE
322
323
324 LOGDIR=$outputdir/log
325
326 if [ x"$temp_install" != x"" ]
327 then
328     if echo x"$temp_install" | grep -v '^x/' >/dev/null 2>&1; then
329         temp_install="`pwd`/$temp_install"
330     fi
331
332     bindir=$temp_install/install/$bindir
333     libdir=$temp_install/install/$libdir
334     datadir=$temp_install/install/$datadir
335     PGDATA=$temp_install/data
336
337     if [ "$unix_sockets" = no ]; then
338         PGHOST=$hostname
339         export PGHOST
340         unset PGHOSTADDR
341     else
342         unset PGHOST
343         unset PGHOSTADDR
344     fi
345
346     # since Makefile isn't very bright, check for out-of-range temp_port
347     if [ "$temp_port" -ge 1024 -a "$temp_port" -le 65535 ] ; then
348         PGPORT=$temp_port
349     else
350         PGPORT=65432
351     fi
352     export PGPORT
353
354     # Get rid of environment stuff that might cause psql to misbehave
355     # while contacting our temp installation
356     unset PGDATABASE PGUSER PGSERVICE PGSSLMODE PGREQUIRESSL PGCONNECT_TIMEOUT
357
358     # ----------
359     # Set up shared library paths, needed by psql and pg_encoding
360     # (if you run multibyte).  LD_LIBRARY_PATH covers many platforms.
361     # DYLD_LIBRARY_PATH works on Darwin, and maybe other Mach-based systems.
362     # Feel free to account for others as well.
363     # ----------
364
365     if [ -n "$LD_LIBRARY_PATH" ]; then
366         LD_LIBRARY_PATH="$libdir:$LD_LIBRARY_PATH"
367     else
368         LD_LIBRARY_PATH=$libdir
369     fi
370     export LD_LIBRARY_PATH
371
372     if [ -n "$DYLD_LIBRARY_PATH" ]; then
373         DYLD_LIBRARY_PATH="$libdir:$DYLD_LIBRARY_PATH"
374     else
375         DYLD_LIBRARY_PATH=$libdir
376     fi
377     export DYLD_LIBRARY_PATH
378
379     # ----------
380     # Windows needs shared libraries in PATH. (Only those linked into
381     # executables, not dlopen'ed ones)
382     # ----------
383     case $host_platform in
384         *-*-cygwin*|*-*-mingw32*)
385             PATH=$libdir:$PATH
386             export PATH
387             ;;
388     esac
389
390     if [ -d "$temp_install" ]; then
391         message "removing existing temp installation"
392         rm -rf "$temp_install"
393     fi
394
395     message "creating temporary installation"
396     if [ ! -d "$LOGDIR" ]; then
397         mkdir -p "$LOGDIR" || { (exit 2); exit; }
398     fi
399     $GMAKE -C "$top_builddir" DESTDIR="$temp_install/install" install with_perl=no with_python=no >"$LOGDIR/install.log" 2>&1
400
401     if [ $? -ne 0 ]
402     then
403         echo
404         echo "$me: installation failed"
405         echo "Examine $LOGDIR/install.log for the reason."
406         echo
407         (exit 2); exit
408     fi
409
410     message "initializing database system"
411     [ "$debug" = yes ] && initdb_options="--debug"
412     [ "$nolocale" = yes ] && initdb_options="$initdb_options --no-locale"
413     "$bindir/initdb" -D "$PGDATA" -L "$datadir" --noclean $initdb_options >"$LOGDIR/initdb.log" 2>&1
414
415     if [ $? -ne 0 ]
416     then
417         echo
418         echo "$me: initdb failed"
419         echo "Examine $LOGDIR/initdb.log for the reason."
420         echo
421         (exit 2); exit
422     fi
423
424
425     # ----------
426     # Start postmaster
427     # ----------
428
429     message "starting postmaster"
430     [ "$debug" = yes ] && postmaster_options="$postmaster_options -d 5"
431     if [ "$unix_sockets" = no ]; then
432         postmaster_options="$postmaster_options -c listen_addresses=$hostname"
433     else
434         postmaster_options="$postmaster_options -c listen_addresses="
435     fi
436     "$bindir/postmaster" -D "$PGDATA" -F $postmaster_options >"$LOGDIR/postmaster.log" 2>&1 &
437     postmaster_pid=$!
438
439     # Wait till postmaster is able to accept connections (normally only
440     # a second or so, but Cygwin is reportedly *much* slower).  Don't
441     # wait forever, however.
442     i=0
443     max=60
444     until "$bindir/psql" -X $psql_options postgres </dev/null 2>/dev/null
445     do
446         i=`expr $i + 1`
447         if [ $i -ge $max ]
448         then
449             break
450         fi
451         if kill -0 $postmaster_pid >/dev/null 2>&1
452         then
453             : still starting up
454         else
455             break
456         fi
457         sleep 1
458     done
459
460     if kill -0 $postmaster_pid >/dev/null 2>&1
461     then
462         echo "running on port $PGPORT with pid $postmaster_pid"
463     else
464         echo
465         echo "$me: postmaster did not start"
466         echo "Examine $LOGDIR/postmaster.log for the reason."
467         echo
468         (exit 2); exit
469     fi
470
471 else # not temp-install
472
473     # ----------
474     # Windows needs shared libraries in PATH. (Only those linked into
475     # executables, not dlopen'ed ones)
476     # ----------
477     case $host_platform in
478         *-*-cygwin*|*-*-mingw32*)
479             PATH=$libdir:$PATH
480             export PATH
481             ;;
482     esac
483
484     if [ -n "$PGPORT" ]; then
485         port_info="port $PGPORT"
486     else
487         port_info="default port"
488     fi
489
490     if [ -n "$PGHOST" ]; then
491         echo "(using postmaster on $PGHOST, $port_info)"
492     else
493         if [ "$unix_sockets" = no ]; then
494             echo "(using postmaster on localhost, $port_info)"
495         else
496             echo "(using postmaster on Unix socket, $port_info)"
497         fi
498     fi
499
500     message "dropping database \"$dbname\""
501     "$bindir/dropdb" $psql_options "$dbname"
502     # errors can be ignored
503 fi
504
505
506 # ----------
507 # Set up SQL shell for the test.
508 # ----------
509
510 PSQL="$bindir/psql -a -q -X $psql_options"
511
512
513 # ----------
514 # Set frontend timezone and datestyle explicitly
515 # ----------
516
517 PGTZ='PST8PDT'; export PGTZ
518 PGDATESTYLE='Postgres, MDY'; export PGDATESTYLE
519
520
521 # ----------
522 # Set up multibyte environment
523 # ----------
524
525 if [ -n "$multibyte" ]; then
526     PGCLIENTENCODING=$multibyte
527     export PGCLIENTENCODING
528     encoding_opt="-E $multibyte"
529 else
530     unset PGCLIENTENCODING
531 fi
532
533
534 # ----------
535 # Create the regression database
536 # We use template0 so that any installation-local cruft in template1
537 # will not mess up the tests.
538 # ----------
539
540 message "creating database \"$dbname\""
541 "$bindir/createdb" $encoding_opt $psql_options --template template0 "$dbname"
542 if [ $? -ne 0 ]; then
543     echo "$me: createdb failed"
544     (exit 2); exit
545 fi
546
547 "$bindir/psql" -q -X $psql_options -c "\
548 alter database \"$dbname\" set lc_messages to 'C';
549 alter database \"$dbname\" set lc_monetary to 'C';
550 alter database \"$dbname\" set lc_numeric to 'C';
551 alter database \"$dbname\" set lc_time to 'C';" "$dbname"
552 if [ $? -ne 0 ]; then
553     echo "$me: could not set database default locales"
554     (exit 2); exit
555 fi
556
557
558 # ----------
559 # Remove regressuser* and regressgroup* user accounts.
560 # ----------
561
562 message "dropping regression test user accounts"
563 "$bindir/psql" -q -X $psql_options -c 'DROP GROUP regressgroup1; DROP GROUP regressgroup2; DROP USER regressuser1, regressuser2, regressuser3, regressuser4;' $dbname 2>/dev/null
564 if [ $? -eq 2 ]; then
565     echo "$me: could not drop user accounts"
566     (exit 2); exit
567 fi
568
569
570 # ----------
571 # Install any requested PL languages
572 # ----------
573
574 if [ "$enable_shared" = yes ]; then
575     for lang in xyzzy $load_langs ; do    
576         if [ "$lang" != "xyzzy" ]; then
577             message "installing $lang"
578             "$bindir/createlang" $psql_options $lang $dbname
579             if [ $? -ne 0 ] && [ $? -ne 2 ]; then
580                 echo "$me: createlang $lang failed"
581                 (exit 2); exit
582             fi
583         fi
584     done
585 fi
586
587
588 # ----------
589 # Let's go
590 # ----------
591
592 message "running regression test queries"
593
594 if [ ! -d "$outputdir/results" ]; then
595     mkdir -p "$outputdir/results" || { (exit 2); exit; }
596 fi
597 result_summary_file=$outputdir/regression.out
598 diff_file=$outputdir/regression.diffs
599
600 cat /dev/null >"$result_summary_file"
601 cat /dev/null >"$diff_file"
602
603 lno=0
604 (
605     [ "$enable_shared" != yes ] && echo "ignore: plpgsql"
606     cat $schedule </dev/null
607     for x in $extra_tests; do
608         echo "test: $x"
609     done
610 ) | sed 's/[    ]*#.*//g' | \
611 while read line
612 do
613     # Count line numbers
614     lno=`expr $lno + 1`
615     [ -z "$line" ] && continue
616
617     set X $line; shift
618
619     if [ x"$1" = x"ignore:" ]; then
620         shift
621         ignore_list="$ignore_list $@"
622         continue
623     elif [ x"$1" != x"test:" ]; then
624         echo "$me:$schedule:$lno: syntax error"
625         (exit 2); exit
626     fi
627
628     shift
629
630     # ----------
631     # Start tests
632     # ----------
633
634     if [ $# -eq 1 ]; then
635         # Run a single test
636         formatted=`echo $1 | awk '{printf "%-20.20s", $1;}'`
637         $ECHO_N "test $formatted ... $ECHO_C"
638         ( $PSQL -d "$dbname" <"$inputdir/sql/$1.sql" >"$outputdir/results/$1.out" 2>&1 )&
639         wait
640     else
641         # Start a parallel group
642         $ECHO_N "parallel group ($# tests): $ECHO_C"
643         if [ $maxconnections -gt 0 ] ; then
644             connnum=0
645             test $# -gt $maxconnections && $ECHO_N "(in groups of $maxconnections) $ECHO_C"
646         fi
647         for name do
648             ( 
649               $PSQL -d "$dbname" <"$inputdir/sql/$name.sql" >"$outputdir/results/$name.out" 2>&1
650               $ECHO_N " $name$ECHO_C"
651             ) &
652             if [ $maxconnections -gt 0 ] ; then
653                 connnum=`expr \( $connnum + 1 \) % $maxconnections`
654                 test $connnum -eq 0 && wait
655             fi
656         done
657         wait
658         echo
659     fi
660
661     # ----------
662     # Run diff
663     # (We do not want to run the diffs immediately after each test,
664     # because they would certainly get corrupted if run in parallel
665     # subshells.)
666     # ----------
667
668     for name do
669         if [ $# -ne 1 ]; then
670             formatted=`echo "$name" | awk '{printf "%-20.20s", $1;}'`
671             $ECHO_N "     $formatted ... $ECHO_C"
672         fi
673
674         # Check list extracted from resultmap to see if we should compare
675         # to a system-specific expected file.
676         # There shouldn't be multiple matches, but take the last if there are.
677
678         EXPECTED="$inputdir/expected/${name}"
679         for LINE in $SUBSTLIST
680         do
681             if [ `expr "$LINE" : "$name="` -ne 0 ]
682             then
683                 SUBST=`echo "$LINE" | sed 's/^.*=//'`
684                 EXPECTED="$inputdir/expected/${SUBST}"
685             fi
686         done
687
688         # If there are multiple equally valid result files, loop to get the right one.
689         # If none match, diff against the closest one.
690
691         bestfile=
692         bestdiff=
693         result=2
694         for thisfile in $EXPECTED.out ${EXPECTED}_[0-9].out; do
695             [ ! -r "$thisfile" ] && continue
696             diff $DIFFFLAGS $thisfile $outputdir/results/${name}.out >/dev/null 2>&1
697             result=$?
698             case $result in
699                 0) break;;
700                 1) thisdiff=`diff $DIFFFLAGS $thisfile $outputdir/results/${name}.out | wc -l`
701                    if [ -z "$bestdiff" ] || [ "$thisdiff" -lt "$bestdiff" ]; then
702                        bestdiff=$thisdiff; bestfile=$thisfile
703                    fi
704                    continue;;
705                 2) break;;
706             esac
707         done
708
709         # Now print the result.
710
711         case $result in
712             0)
713                 echo "ok";;
714             1)
715                 ( diff $DIFFFLAGS -C3 $bestfile $outputdir/results/${name}.out
716                   echo
717                   echo "======================================================================"
718                   echo ) >> "$diff_file"
719                 if echo " $ignore_list " | grep " $name " >/dev/null 2>&1 ; then
720                     echo "failed (ignored)"
721                 else
722                     echo "FAILED"
723                 fi
724                 ;;
725             2)
726                 # disaster struck
727                 echo "trouble" 1>&2
728                 (exit 2); exit;;
729         esac
730     done
731 done | tee "$result_summary_file" 2>&1
732
733 [ $? -ne 0 ] && exit
734
735 # ----------
736 # Server shutdown
737 # ----------
738
739 if [ -n "$postmaster_pid" ]; then
740     message "shutting down postmaster"
741     "$bindir/pg_ctl" -s -D "$PGDATA" stop
742     wait "$postmaster_pid"
743     unset postmaster_pid
744 fi
745
746 rm -f "$TMPFILE"
747
748
749 # ----------
750 # Evaluation
751 # ----------
752
753 count_total=`cat "$result_summary_file" | grep '\.\.\.' | wc -l | sed 's/ //g'`
754 count_ok=`cat "$result_summary_file" | grep '\.\.\. ok' | wc -l | sed 's/ //g'`
755 count_failed=`cat "$result_summary_file" | grep '\.\.\. FAILED' | wc -l | sed 's/ //g'`
756 count_ignored=`cat "$result_summary_file" | grep '\.\.\. failed (ignored)' | wc -l | sed 's/ //g'`
757
758 echo
759 if [ $count_total -eq $count_ok ]; then
760     msg="All $count_total tests passed."
761     result=0
762 elif [ $count_failed -eq 0 ]; then
763     msg="$count_ok of $count_total tests passed, $count_ignored failed test(s) ignored."
764     result=0
765 elif [ $count_ignored -eq 0 ]; then
766     msg="$count_failed of $count_total tests failed."
767     result=1
768 else
769     msg="`expr $count_failed + $count_ignored` of $count_total tests failed, $count_ignored of these failures ignored."
770     result=1
771 fi
772
773 dashes=`echo " $msg " | sed 's/./=/g'`
774 echo "$dashes"
775 echo " $msg "
776 echo "$dashes"
777 echo
778
779 if [ -s "$diff_file" ]; then
780     echo "The differences that caused some tests to fail can be viewed in the"
781     echo "file \`$diff_file'.  A copy of the test summary that you see"
782     echo "above is saved in the file \`$result_summary_file'."
783     echo
784 else
785     rm -f "$diff_file" "$result_summary_file"
786 fi
787
788
789 (exit $result); exit