0.7.7.32:
[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 sbclstem=`pwd`/../src/runtime/sbcl
23 SBCL="${1:-$sbclstem --core `pwd`/../output/sbcl.core --noinform --sysinit /dev/null --userinit /dev/null --noprint --disable-debugger}"
24 export SBCL
25 echo /running tests on SBCL=\'$SBCL\'
26 # more or less like SBCL, but without enough grot removed that appending
27 # a --core command line argument works
28 SBCL_ALLOWING_CORE=${1:-$sbclstem}
29 export SBCL_ALLOWING_CORE
30 echo /with SBCL_ALLOWING_CORE=\'$SBCL_ALLOWING_CORE\'
31
32 # "Ten four" is the closest numerical slang I can find to "OK", so
33 # it's the Unix status value that we expect from a successful test.
34 # (Of course, zero is the usual success value, but we don't want to
35 # use that because SBCL returns that by default, so we might think
36 # we passed a test when in fact some error caused us to exit SBCL
37 # in a weird unexpected way. In contrast, 104 is unlikely to be
38 # returned unless we exit through the intended explicit "test
39 # successful" path.
40 tenfour () {
41     if [ $? = 104 ]; then
42         echo ok
43     else
44         echo test failed, expected 104 return code, got $?
45         exit 1
46     fi
47 }
48
49 # *.pure.lisp files are ordinary Lisp code with no side effects,
50 # and we can run them all in a single Lisp process.
51 echo //running '*.pure.lisp' tests
52 echo //i.e. *.pure.lisp
53 (
54 echo "(progn"
55 for f in *.pure.lisp; do
56     if [ -f $f ]; then
57         echo "  (progn (format t \"//running $f test~%\") (load \"$f\"))"
58     fi
59 done
60 echo "  (sb-ext:quit :unix-status 104)) ; Return status=success."
61 ) | $SBCL ; tenfour
62
63 # *.impure.lisp files are Lisp code with side effects (e.g. doing
64 # DEFSTRUCT or DEFTYPE or DEFVAR, or messing with the read table).
65 # Each one should be LOADed in a separate invocation of Lisp, so 
66 # that we don't need to worry about them interfering with each
67 # other.
68 echo //running '*.impure.lisp' tests
69 for f in *.impure.lisp; do
70     if [ -f $f ]; then
71         echo //running $f test
72         echo "(load \"$f\")" | $SBCL ; tenfour
73     fi
74 done
75
76 # *.test.sh files are scripts to test stuff, typically stuff which 
77 # can't so easily be tested within Lisp itself. A file foo.test.sh
78 # may be associated with other files foo*, e.g. foo.lisp, foo-1.lisp,
79 # or foo.pl.
80 echo //running '*.test.sh' tests
81 for f in *.test.sh; do
82     if [ -f $f ]; then
83         echo //running $f test
84         sh $f "$SBCL"; tenfour
85     fi
86 done
87
88 # *.assertoids files contain ASSERTOID statements to test things
89 # interpreted and at various compilation levels.
90 echo //running '*.assertoids' tests
91 for f in *.assertoids; do
92     if [ -f $f ]; then
93         echo //running $f test
94         echo "(load \"$f\")" | $SBCL --eval '(load "assertoid.lisp")' ; tenfour
95     fi
96 done
97
98 # *.pure-cload.lisp files want to be compiled, then loaded. They 
99 # can all be done in the same invocation of Lisp.
100 echo //running '*.pure-cload.lisp' tests
101 for f in *.pure-cload.lisp; do
102     # (Actually here we LOAD each one into a separate invocation
103     # of Lisp just because I haven't figured out a concise way
104     # to LOAD them all into the same Lisp.)
105     if [ -f $f ]; then
106         echo //running $f test
107         $SBCL <<EOF ; tenfour
108                 (compile-file "$f")
109                 (progn
110                   (unwind-protect
111                   (load *)
112                    (ignore-errors (delete-file (compile-file-pathname "$f"))))
113                   (sb-ext:quit :unix-status 104))
114 EOF
115     fi
116 done
117
118 # *.impure-cload.lisp files want to be compiled, then loaded. They
119 # can have side effects, so each one should be done in a separate
120 # invocation of Lisp so that they don't interfere.
121 echo //running '*.impure-cload.lisp' tests
122 for f in *.impure-cload.lisp; do
123     if [ -f $f ]; then
124         echo //running $f test
125         $SBCL <<EOF ; tenfour
126                 (compile-file "$f")
127                 (progn
128                   (unwind-protect
129                   (load *)
130                    (ignore-errors (delete-file (compile-file-pathname "$f"))))
131                   (sb-ext:quit :unix-status 104))
132 EOF
133     fi
134 done
135
136 # (*.before-xc.lisp and *.after-xc.lisp files aren't handled in this
137 # script at all. They're tests intended to run in the cross-compiler,
138 # so that some functionality can be tested even when cold init doesn't
139 # work.)
140
141 echo '//apparent success (reached end of run-tests.sh normally)'
142 date