export TEST_BASEDIR=${TMPDIR:-/tmp}
. ./subr.sh
use_test_subdirectory
tmpcore=$TEST_FILESTEM.core
run_sbcl <<EOF
(defun bar ()
(format t "~&Callbacks not supported, skipping~%")
(exit :code 42))
;; The symbol SB-ALIEN::DEFINE-ALIEN-CALLBACK exists (can be read)
;; no matter whether support for it exists.
(when (member :alien-callbacks sb-impl:+internal-features+)
(fmakunbound 'bar)
(sb-alien::define-alien-callback foo int () 42)
(defun bar () (exit :code (alien-funcall foo))))
(save-lisp-and-die "$tmpcore")
EOF
run_sbcl_with_core "$tmpcore" --noinform --no-userinit --no-sysinit --noprint \
--eval "(setf sb-ext:*evaluator-mode* :${TEST_SBCL_EVALUATOR_MODE:-compile})" \
<<EOF
(bar)
EOF
check_status_maybe_lose "Callbacks after SAVE-LISP-AND-DIE" $? \
42 "(callback function ran)"
exit $EXIT_TEST_WIN