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