[04d819]: tests / finalize.test.sh Maximize Restore History

Download this file

finalize.test.sh    67 lines (55 with data), 1.7 kB

 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
#!/bin/sh
#
# This test is as convoluted as it is to avoid having failing tests
# hang the test-suite, as the typical failure mode used to be SBCL
# hanging uninterruptible in GC.
echo //entering finalize.test.sh
rm -f finalize-test-passed finalize-test-failed
${SBCL:-sbcl} <<EOF > /dev/null &
(defvar *tmp* 0.0)
(defvar *count* 0)
(defun foo (_)
(declare (ignore _))
nil)
(let ((junk (mapcar (lambda (_)
(declare (ignore _))
(let ((x (gensym)))
(finalize x (lambda ()
;; cons in finalizer
(setf *tmp* (make-list 10000))
(incf *count*)))
x))
(make-list 10000))))
(setf junk (foo junk))
(foo junk))
(gc :full t)
(gc :full t)
(if (= *count* 10000)
(with-open-file (f "finalize-test-passed" :direction :output)
(write-line "OK" f))
(with-open-file (f "finalize-test-failed" :direction :output)
(format f "OOPS: ~A~%" *count*)))
(sb-ext:quit)
EOF
SBCL_PID=$!
WAITED=0
echo "Waiting for SBCL to finish stress-testing finalizers"
while true; do
if [ -f finalize-test-passed ]; then
echo "OK"
rm finalize-test-passed
exit 104 # Success
elif [ -f finalize-test-failed ]; then
echo "Failed"
rm finalize-test-failed
exit 1 # Failure
fi
sleep 1
WAITED=$(($WAITED+1))
if (($WAITED>60)); then
echo
echo "timeout, killing SBCL"
kill -9 $SBCL_PID
exit 1 # Failure, SBCL probably hanging in GC
fi
done