From e62bb3a4b9633dbd898fca05cc4af3dd0a16e0aa Mon Sep 17 00:00:00 2001 From: Nikodemus Siivola Date: Wed, 24 Aug 2011 15:35:36 +0300 Subject: [PATCH] test for multiply-interrupted sleeps Make sure the time take by the interrupt is tallied correctly. --- tests/signals.impure.lisp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) 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))))))) -- 1.7.10.4