A test no longer fails.
[sbcl.git] / tests / elf-sans-immobile.test.sh
blob0117b1763bc98995952607bc36e26dea2c28681f
1 #!/bin/sh
3 # tests related to ELFinated .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 run_sbcl <<EOF
19 #+(and linux x86-64 sb-thread)
20 (unless (member :immobile-space sb-impl:+internal-features+)
21 (exit :code 0)) ; proceed with test
22 (exit :code 2) ; otherwise skip the test
23 EOF
24 status=$?
25 if [ $status != 0 ]; then # test can't be executed
26 # we don't have a way to exit shell tests with "inapplicable" as the result
27 exit $EXIT_TEST_WIN
30 set -e # exit on error
32 create_test_subdirectory
33 temp=$TEST_DIRECTORY/$TEST_FILESTEM
35 run_sbcl --load ../tools-for-build/elftool \
36 --eval '(sb-editcore:move-dynamic-code-to-text-space "../output/sbcl.core" "'${temp}'-patched.core")' \
37 --eval '(sb-editcore:redirect-text-space-calls "'${temp}'-patched.core")' \
38 --eval '(sb-editcore:split-core "'${temp}'-patched.core" "'${temp}'-src.s")' --quit
40 m_arg=`run_sbcl --eval '(progn #+sb-core-compression (princ " -lzstd") #+x86 (princ " -m32"))' --quit`
42 (cd ../src/runtime ; make libsbcl.a)
43 exefile=$TEST_DIRECTORY/sbcl-new-elf
44 cc -no-pie -o ${exefile} -Wl,--export-dynamic -Wl,-no-as-needed \
45 ${temp}-src.s ${temp}-src-core.o ../src/runtime/libsbcl.a -lm -ldl ${m_arg}
47 result=`${exefile} --eval '(princ "Success")' --quit`
48 echo $result
49 if [ "$result" = Success ]
50 then
51 echo "basic ELF: smoke test PASS"
52 else
53 exit 1
55 result=`${exefile} --eval '(defun fib (n) (if (<= n 1) 1 (+ (fib (- n 1)) (fib (- n 2)))))' \
56 --eval "(compile 'fib)" \
57 --eval "(if (equal (loop for i from 2 to 5 collect (fib i)) '(2 3 5 8)) (print 'ok))" --quit`
58 if [ $result = OK ]
59 then
60 echo "COMPILE: PASS"
61 else
62 exit 1
65 set +e # no exit on error
66 ${exefile} --noprint n<<EOF
67 (in-package sb-impl)
68 (defun disassembly-contains-query-read-char ()
69 (search "FDEFN QUERY-READ-CHAR"
70 (with-output-to-string (ss) (disassemble 'y-or-n-p :stream ss))))
71 (assert (not (disassembly-contains-query-read-char)))
72 (defun query-read-char () #\y) ; will undo static linkage
73 (assert (disassembly-contains-query-read-char))
74 (if (let ((*query-io* (make-broadcast-stream))) (y-or-n-p)) (exit :code 42))
75 EOF
76 status=$?
77 if [ $status -eq 42 ]
78 then
79 echo
80 echo "Undo static linkage: PASS"
81 else
82 exit 1
85 exit $EXIT_TEST_WIN