1#! /bin/sh
2
3# Test all package
4
5# Usage:
6#   scripts/testall.sh [--noregressions]
7#                      [--csl] [--cslboot] [--installed-csl]
8#                      [--csl-XXX] [--cslboot-XXX]
9#                      [--csl=host-triple]
10#                      [--jlisp] [[jlispboot]
11#                      [--psl] [--installed-psl]
12#                      [--uncached] [--install] [--keep] [--just-time]
13#
14# If present the argument "--noregressions" must come first and it
15# causes the script to avoid running the regression tests. This may be useful
16# when just checking performance of the core of Reduce.
17#
18# Other arguments can be given in any order. "--install" will lead to
19# a fresh set of reference logs being places in the source tree based on
20# testing the CSL version. "--keep" preserves some temporary files created
21# during testing and may be useful when debugging this script. "--uncached"
22# runs the tests with symbolic(!*uncached := t);
23# --csl, --psl, --jlisp, --cslboot and --jlispboot select the variants
24# of Reduce to test, and any number of those options can be given. If none
25# are then "--csl --psl" is assumed. --csl-XXX stands for something like
26# --csl-debug, --csl-nothrow, --csl-nothrow-debug or some other collection
27# of options referring to a copy of Reduce (or bootstrareduce) in the cslbuild
28# directory.
29# --installed-csl and --installed-psl use versions of the redcsl and redpsl
30# command present on your PATH.
31
32# Part of the intent here is that if any further variants of Reduce get
33# created it should be reasonably straightforward to extent the code here
34# to support testing them. Changes will be needed in "test1.sh" too.
35
36# I want this script to be one I can launch from anywhere, so
37# to access files etc I need to know where it lives. The logs directories
38# csl-times, psl-times etc are created as sub-directories of the directory
39# current when this script was invoked.
40
41here="$0";while test -L "$here";do here=`ls -ld "$here" | sed 's/.*-> //'`;done
42here=`dirname "$here"`
43here=`cd "$here"; pwd -P`
44here=`dirname "$here"`
45
46# Well I want to tidy up files relating to platforms being tested so I
47# do need to scan the argument list and collect them
48
49noregressions="no"
50if test "$1" = "--noregressions"
51then
52  noregressions="yes"
53  shift
54fi
55
56platforms=""
57plist=""
58base=""
59extras=""
60version=""
61just_time="no"
62for a in $*
63do
64  case $a
65  in
66  --install | --keep | --uncached)
67    extras="$extras $a"
68    ;;
69  --csl | --csl-* | --cslboot | --cslboot-* | --csl=* | --jlisp | \
70  --jlispboot | --installed-csl | --psl | --installed-psl)
71# I will build up two lists of the platforms to test, plus a variable.
72#    $platforms will be a sequence of names like "csl psl" etc and is used in
73#       this file to deal with directories within which logs accumulate.
74#    $base is the first entry on $platforms and is used as the base-system
75#       against which others are evaluated.
76#    $plist is a list like "--psl --csl" used to pass down to test1.sh
77    sys=${a#--}
78    if test "$base" = ""
79    then
80      plist="$a"
81      platforms="$sys"
82      base="$sys"
83    else
84      plist="$plist $a"
85      platforms="$platforms $sys"
86    fi
87    ;;
88  --just-time)
89    just_time="yes"
90    ;;
91  *)
92    printf "\"$a\" is not a valid argument to this script.\n"
93    printf "Valid options are: --csl* --cslboot* --jlisp --jlispboot --psl\n"
94    printf "    --noregressions --install --keep --uncached\n"
95    printf "Stopping.\n"
96    exit 1
97    ;;
98  esac
99done
100
101# Apply default if no platforms specified
102if test "$base" = ""
103then
104  plist="--csl --psl"
105  platforms="csl psl"
106  base="csl"
107fi
108
109if test "$just_time" = "no"
110then
111
112#
113# Remove old log files
114#
115  for sys in $platforms
116  do
117    sys=${sys#csl=}
118    rm -f $sys-times/*.rlg* $sys-times/showtimes \
119          $base-$sys-times-comparison/*.rlg.diff
120    mkdir -p $sys-times
121    echo "showtimes := '(" > $sys-times/showtimes
122  done
123
124  packages=`sed -e '/^\%/d' $here/packages/package.map | \
125            grep ' test ' | \
126            sed -e 's/(//; s/".*//'`
127
128  for p in $packages
129  do
130    echo "Test package $p"
131    $here/scripts/test1.sh $extras $plist $p
132  done
133
134  if test "$noregressions" = "no"
135  then
136    for p1 in $here/packages/regressions/*.tst
137    do
138      p=${p1%.tst}
139      p=${p##*/}
140      echo "Test regression case $p"
141      $here/scripts/test1.sh $extras $plist regressions $p
142    done
143  fi
144
145  for sys in $platforms
146  do
147    sys=${sys#csl=}
148    echo ")\$ end\$" >> $sys-times/showtimes
149  done
150fi
151
152printf "\nSummary of test runs for $platforms\n\n"
153
154if test "$just_time" = "no"
155then
156  for sys in $platforms
157  do
158    sys=${sys#csl=}
159    d=`cd $sys-times; echo *.rlg.diff`
160    if test "$d" != "*.rlg.diff"
161    then
162      printf "\nDifferences for $sys: `echo $d | sed -e 's/\.rlg\.diff//g'`\n"
163    fi
164  done
165
166  for sys in $platforms
167  do
168    sys=${sys#csl=}
169    if test "$sys" != "$base"
170    then
171      d=`cd $base-$sys-times-comparison; echo *.rlg.diff`
172      if test "$d" != "*.rlg.diff"
173      then
174        printf "\nDifferences between $base and $sys: `echo $d | sed -e 's/\.rlg\.diff//g'`\n"
175      fi
176    fi
177  done
178
179  printf "\n"
180fi
181
182reporttime() {
183  name=$1
184  dir=$2
185  total="0"
186  opt=""
187  if test "`which redcsl 2> /dev/null`" != ""
188  then
189    red="redcsl"
190    opt="-w"
191  elif test "`which redpsl 2> /dev/null`" != ""
192  then
193    red="redpsl"
194  else
195    red="$here/bin/redcsl"
196    opt="-w"
197  fi
198  "$red" "$opt" <<XXX | grep "^$name"
199symbolic <<
200in "$dir/showtimes"$
201total := for each r in showtimes sum cadr r;
202gctotal := for each r in showtimes sum caddr r;
203terpri();
204prin2 "$name";
205prin2 " ";
206while posn() < 20 do prin2 " ";
207prin2 total; prin2 " ms CPU ";
208while posn() < 40 do prin2 " ";
209prin2 gctotal; prin2 " ms GC";
210terpri();
211quit; >>$
212XXX
213}
214
215for sys in $platforms
216do
217  case $sys in
218  cslboot*)
219    reporttime "CSLBOOT${sys#cslboot}" "$sys-times"
220    ;;
221  installed-cslboot)
222    reporttime "installedCSLBOOT" "installed-cslboot-times"
223    ;;
224  csl | csl-*)
225    reporttime "CSL${sys#csl}" "$sys-times"
226    ;;
227  installed-csl)
228    reporttime "installedCSL" "installed-csl-times"
229    ;;
230  csl=*)
231    reporttime "${sys#csl=}" "${sys#csl=}-times"
232    ;;
233  jlisp)
234    reporttime "Jlisp" "jlisp-times"
235    ;;
236  jlispboot)
237    reporttime "Jlispboot" "jlispboot-times"
238    ;;
239  psl)
240    reporttime "PSL" "psl-times"
241    ;;
242  installed-psl)
243    reporttime "installedPSL" "installed-psl-times"
244    ;;
245  *)
246    printf "+++ $sys unknown\n"
247    ;;
248  esac
249done
250
251# end of script
252
253