5 tmpcore
=$TEST_FILESTEM.core
7 echo "::: Running :SAVE-CORE-MEM-SIZES"
8 # executable core used as "--core" option should not save the memory sizes
9 # that were originally saved, but the sizes in the process doing the save.
10 run_sbcl_with_args
--noinform --control-stack-size 384KB
--dynamic-space-size 260MB \
11 --disable-debugger --no-userinit --no-sysinit --noprint <<EOF
12 (save-lisp-and-die "$tmpcore" :executable t :save-runtime-options t)
15 echo "::: INFO: prepared test core"
16 .
/"$tmpcore" --no-userinit --no-sysinit --noprint <<EOF
17 (assert (eql (extern-alien "thread_control_stack_size" unsigned) (* 384 1024)))
18 ; allow slight shrinkage if heap relocation has to adjust for alignment
19 (assert (<= 0 (- (* 260 1048576) (dynamic-space-size)) 65536))
26 echo "::: Running :ALWAYS-ACCEPT-MEMORY-SIZES"
27 # next, check that tmpcore will accept memory size options.
28 # Use --control-stack-size for the test, since we don't know the valid range
29 # of dynamic space size for the OS/arch.
30 # Test that we find the arg in the midst of the command-line args as well.
31 .
/"$tmpcore" --no-userinit --control-stack-size 3MB
--no-sysinit --noprint <<EOF
32 (assert (eql (extern-alien "thread_control_stack_size" unsigned) (* 3 1048576)))
39 echo "::: Running :DASH-DASH-STOP-PARSING"
40 # Test that we don't parse after a "--"
41 .
/"$tmpcore" --no-userinit --no-sysinit --noprint -- --dynamic-space-size 1000GB foo
<<EOF
42 (let* ((end (sb-vm::current-thread-offset-sap sb-vm::thread-control-stack-end-slot))
43 (start (sb-vm::current-thread-offset-sap sb-vm::thread-control-stack-start-slot))
44 (diff (sb-sys:sap- end start)))
45 ;; We better not have gotten a terabyte of dynamic space!
46 (assert (< diff (* 8 1024 1024 1024))) ; assert less than 8GB
47 (assert (find "--" sb-ext:*posix-argv* :test 'string=)))
54 echo "::: Running :DYNAMIC-SPACE-SIZE-ARG"
55 run_sbcl_with_core
"$tmpcore" --noinform --control-stack-size 640KB \
57 --dynamic-space-size 260MB
--no-userinit --no-sysinit --noprint <<EOF
58 (assert (eql (extern-alien "thread_control_stack_size" unsigned) (* 640 1024)))
59 (assert (eql (extern-alien "dynamic_values_bytes" (unsigned 32))
60 (* 5000 sb-vm:n-word-bytes)))
61 ; allow slight shrinkage if heap relocation has to adjust for alignment
62 (defun dynamic-space-size-good-p ()
63 (<= 0 (- (* 260 1048576) (dynamic-space-size)) 65536))
64 (assert (dynamic-space-size-good-p))
65 (save-lisp-and-die "${tmpcore}2" :executable t :save-runtime-options t)
67 chmod u
+x
"${tmpcore}2"
68 echo "::: INFO: prepared test core"
69 .
/"${tmpcore}2" --no-userinit --no-sysinit --noprint <<EOF
70 (when (and (eql (extern-alien "thread_control_stack_size" unsigned) (* 640 1024))
71 (eql (extern-alien "dynamic_values_bytes" (unsigned 32))
72 (* 5000 sb-vm:n-word-bytes))
73 (dynamic-space-size-good-p))
77 rm "$tmpcore" "${tmpcore}2"
78 if [ $status -ne 42 ]; then
79 echo "re-saved executable used wrong memory size options"