Add tests for two bugs that were incidentally fixed some time ago.
[sbcl.git] / tests / threads.pure.lisp
index 118422c..2a2a6c4 100644 (file)
 (in-package :cl-user)
 
 (defpackage :thread-test
-  (:use :cl :sb-thread))
+  (:use :cl :sb-thread :sb-ext))
 
 (in-package :thread-test)
 
 (use-package :test-util)
 
+(with-test (:name atomic-update
+            :skipped-on '(not :sb-thread))
+  (let ((x (cons :count 0)))
+    (mapc #'sb-thread:join-thread
+          (loop repeat 1000
+                collect (sb-thread:make-thread
+                         (lambda ()
+                           (loop repeat 1000
+                                 do (atomic-update (cdr x) #'1+)
+                                    (sleep 0.00001))))))
+    (assert (equal x '(:count . 1000000)))))
+
 (with-test (:name mutex-owner)
   ;; Make sure basics are sane on unithreaded ports as well
   (let ((mutex (make-mutex)))
     (try-semaphore sem 1 note)
     (assert (semaphore-notification-status note))))
 
-(with-test (:name (:return-from-thread :normal-thread))
+(with-test (:name (:return-from-thread :normal-thread)
+            :skipped-on '(not :sb-thread))
   (let* ((thread (make-thread (lambda ()
                                 (return-from-thread (values 1 2 3))
                                 :foo)))
                 (thread-error ()
                   :oops)))))
 
-(with-test (:name (:abort-thread :normal-thread))
+(with-test (:name (:abort-thread :normal-thread)
+            :skipped-on '(not :sb-thread))
   (let ((thread (make-thread (lambda ()
                                (abort-thread)
                                :foo))))