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