one more stray GENSYM leading to fasl differences
[sbcl.git] / tests / core.test.sh
blob02d3d4726dffd41b79dab4640cd8d0cd4157d564
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 check_status_maybe_lose "SAVE-LISP-AND-DIE :TOPLEVEL" $? 0 "(saved core ran)"
29 # In sbcl-0.7.7 SAVE-LISP-AND-DIE didn't work at all because of
30 # flakiness caused by consing/GC/purify twice-and-at-least-twice
31 # mismatch grot.
33 # "serves yall right for fiddling with too much stuff"
34 # -- Eric Marsden, <http://tunes.org/~nef/logs/lisp/02.09.15>
36 # diagnosed and fixed by Dan Barlow in sbcl-0.7.7.29
37 run_sbcl <<EOF
38 (defun foo (x) (+ x 11))
39 (save-lisp-and-die "$tmpcore")
40 EOF
41 run_sbcl_with_core "$tmpcore" --no-userinit --no-sysinit <<EOF
42 (exit :code (foo 10))
43 EOF
44 check_status_maybe_lose "Basic SAVE-LISP-AND-DIE" $? 21 "(saved core ran)"
46 # In sbcl-0.9.8 saving cores with callbacks didn't work on gencgc platforms
47 run_sbcl <<EOF
48 (defun bar ()
49 (format t "~&Callbacks not supported, skipping~%")
50 (exit :code 42))
51 #+alien-callbacks
52 (progn
53 (sb-alien::define-alien-callback foo int () 42)
54 (defun bar () (exit :code (alien-funcall foo))))
55 (save-lisp-and-die "$tmpcore")
56 EOF
57 run_sbcl_with_core "$tmpcore" --no-userinit --no-sysinit <<EOF
58 (bar)
59 EOF
60 check_status_maybe_lose "Callbacks after SAVE-LISP-AND-DIE" $? \
61 42 "(callback function ran)"
63 # test suppression of banner in executable cores
64 run_sbcl <<EOF
65 (save-lisp-and-die "$tmpcore" :executable t)
66 EOF
67 chmod u+x "$tmpcore"
68 ./"$tmpcore" > "$tmpoutput" --no-userinit --no-sysinit --noprint <<EOF
69 (exit :code 71)
70 EOF
71 status=$?
72 if [ $status != 71 ]; then
73 echo "failure in banner suppression: $status"
74 exit 1
75 elif [ -s "$tmpoutput" ]; then
76 echo "failure in banner suppression: nonempty output:"
77 echo ---
78 cat "$tmpoutput"
79 echo ---
80 exit 1
81 elif [ -f "$tmpoutput" ]; then
82 echo "/Executable suppressed banner, good."
83 else
84 echo "failure in banner suppression: $tmpoutput was not created or something funny happened."
85 exit 1
88 # saving runtime options _from_ executable cores
89 run_sbcl <<EOF
90 (save-lisp-and-die "$tmpcore" :executable t)
91 EOF
92 chmod u+x "$tmpcore"
93 ./"$tmpcore" --no-userinit <<EOF
94 (save-lisp-and-die "$tmpcore" :executable t :save-runtime-options t)
95 EOF
96 chmod u+x "$tmpcore"
97 ./"$tmpcore" --no-userinit --version --eval '(exit)' <<EOF
98 (when (equal *posix-argv* '("./$tmpcore" "--version" "--eval" "(exit)"))
99 (exit :code 42))
101 status=$?
102 if [ $status != 42 ]; then
103 echo "saving runtime options from executable failed"
104 exit 1
107 rm "$tmpcore"
108 run_sbcl <<EOF
109 (save-lisp-and-die "$tmpcore" :toplevel (lambda () 42)
110 :compression (and (member :sb-core-compression *features*) t))
112 run_sbcl_with_core "$tmpcore" --no-userinit --no-sysinit
113 check_status_maybe_lose "SAVE-LISP-AND-DIE :COMPRESS" $? 0 "(compressed saved core ran)"
115 rm "$tmpcore"
116 run_sbcl <<EOF
117 (save-lisp-and-die "$tmpcore" :toplevel (lambda () 42) :executable t
118 :compression (and (member :sb-core-compression *features*) t))
120 chmod u+x "$tmpcore"
121 ./"$tmpcore" --no-userinit --no-sysinit
122 check_status_maybe_lose "SAVE-LISP-AND-DIE :EXECUTABLE-COMPRESS" $? 0 "(executable compressed saved core ran)"
124 exit $EXIT_TEST_WIN