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