at master 4.4 kB view raw
1From 979a92d10731bae90e611b98d29be8d187f0f1f8 Mon Sep 17 00:00:00 2001 2From: Hraban Luyat <hraban@0brg.net> 3Date: Sat, 13 Apr 2024 15:39:58 -0400 4Subject: [PATCH 2/2] test: dynamic space size envvar and precedence 5 6--- 7 tests/memory-args.test.sh | 22 ++++++++++++++++++ 8 tests/save7.test.sh | 49 ++++++++++++++++++++++++++++++++++----- 9 2 files changed, 65 insertions(+), 6 deletions(-) 10 create mode 100755 tests/memory-args.test.sh 11 12diff --git a/tests/memory-args.test.sh b/tests/memory-args.test.sh 13new file mode 100755 14index 000000000..72ef0cc79 15--- /dev/null 16+++ b/tests/memory-args.test.sh 17@@ -0,0 +1,22 @@ 18+#!/bin/sh 19+ 20+. ./subr.sh 21+ 22+use_test_subdirectory 23+ 24+set -e 25+ 26+# Allow slight shrinkage if heap relocation has to adjust for alignment 27+NIX_SBCL_DYNAMIC_SPACE_SIZE=234mb run_sbcl_with_args --script <<EOF 28+(assert (<= 0 (- (* 234 1024 1024) (sb-ext:dynamic-space-size)) 65536)) 29+EOF 30+ 31+NIX_SBCL_DYNAMIC_SPACE_SIZE=555mb run_sbcl_with_args --dynamic-space-size 234mb --script <<EOF 32+(assert (<= 0 (- (* 234 1024 1024) (sb-ext:dynamic-space-size)) 65536)) 33+EOF 34+ 35+run_sbcl_with_args --dynamic-space-size 234mb --script <<EOF 36+(assert (<= 0 (- (* 234 1024 1024) (sb-ext:dynamic-space-size)) 65536)) 37+EOF 38+ 39+exit $EXIT_TEST_WIN 40diff --git a/tests/save7.test.sh b/tests/save7.test.sh 41index dd112f220..d56bddbc2 100644 42--- a/tests/save7.test.sh 43+++ b/tests/save7.test.sh 44@@ -25,6 +25,9 @@ echo "::: Success" 45 46 run_sbcl_with_args --noinform --control-stack-size 384KB --dynamic-space-size 260MB \ 47 --disable-debugger --no-userinit --no-sysinit --noprint <<EOF 48+ ; allow slight shrinkage if heap relocation has to adjust for alignment 49+ (defun dynamic-space-size-good-p (expected-mb) 50+ (<= 0 (- (* expected-mb 1024 1024) (dynamic-space-size)) 65536)) 51 (save-lisp-and-die "$tmpcore" :executable t :save-runtime-options :accept-runtime-options) 52 EOF 53 chmod u+x "$tmpcore" 54@@ -57,6 +60,29 @@ if [ $? -ne 0 ]; then 55 fi 56 echo "::: Success" 57 58+echo "::: Running :DYNAMIC-SPACE-SIZE-ENV-ACCEPT" 59+NIX_SBCL_DYNAMIC_SPACE_SIZE=432MB ./"$tmpcore" --no-userinit --no-sysinit --noprint <<EOF 60+ (when (dynamic-space-size-good-p 432) 61+ (exit :code 42)) 62+EOF 63+if [ $? -ne 42 ]; then 64+ exit 1 65+fi 66+echo "::: Success" 67+ 68+echo "::: Running :DYNAMIC-SPACE-SIZE-PRECEDENCE" 69+NIX_SBCL_DYNAMIC_SPACE_SIZE=432MB ./"$tmpcore" --dynamic-space-size 333MB \ 70+ --no-userinit --no-sysinit --noprint <<EOF 71+ (when (dynamic-space-size-good-p 333)) 72+ (exit :code 42)) 73+EOF 74+status=$? 75+if [ $status -ne 42 ]; then 76+ echo "saved core should have prioritized memory specification from arg" 77+ exit 1 78+fi 79+echo "::: Success" 80+ 81 echo "::: Running :DYNAMIC-SPACE-SIZE-ARG" 82 run_sbcl_with_core "$tmpcore" --noinform --control-stack-size 640KB \ 83 --tls-limit 5000 \ 84@@ -64,10 +90,7 @@ run_sbcl_with_core "$tmpcore" --noinform --control-stack-size 640KB \ 85 (assert (eql (extern-alien "thread_control_stack_size" unsigned) (* 640 1024))) 86 (assert (eql (extern-alien "dynamic_values_bytes" (unsigned 32)) 87 (* 5000 sb-vm:n-word-bytes))) 88- ; allow slight shrinkage if heap relocation has to adjust for alignment 89- (defun dynamic-space-size-good-p () 90- (<= 0 (- (* 260 1048576) (dynamic-space-size)) 65536)) 91- (assert (dynamic-space-size-good-p)) 92+ (assert (dynamic-space-size-good-p 260)) 93 (save-lisp-and-die "${tmpcore}2" :executable t :save-runtime-options t) 94 EOF 95 chmod u+x "${tmpcore}2" 96@@ -76,15 +99,29 @@ echo "::: INFO: prepared test core" 97 (when (and (eql (extern-alien "thread_control_stack_size" unsigned) (* 640 1024)) 98 (eql (extern-alien "dynamic_values_bytes" (unsigned 32)) 99 (* 5000 sb-vm:n-word-bytes)) 100- (dynamic-space-size-good-p)) 101+ (dynamic-space-size-good-p 260)) 102 (exit :code 42)) 103 EOF 104 status=$? 105-rm "$tmpcore" "${tmpcore}2" 106 if [ $status -ne 42 ]; then 107 echo "re-saved executable used wrong memory size options" 108 exit 1 109 fi 110 echo "::: Success" 111 112+echo "::: Running :DYNAMIC-SPACE-SIZE-ENV-IGNORE" 113+NIX_SBCL_DYNAMIC_SPACE_SIZE=432MB ./"${tmpcore}2" --no-userinit --no-sysinit --noprint <<EOF 114+ (when (dynamic-space-size-good-p 260) 115+ (exit :code 42)) 116+EOF 117+status=$? 118+if [ $status -ne 42 ]; then 119+ echo "re-saved executable should have ignored memory specification from env" 120+ exit 1 121+fi 122+echo "::: Success" 123+rm "$tmpcore" "${tmpcore}2" 124+ 125+ 126+ 127 exit $EXIT_TEST_WIN 128-- 1292.48.1 130