X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=tests%2Fdeadline.impure.lisp;h=44990e89a611b4030bac49358fc55f882792d317;hb=829ced3e78a23ba153ba4db64e6ea6984c2313b6;hp=e4b077ed7e18e955b1713dbd611b01eb3136e5f7;hpb=b93cd5f21f8161783f8d40fb6ade28aa04ecf193;p=sbcl.git diff --git a/tests/deadline.impure.lisp b/tests/deadline.impure.lisp index e4b077e..44990e8 100644 --- a/tests/deadline.impure.lisp +++ b/tests/deadline.impure.lisp @@ -15,11 +15,11 @@ (sb-ext:run-program "sleep" (list (format nil "~D" seconds)) :search t :wait t)) -(with-test (:name (:deadline :run-program :trivial)) +(with-test (:name (:deadline :run-program :trivial) :fails-on :win32) (assert-timeout (sb-sys:with-deadline (:seconds 1) (run-sleep 3)))) -(with-test (:name (:deadline :defer-deadline-1)) +(with-test (:name (:deadline :defer-deadline-1) :fails-on :win32) (let ((n 0) (final nil)) (handler-case @@ -35,7 +35,7 @@ (assert (= n 2)) (assert final))) -(with-test (:name (:deadline :defer-deadline-2)) +(with-test (:name (:deadline :defer-deadline-2) :fails-on :win32) (let ((n 0) (final nil)) (handler-case @@ -50,7 +50,7 @@ (assert (plusp n)) (assert (not final)))) -(with-test (:name (:deadline :cancel-deadline)) +(with-test (:name (:deadline :cancel-deadline) :fails-on :win32) (let ((n 0) (final nil)) (handler-case @@ -65,55 +65,52 @@ (assert (= n 1)) (assert (not final)))) -#+(and sb-thread (not sb-lutex)) -(progn - - (with-test (:name (:deadline :get-mutex)) - (assert-timeout - (let ((lock (sb-thread:make-mutex)) - (waitp t)) - (sb-thread:make-thread (lambda () - (sb-thread:get-mutex lock) - (setf waitp nil) - (sleep 5))) - (loop while waitp do (sleep 0.01)) - (sb-sys:with-deadline (:seconds 1) - (sb-thread:get-mutex lock))))) - - (with-test (:name (:deadline :wait-on-semaphore)) - (assert-timeout - (let ((sem (sb-thread::make-semaphore :count 0))) - (sb-sys:with-deadline (:seconds 1) - (sb-thread::wait-on-semaphore sem))))) +(with-test (:name (:deadline :grab-mutex) :skipped-on '(not :sb-thread)) + (assert-timeout + (let ((lock (sb-thread:make-mutex)) + (waitp t)) + (make-join-thread (lambda () + (sb-thread:grab-mutex lock) + (setf waitp nil) + (sleep 5))) + (loop while waitp do (sleep 0.01)) + (sb-sys:with-deadline (:seconds 1) + (sb-thread:grab-mutex lock))))) - (with-test (:name (:deadline :join-thread)) - (assert-timeout +(with-test (:name (:deadline :wait-on-semaphore) :skipped-on '(not :sb-thread)) + (assert-timeout + (let ((sem (sb-thread::make-semaphore :count 0))) (sb-sys:with-deadline (:seconds 1) - (sb-thread:join-thread - (sb-thread:make-thread (lambda () (loop (sleep 1)))))))) + (sb-thread::wait-on-semaphore sem))))) + +(with-test (:name (:deadline :join-thread) :skipped-on '(not :sb-thread)) + (assert-timeout + (sb-sys:with-deadline (:seconds 1) + (sb-thread:join-thread + (make-kill-thread (lambda () (loop (sleep 1)))))))) - (with-test (:name (:deadline :futex-wait-eintr)) - (let ((lock (sb-thread:make-mutex)) - (waitp t)) - (sb-thread:make-thread (lambda () - (sb-thread:get-mutex lock) - (setf waitp nil) - (sleep 5))) - (loop while waitp do (sleep 0.01)) - (let ((thread (sb-thread:make-thread - (lambda () - (let ((start (get-internal-real-time))) - (handler-case - (sb-sys:with-deadline (:seconds 1) - (sb-thread:get-mutex lock)) - (sb-sys:deadline-timeout (x) - (declare (ignore x)) - (let ((end (get-internal-real-time))) - (float (/ (- end start) - internal-time-units-per-second) - 0.0))))))))) - (sleep 0.3) - (sb-thread:interrupt-thread thread (lambda () 42)) - (let ((seconds-passed (sb-thread:join-thread thread))) - (format t "Deadline in ~S~%" seconds-passed) - (assert (< seconds-passed 1.2))))))) \ No newline at end of file +(with-test (:name (:deadline :futex-wait-eintr) :skipped-on '(not :sb-thread)) + (let ((lock (sb-thread:make-mutex)) + (waitp t)) + (make-join-thread (lambda () + (sb-thread:grab-mutex lock) + (setf waitp nil) + (sleep 5))) + (loop while waitp do (sleep 0.01)) + (let ((thread (make-join-thread + (lambda () + (let ((start (get-internal-real-time))) + (handler-case + (sb-sys:with-deadline (:seconds 1) + (sb-thread:grab-mutex lock)) + (sb-sys:deadline-timeout (x) + (declare (ignore x)) + (let ((end (get-internal-real-time))) + (float (/ (- end start) + internal-time-units-per-second) + 0.0))))))))) + (sleep 0.3) + (sb-thread:interrupt-thread thread (lambda () 42)) + (let ((seconds-passed (sb-thread:join-thread thread))) + (format t "Deadline in ~S~%" seconds-passed) + (assert (< seconds-passed 1.2))))))