1.0.29.20: fix build breakage from 1.0.29.12 (PPC and MIPS, hopefully)
[sbcl/pkhuong.git] / tests / core.test.sh
blob73936455ab0d1c4a48645da523ba75782f334758
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 (quit :unix-status (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 (quit :unix-status 42))
51 #+alien-callbacks
52 (progn
53 (sb-alien::define-alien-callback foo int () 42)
54 (defun bar () (quit :unix-status (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 (quit :unix-status 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 exit $EXIT_TEST_WIN