1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-04-30 03:40:34 +02:00
guile/test-suite/standalone/test-stack-overflow
Mike Gran 24da8084ad Cygwin: skip tests that require working setrlimits for memory
On Cygwin, setrlimits cannot be used to set total memory availabe
for a process.

* test-suite/standalone/test-out-of-memory: skip for cygwin
* test-suite/standalone/test-stack-overflow: skip for cygwin
2017-03-03 09:44:10 -08:00

54 lines
1.5 KiB
Scheme
Executable file

#!/bin/sh
guild compile "$0"
exec guile -q -s "$0" "$@"
!#
(unless (defined? 'setrlimit)
;; Without an rlimit, this test can take down your system, as it
;; consumes all of your memory in stack space. That doesn't seem like
;; something we should run as part of an automated test suite.
(exit 0))
(when (string-ci= "darwin" (vector-ref (uname) 0))
;; setrlimits are ignored in OS X (tested on 10.9 and 10.10). Proceeding
;; with the test would fill all available memory and probably end in a crash.
;; See also test-out-of-memory.
(exit 77)) ; uresolved
(when (string-contains-ci (vector-ref (uname) 0) "CYGWIN_NT")
;; attempting to use setrlimits for memory RLIMIT_AS will always
;; produce an invalid argument error on Cygwin (tested on
;; CYGWIN_NT-10.0 DLL v2.7.0). Proceeding with the test would fill
;; all available memory and probably end in a crash. See also
;; test-out-of-memory.
(exit 77)) ; unresolved
;; 100 MB.
(define *limit* (* 100 1024 1024))
(call-with-values (lambda () (getrlimit 'as))
(lambda (soft hard)
(unless (and soft (< soft *limit*))
(setrlimit 'as (if hard (min *limit* hard) *limit*) hard))))
(define (test)
(catch 'stack-overflow
(lambda ()
(let lp ()
(lp)
(error "should not be reached")))
(lambda _
#t)))
;; Run the test a few times. The stack will only be enlarged and
;; relocated on the first one.
(test)
(test)
(test)
(test)
(test)
;; Local Variables:
;; mode: scheme
;; End: