at master 3.5 kB view raw
1From 9d4a886a8a76ea8be51bcf754cefacdf30986f46 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 | 37 ++++++++++++++++++++++++++++++++----- 9 2 files changed, 54 insertions(+), 5 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 f9225543b..3c35e7b31 100644 42--- a/tests/save7.test.sh 43+++ b/tests/save7.test.sh 44@@ -59,9 +59,9 @@ run_sbcl_with_core "$tmpcore" --noinform --control-stack-size 640KB \ 45 (assert (eql (extern-alien "dynamic_values_bytes" (unsigned 32)) 46 (* 5000 sb-vm:n-word-bytes))) 47 ; allow slight shrinkage if heap relocation has to adjust for alignment 48- (defun dynamic-space-size-good-p () 49- (<= 0 (- (* 260 1048576) (dynamic-space-size)) 65536)) 50- (assert (dynamic-space-size-good-p)) 51+ (defun dynamic-space-size-good-p (expected-mb) 52+ (<= 0 (- (* expected-mb 1024 1024) (dynamic-space-size)) 65536)) 53+ (assert (dynamic-space-size-good-p 260)) 54 (save-lisp-and-die "${tmpcore}2" :executable t :save-runtime-options t) 55 EOF 56 chmod u+x "${tmpcore}2" 57@@ -70,15 +70,42 @@ echo "::: INFO: prepared test core" 58 (when (and (eql (extern-alien "thread_control_stack_size" unsigned) (* 640 1024)) 59 (eql (extern-alien "dynamic_values_bytes" (unsigned 32)) 60 (* 5000 sb-vm:n-word-bytes)) 61- (dynamic-space-size-good-p)) 62+ (dynamic-space-size-good-p 260)) 63 (exit :code 42)) 64 EOF 65 status=$? 66-rm "$tmpcore" "${tmpcore}2" 67 if [ $status -ne 42 ]; then 68 echo "re-saved executable used wrong memory size options" 69 exit 1 70 fi 71 echo "::: Success" 72 73+echo "::: Running :DYNAMIC-SPACE-SIZE-ENV" 74+NIX_SBCL_DYNAMIC_SPACE_SIZE=432MB ./"${tmpcore}2" --no-userinit --no-sysinit --noprint <<EOF 75+ (when (dynamic-space-size-good-p 432) 76+ (exit :code 42)) 77+EOF 78+status=$? 79+if [ $status -ne 42 ]; then 80+ echo "re-saved executable should have prioritized memory specification from env" 81+ exit 1 82+fi 83+echo "::: Success" 84+ 85+echo "::: Running :DYNAMIC-SPACE-SIZE-PRECEDENCE" 86+NIX_SBCL_DYNAMIC_SPACE_SIZE=432MB ./"${tmpcore}2" --dynamic-space-size 333MB \ 87+ --no-userinit --no-sysinit --noprint <<EOF 88+ (when (dynamic-space-size-good-p 333)) 89+ (exit :code 42)) 90+EOF 91+status=$? 92+rm "$tmpcore" "${tmpcore}2" 93+if [ $status -ne 42 ]; then 94+ echo "re-saved executable should have prioritized memory specification from arg" 95+ exit 1 96+fi 97+echo "::: Success" 98+ 99+ 100+ 101 exit $EXIT_TEST_WIN 102-- 1032.44.0 104