Decrease scope of OUT-TO macrolet in SB-COLD:GENESIS
[sbcl.git] / tests / core.test.sh
blob307206506ddf7362eb79c2750027b1c794f7dd06
1 #!/bin/sh
3 # tests related to .core files
5 # This software is part of the SBCL system. See the README file for
6 # more information.
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.
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.
16 . ./subr.sh
18 use_test_subdirectory
20 tmpcore=$TEST_FILESTEM.core
21 tmpoutput=$TEST_FILESTEM.txt
23 run_sbcl <<EOF
24 (save-lisp-and-die "$tmpcore" :toplevel (lambda () 42))
25 EOF
26 run_sbcl_with_core "$tmpcore" --no-userinit --no-sysinit \
27 --eval "(setf sb-ext:*evaluator-mode* :${TEST_SBCL_EVALUATOR_MODE:-compile})"
28 check_status_maybe_lose "SAVE-LISP-AND-DIE :TOPLEVEL" $? 0 "(saved core ran)"
30 # In sbcl-0.7.7 SAVE-LISP-AND-DIE didn't work at all because of
31 # flakiness caused by consing/GC/purify twice-and-at-least-twice
32 # mismatch grot.
34 # "serves yall right for fiddling with too much stuff"
35 # -- Eric Marsden, <http://tunes.org/~nef/logs/lisp/02.09.15>
37 # diagnosed and fixed by Dan Barlow in sbcl-0.7.7.29
38 run_sbcl <<EOF
39 (defun foo (x) (+ x 11))
40 (save-lisp-and-die "$tmpcore")
41 EOF
42 run_sbcl_with_core "$tmpcore" --no-userinit --no-sysinit \
43 --eval "(setf sb-ext:*evaluator-mode* :${TEST_SBCL_EVALUATOR_MODE:-compile})" \
44 <<EOF
45 (exit :code (foo 10))
46 EOF
47 check_status_maybe_lose "Basic SAVE-LISP-AND-DIE" $? 21 "(saved core ran)"
49 # In sbcl-0.9.8 saving cores with callbacks didn't work on gencgc platforms
50 run_sbcl <<EOF
51 (defun bar ()
52 (format t "~&Callbacks not supported, skipping~%")
53 (exit :code 42))
54 #+alien-callbacks
55 (progn
56 (sb-alien::define-alien-callback foo int () 42)
57 (defun bar () (exit :code (alien-funcall foo))))
58 (save-lisp-and-die "$tmpcore")
59 EOF
60 run_sbcl_with_core "$tmpcore" --no-userinit --no-sysinit \
61 --eval "(setf sb-ext:*evaluator-mode* :${TEST_SBCL_EVALUATOR_MODE:-compile})" \
62 <<EOF
63 (bar)
64 EOF
65 check_status_maybe_lose "Callbacks after SAVE-LISP-AND-DIE" $? \
66 42 "(callback function ran)"
68 # test suppression of banner in executable cores
69 run_sbcl <<EOF
70 (save-lisp-and-die "$tmpcore" :executable t)
71 EOF
72 chmod u+x "$tmpcore"
73 ./"$tmpcore" > "$tmpoutput" --no-userinit --no-sysinit --noprint <<EOF
74 (exit :code 71)
75 EOF
76 status=$?
77 if [ $status != 71 ]; then
78 echo "failure in banner suppression: $status"
79 exit 1
80 elif [ -s "$tmpoutput" ]; then
81 echo "failure in banner suppression: nonempty output:"
82 echo ---
83 cat "$tmpoutput"
84 echo ---
85 exit 1
86 elif [ -f "$tmpoutput" ]; then
87 echo "/Executable suppressed banner, good."
88 else
89 echo "failure in banner suppression: $tmpoutput was not created or something funny happened."
90 exit 1
93 # saving runtime options _from_ executable cores
94 run_sbcl <<EOF
95 (save-lisp-and-die "$tmpcore" :executable t)
96 EOF
97 chmod u+x "$tmpcore"
98 ./"$tmpcore" --no-userinit <<EOF
99 (save-lisp-and-die "$tmpcore" :executable t :save-runtime-options t)
101 chmod u+x "$tmpcore"
102 ./"$tmpcore" --no-userinit --version --eval '(exit)' <<EOF
103 (when (equal *posix-argv* '("./$tmpcore" "--version" "--eval" "(exit)"))
104 (exit :code 42))
106 status=$?
107 if [ $status != 42 ]; then
108 echo "saving runtime options from executable failed"
109 exit 1
112 rm "$tmpcore"
113 run_sbcl <<EOF
114 (save-lisp-and-die "$tmpcore" :toplevel (lambda () 42)
115 :compression (and (member :sb-core-compression *features*) t))
117 run_sbcl_with_core "$tmpcore" --no-userinit --no-sysinit \
118 --eval "(setf sb-ext:*evaluator-mode* :${TEST_SBCL_EVALUATOR_MODE:-compile})"
119 check_status_maybe_lose "SAVE-LISP-AND-DIE :COMPRESS" $? 0 "(compressed saved core ran)"
121 rm "$tmpcore"
122 run_sbcl <<EOF
123 (save-lisp-and-die "$tmpcore" :toplevel (lambda () 42) :executable t
124 :compression (and (member :sb-core-compression *features*) t))
126 chmod u+x "$tmpcore"
127 ./"$tmpcore" --no-userinit --no-sysinit
128 check_status_maybe_lose "SAVE-LISP-AND-DIE :EXECUTABLE-COMPRESS" $? 0 "(executable compressed saved core ran)"
130 exit $EXIT_TEST_WIN