From: Nikodemus Siivola Date: Wed, 24 Aug 2011 12:35:36 +0000 (+0300) Subject: test for multiply-interrupted sleeps X-Git-Url: http://repo.macrolet.net/gitweb/?a=commitdiff_plain;h=e62bb3a4b9633dbd898fca05cc4af3dd0a16e0aa;p=sbcl.git test for multiply-interrupted sleeps Make sure the time take by the interrupt is tallied correctly. --- diff --git a/tests/signals.impure.lisp b/tests/signals.impure.lisp index 093bf23..1cb5fd3 100644 --- a/tests/signals.impure.lisp +++ b/tests/signals.impure.lisp @@ -81,3 +81,19 @@ (sb-ext:with-timeout 0.1 (sleep 1) t)))) (sb-ext:timeout () nil)))) + +(with-test (:name :sleep-many-interrupts) + (let ((n 0) + (timer nil)) + (flet ((trip () + (when (< (incf n) 5) + (sleep 0.1) + (schedule-timer timer 0.1)))) + (setf timer (make-timer #'trip)) + (schedule-timer timer 0.1) + (let ((start (get-internal-real-time))) + (sleep 1.5) + (let ((ticks (/ (float (- (get-internal-real-time) start)) + internal-time-units-per-second))) + (assert (< 1.4 ticks 1.6)) + (assert (= n 5)))))))