summaryrefslogtreecommitdiffstats
path: root/tests/012
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2021-07-14 06:13:02 -0700
committerKaz Kylheku <kaz@kylheku.com>2021-07-14 06:13:02 -0700
commit1bdccc66b8af56dc408b57b2b5842f5d5d7af5b7 (patch)
tree336cc011723f6a5a2879cb3107bdbe38c504d22d /tests/012
parent673489d49890bfdaffdd30246266eea97365d487 (diff)
downloadtxr-1bdccc66b8af56dc408b57b2b5842f5d5d7af5b7.tar.gz
txr-1bdccc66b8af56dc408b57b2b5842f5d5d7af5b7.tar.bz2
txr-1bdccc66b8af56dc408b57b2b5842f5d5d7af5b7.zip
tests: fix stack overflow test case for old gmake.
* tests/012/stack.tl: The (if stack-limited ...) test is not correct because even if gerlimit indicates an unlimited stack, we impose a defualt limit, and so (get-stack-limit) returns a an integer value. The idea here was to try to skip this test case when the stack usage is unlmited, which happens under older versions of GNU make, before posix_spawn was introduced. Instead, let's execute this test case only if we have setrlimit. In the forked child, we try to impose a small stack limit that will give use the stack overflow crash we are testing for. The objective of the test case is to validate that when (set-stack-limit 0) is called, the child will abort due to a signal, rather than (recur) returning :so.
Diffstat (limited to 'tests/012')
-rw-r--r--tests/012/stack.tl9
1 files changed, 7 insertions, 2 deletions
diff --git a/tests/012/stack.tl b/tests/012/stack.tl
index 62df252b..b3cea078 100644
--- a/tests/012/stack.tl
+++ b/tests/012/stack.tl
@@ -10,10 +10,15 @@
(test (so (recur)) :so)
-(if stack-limited
+(if (fboundp 'setrlimit)
(test (let ((pid (fork)))
(cond
- ((zerop pid) (set-stack-limit 0) (recur))
+ ((zerop pid)
+ (set-stack-limit 0)
+ (let ((rlim (getrlimit rlimit-stack)))
+ (set rlim.cur 32768)
+ (setrlimit rlimit-stack rlim))
+ (recur))
(t (let ((status (wait pid)))
(w-ifsignaled status)))))
t))