1.0.23.16: more generic assembly op optimizations on x86 and x86-64
[sbcl/tcr.git] / tests / finalize.test.sh
blobe2ef1bcbe9251d62d3b6bb67bcf1a6128e722e54
1 #!/bin/sh
3 # This test is as convoluted as it is to avoid having failing tests
4 # hang the test-suite, as the typical failure mode used to be SBCL
5 # hanging uninterruptible in GC.
7 . ./subr.sh
9 use_test_subdirectory
11 echo //entering finalize.test.sh
13 run_sbcl <<EOF > /dev/null &
14 (defvar *tmp* 0.0)
15 (defvar *count* 0)
17 (defun foo (_)
18 (declare (ignore _))
19 nil)
21 (let ((junk (mapcar (compile nil '(lambda (_)
22 (declare (ignore _))
23 (let ((x (gensym)))
24 (finalize x (lambda ()
25 ;; cons in finalizer
26 (setf *tmp* (make-list 10000))
27 (incf *count*)))
28 x)))
29 (make-list 10000))))
30 (setf junk (foo junk))
31 (foo junk))
33 (gc :full t)
34 (gc :full t)
36 (if (= *count* 10000)
37 (with-open-file (f "finalize-test-passed" :direction :output)
38 (write-line "OK" f))
39 (with-open-file (f "finalize-test-failed" :direction :output)
40 (format f "OOPS: ~A~%" *count*)))
42 (sb-ext:quit)
43 EOF
45 SBCL_PID=$!
46 WAITED=x
48 echo "Waiting for SBCL to finish stress-testing finalizers"
49 while true; do
50 if [ -f finalize-test-passed ]; then
51 echo "OK"
52 rm finalize-test-passed
53 exit $EXIT_TEST_WIN
54 elif [ -f finalize-test-failed ]; then
55 echo "Failed"
56 rm finalize-test-failed
57 exit $EXIT_LOSE
59 sleep 1
60 WAITED="x$WAITED"
61 if [ $WAITED = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" ]; then
62 echo
63 echo "timeout, killing SBCL"
64 kill -9 $SBCL_PID
65 exit $EXIT_LOSE # Failure, SBCL probably hanging in GC
67 done