0.pre7.62:
[sbcl.git] / tests / run-tests.sh
1 #!/bin/sh
2
3 # Run the regression tests in this directory.
4
5 # This software is part of the SBCL system. See the README file for
6 # more information.
7 #
8 # While most of SBCL is derived from the CMU CL system, the test
9 # files (like this one) were written from scratch after the fork
10 # from CMU CL.
11
12 # This software is in the public domain and is provided with
13 # absolutely no warranty. See the COPYING and CREDITS files for
14 # more information.
15
16 # how we invoke SBCL in the tests
17 #
18 # Until sbcl-0.6.12.8, the shell variable SBCL was bound to a relative
19 # pathname, but now we take care to bind it to an absolute pathname (still
20 # generated relative to `pwd` in the tests/ directory) so that tests
21 # can chdir before invoking SBCL and still work.
22 export SBCL="${1:-`pwd`/../src/runtime/sbcl --core `pwd`/../output/sbcl.core --noinform --sysinit /dev/null --userinit /dev/null --noprint --noprogrammer}"
23 echo /running tests on SBCL=\'$SBCL\'
24
25 # "Ten four" is the closest numerical slang I can find to "OK", so
26 # it's the Unix status value that we expect from a successful test.
27 # (Of course, zero is the usual success value, but we don't want to
28 # use that because SBCL returns that by default, so we might think
29 # we passed a test when in fact some error caused us to exit SBCL
30 # in a weird unexpected way. In contrast, 104 is unlikely to be
31 # returned unless we exit through the intended explicit "test
32 # successful" path.
33 tenfour () {
34     if [ $? = 104 ]; then
35         echo ok
36     else
37         echo test failed, expected 104 return code, got $?
38         exit 1
39     fi
40 }
41
42 # *.pure.lisp files are ordinary Lisp code with no side effects,
43 # and we can run them all in a single Lisp process.
44 echo //running '*.pure.lisp' tests
45 echo //i.e. *.pure.lisp
46 (
47 echo "(progn"
48 for f in *.pure.lisp; do
49     if [ -f $f ]; then
50         echo "  (progn (format t \"//running $f test~%\") (load \"$f\"))"
51     fi
52 done
53 echo "  (sb-ext:quit :unix-status 104)) ; Return status=success."
54 ) | $SBCL ; tenfour
55
56 # *.impure.lisp files are Lisp code with side effects (e.g. doing
57 # DEFSTRUCT or DEFTYPE or DEFVAR, or messing with the read table).
58 # Each one should be LOADed in a separate invocation of Lisp, so 
59 # that we don't need to worry about them interfering with each
60 # other.
61 echo //running '*.impure.lisp' tests
62 for f in *.impure.lisp; do
63     if [ -f $f ]; then
64         echo //running $f test
65         echo "(load \"$f\")" | $SBCL ; tenfour
66     fi
67 done
68
69 # *.test.sh files are scripts to test stuff, typically stuff which 
70 # can't so easily be tested within Lisp itself. A file foo.test.sh
71 # may be associated with other files foo*, e.g. foo.lisp, foo-1.lisp,
72 # or foo.pl.
73 echo //running '*.test.sh' tests
74 for f in *.test.sh; do
75     if [ -f $f ]; then
76         echo //running $f test
77         sh $f "$SBCL"; tenfour
78     fi
79 done
80
81 # *.assertoids files contain ASSERTOID statements to test things
82 # interpreted and at various compilation levels.
83 echo //running '*.assertoids' tests
84 for f in *.assertoids; do
85     if [ -f $f ]; then
86         echo //running $f test
87         echo "(load \"$f\")" | $SBCL --eval '(load "assertoid.lisp")' ; tenfour
88     fi
89 done
90
91 # *.pure-cload.lisp files want to be compiled, then loaded. They 
92 # can all be done in the same invocation of Lisp.
93 echo //running '*.pure-cload.lisp' tests
94 for f in *.pure-cload.lisp; do
95     # (Actually here we LOAD each one into a separate invocation
96     # of Lisp just because I haven't figured out a concise way
97     # to LOAD them all into the same Lisp.)
98     if [ -f $f ]; then
99         echo //running $f test
100         $SBCL <<EOF ; tenfour
101                 (compile-file "$f")
102                 (progn (load *) (sb-ext:quit :unix-status 104))
103 EOF
104     fi
105 done
106
107 # *.impure-cload.lisp files want to be compiled, then loaded. They
108 # can have side effects, so each one should be done in a separate
109 # invocation of Lisp so that they don't interfere.
110 echo //running '*.impure-cload.lisp' tests
111 for f in *.impure-cload.lisp; do
112     if [ -f $f ]; then
113         echo //running $f test
114         $SBCL <<EOF ; tenfour
115                 (compile-file "$f")
116                 (progn (load *) (sb-ext:quit :unix-status 104))
117 EOF
118     fi
119 done
120
121 # (*.before-xc.lisp and *.after-xc.lisp files aren't handled in this
122 # script at all. They're tests intended to run in the cross-compiler,
123 # so that some functionality can be tested even when cold init doesn't
124 # work.)
125
126 echo '//apparent success (reached end of run-tests.sh normally)'
127 date