WITH-SPINLOCK compatibility layer was broken
[sbcl.git] / tests / threads.impure.lisp
index 75bb628..8bd9f19 100644 (file)
 
 (defun alloc-stuff () (copy-list '(1 2 3 4 5)))
 
-(with-test (:name (:interrupt-thread :interrupt-consing-child)
-            :broken-on :darwin)
+(with-test (:name (:interrupt-thread :interrupt-consing-child))
   (let ((thread (sb-thread:make-thread (lambda () (loop (alloc-stuff))))))
     (let ((killers
            (loop repeat 4 collect
 ;;; Make sure that a deadline handler is not invoked twice in a row in
 ;;; CONDITION-WAIT. See LP #512914 for a detailed explanation.
 ;;;
-(with-test (:name (:condition-wait :deadlines :LP-512914)
-            :skipped-on '(not :sb-futex))
+(with-test (:name (:condition-wait :deadlines :LP-512914))
   (let ((n 2)                      ; was empirically enough to trigger the bug
         (mutex (sb-thread:make-mutex))
         (waitq (sb-thread:make-waitqueue))
 
 (format t "~&starting gc deadlock test: WARNING: THIS TEST WILL HANG ON FAILURE!~%")
 
-(with-test (:name :gc-deadlock
-                  ;; Prone to hang on Darwin due to interrupt issues.
-            :broken-on :darwin)
+(with-test (:name :gc-deadlock)
   ;; Prior to 0.9.16.46 thread exit potentially deadlocked the
   ;; GC due to *all-threads-lock* and session lock. On earlier
   ;; versions and at least on one specific box this test is good enough
     (let ((res (list (sb-thread:join-thread t1)
                      (sb-thread:join-thread t2))))
       (assert (equal '(:ok :ok) res)))))
+
+(with-test (:name :spinlock-api)
+  (let* ((warned 0)
+         (funs
+           (handler-bind ((sb-int:early-deprecation-warning (lambda (_)
+                                                              (declare (ignore _))
+                                                              (incf warned))))
+             (list (compile nil `(lambda (lock)
+                                   (sb-thread::with-spinlock (lock)
+                                     t)))
+                   (compile nil `(lambda ()
+                                   (sb-thread::make-spinlock :name "foo")))
+                   (compile nil `(lambda (lock)
+                                   (sb-thread::get-spinlock lock)))
+                   (compile nil `(lambda (lock)
+                                   (sb-thread::release-spinlock lock)))))))
+    (assert (eql 4 warned))
+    (handler-bind ((warning #'error))
+      (destructuring-bind (with make get release) funs
+        (let ((lock (funcall make)))
+          (funcall get lock)
+          (funcall release lock)
+          (assert (eq t (funcall with lock))))))))