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