about summary refs log tree commit diff
path: root/pkgs/development/compilers/sbcl/dynamic-space-size-envvar-tests.patch
blob: 1a507cc90381a14ff75df7b6024dbdc2c7b20c6a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
From 9d4a886a8a76ea8be51bcf754cefacdf30986f46 Mon Sep 17 00:00:00 2001
From: Hraban Luyat <hraban@0brg.net>
Date: Sat, 13 Apr 2024 15:39:58 -0400
Subject: [PATCH 2/2] test: dynamic space size envvar and precedence

---
 tests/memory-args.test.sh | 22 ++++++++++++++++++++++
 tests/save7.test.sh       | 37 ++++++++++++++++++++++++++++++++-----
 2 files changed, 54 insertions(+), 5 deletions(-)
 create mode 100755 tests/memory-args.test.sh

diff --git a/tests/memory-args.test.sh b/tests/memory-args.test.sh
new file mode 100755
index 000000000..72ef0cc79
--- /dev/null
+++ b/tests/memory-args.test.sh
@@ -0,0 +1,22 @@
+#!/bin/sh
+
+. ./subr.sh
+
+use_test_subdirectory
+
+set -e
+
+# Allow slight shrinkage if heap relocation has to adjust for alignment
+NIX_SBCL_DYNAMIC_SPACE_SIZE=234mb run_sbcl_with_args --script <<EOF
+(assert (<= 0 (- (* 234 1024 1024) (sb-ext:dynamic-space-size)) 65536))
+EOF
+
+NIX_SBCL_DYNAMIC_SPACE_SIZE=555mb run_sbcl_with_args --dynamic-space-size 234mb --script <<EOF
+(assert (<= 0 (- (* 234 1024 1024) (sb-ext:dynamic-space-size)) 65536))
+EOF
+
+run_sbcl_with_args --dynamic-space-size 234mb --script <<EOF
+(assert (<= 0 (- (* 234 1024 1024) (sb-ext:dynamic-space-size)) 65536))
+EOF
+
+exit $EXIT_TEST_WIN
diff --git a/tests/save7.test.sh b/tests/save7.test.sh
index f9225543b..3c35e7b31 100644
--- a/tests/save7.test.sh
+++ b/tests/save7.test.sh
@@ -59,9 +59,9 @@ run_sbcl_with_core "$tmpcore" --noinform --control-stack-size 640KB \
   (assert (eql (extern-alien "dynamic_values_bytes" (unsigned 32))
                (* 5000 sb-vm:n-word-bytes)))
   ; allow slight shrinkage if heap relocation has to adjust for alignment
-  (defun dynamic-space-size-good-p ()
-    (<= 0 (- (* 260 1048576) (dynamic-space-size)) 65536))
-  (assert (dynamic-space-size-good-p))
+  (defun dynamic-space-size-good-p (expected-mb)
+    (<= 0 (- (* expected-mb 1024 1024) (dynamic-space-size)) 65536))
+  (assert (dynamic-space-size-good-p 260))
   (save-lisp-and-die "${tmpcore}2" :executable t :save-runtime-options t)
 EOF
 chmod u+x "${tmpcore}2"
@@ -70,15 +70,42 @@ echo "::: INFO: prepared test core"
   (when (and (eql (extern-alien "thread_control_stack_size" unsigned) (* 640 1024))
              (eql (extern-alien "dynamic_values_bytes" (unsigned 32))
                   (* 5000 sb-vm:n-word-bytes))
-             (dynamic-space-size-good-p))
+             (dynamic-space-size-good-p 260))
     (exit :code 42))
 EOF
 status=$?
-rm "$tmpcore" "${tmpcore}2"
 if [ $status -ne 42 ]; then
     echo "re-saved executable used wrong memory size options"
     exit 1
 fi
 echo "::: Success"
 
+echo "::: Running :DYNAMIC-SPACE-SIZE-ENV"
+NIX_SBCL_DYNAMIC_SPACE_SIZE=432MB ./"${tmpcore}2" --no-userinit --no-sysinit --noprint <<EOF
+  (when (dynamic-space-size-good-p 432)
+    (exit :code 42))
+EOF
+status=$?
+if [ $status -ne 42 ]; then
+    echo "re-saved executable should have prioritized memory specification from env"
+    exit 1
+fi
+echo "::: Success"
+
+echo "::: Running :DYNAMIC-SPACE-SIZE-PRECEDENCE"
+NIX_SBCL_DYNAMIC_SPACE_SIZE=432MB ./"${tmpcore}2" --dynamic-space-size 333MB \
+  --no-userinit --no-sysinit --noprint <<EOF
+  (when (dynamic-space-size-good-p 333))
+    (exit :code 42))
+EOF
+status=$?
+rm "$tmpcore" "${tmpcore}2"
+if [ $status -ne 42 ]; then
+    echo "re-saved executable should have prioritized memory specification from arg"
+    exit 1
+fi
+echo "::: Success"
+
+
+
 exit $EXIT_TEST_WIN
-- 
2.44.0