X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=tests%2Fthreads.pure.lisp;h=cb1a827f9ef106a267ef1e9458fea35c7af2c14d;hb=fd79e33e6b6dacdc52cf6668a5bb7adf75aad6c1;hp=8187b51f762d2cb308f0768a9dccfc9ea6038d03;hpb=9cbef67c0d16955fc77a555e7ad251d93e206524;p=sbcl.git diff --git a/tests/threads.pure.lisp b/tests/threads.pure.lisp index 8187b51..cb1a827 100644 --- a/tests/threads.pure.lisp +++ b/tests/threads.pure.lisp @@ -20,6 +20,24 @@ (use-package :test-util) +(with-test (:name mutex-owner) + ;; Make sure basics are sane on unithreaded ports as well + (let ((mutex (make-mutex))) + (get-mutex mutex) + (assert (eq *current-thread* (mutex-value mutex))) + (handler-bind ((warning #'error)) + (release-mutex mutex)) + (assert (not (mutex-value mutex))))) + +(with-test (:name spinlock-owner) + ;; Make sure basics are sane on unithreaded ports as well + (let ((spinlock (sb-thread::make-spinlock))) + (sb-thread::get-spinlock spinlock) + (assert (eq *current-thread* (sb-thread::spinlock-value spinlock))) + (handler-bind ((warning #'error)) + (sb-thread::release-spinlock spinlock)) + (assert (not (sb-thread::spinlock-value spinlock))))) + ;;; Terminating a thread that's waiting for the terminal. #+sb-thread @@ -92,12 +110,12 @@ (values (loop for r from 0 below n collect - (let ((r r)) - (sb-thread:make-thread (lambda () - (let ((sem semaphore)) - (dotimes (s i) - (sb-thread:wait-on-semaphore sem)))) - :name "reader"))) + (sb-thread:make-thread + (lambda () + (let ((sem semaphore)) + (dotimes (s i) + (sb-thread:wait-on-semaphore sem)))) + :name "reader")) (* n i))) (make-writers (n readers i) (let ((j (* readers i))) @@ -106,12 +124,12 @@ (let ((writers (loop for w from 0 below n collect - (let ((w w)) - (sb-thread:make-thread (lambda () - (let ((sem semaphore)) - (dotimes (s k) - (sb-thread:signal-semaphore sem)))) - :name "writer"))))) + (sb-thread:make-thread + (lambda () + (let ((sem semaphore)) + (dotimes (s k) + (sb-thread:signal-semaphore sem)))) + :name "writer")))) (assert (zerop rem)) writers) (+ rem (* n k))))))