Coverage report: /home/ellis/comp/core/std/tests/thread.lisp
Kind | Covered | All | % |
expression | 0 | 6 | 0.0 |
branch | 0 | 0 | nil |
Key
Not instrumented
Conditionalized out
Executed
Not executed
Both branches taken
One branch taken
Neither branch taken
1
;;; thread.lisp --- Thread Tests
6
(in-package :std/tests)
9
(deftest with-threads ()
10
"Test with-threads macro."
11
(with-threads (i 4 :args (&optional (a 0) (b 1) (c 2)))
12
(is (= 3 (+ a b c)))))
15
"Test standard thread functionality."
16
(is (eq *current-thread*
17
(find (thread-name *current-thread*) (list-all-threads)
18
:key #'thread-name :test #'equal)))
19
(is (find-thread-by-id (car (thread-id-list))))
20
(is (not (zerop (thread-count))))
22
(make-threads 4 (lambda () (is (= 42 (1+ 41)))) :name "threads")))
23
(loop for th in threads
24
do (sb-thread:join-thread th))
25
(loop for th in threads
26
collect (is (not (sb-thread:thread-alive-p th)))))
27
(let ((m (make-mutex :name "mutex-test")))
32
(make-thread (lambda ()
33
(with-mutex (m :timeout 0.1)
36
(make-thread (lambda ()
37
(with-mutex (m :timeout 0.1)
40
(s (make-semaphore :name "semaphore-test"))
41
(th (make-thread (lambda () (wait-on-semaphore s)))))
42
(is (equal (multiple-value-list (join-thread th :timeout .001 :default sym))
45
(is (join-thread th)))
46
(signals join-thread-error (join-thread *current-thread*))
48
(let ((m (make-mutex :name "rlock-test")))
49
(is (not (with-mutex (m) (join-thread (make-thread (lambda () (with-recursive-lock (m :wait-p nil) t)))))))
50
(join-thread (make-thread (lambda () (with-recursive-lock (m :wait-p nil) t))))))
51
(let ((queue (make-waitqueue :name "queue-test"))
52
(lock (make-mutex :name "lock-test"))
55
(labels ((in-new-thread ()
57
(assert (eql (mutex-owner lock) *current-thread*))
58
(condition-wait queue lock)
59
(assert (eql (mutex-owner lock) *current-thread*))
62
(setf th (make-thread #'in-new-thread))
64
(is (null (mutex-owner lock)))
67
(condition-notify queue))
68
(is (= 0 (join-thread th))))))
71
"Test various timer functionality."
72
(sb-int:with-progressive-timeout (ttl :seconds 1)
76
(deftest thread-pool ()
78
(let ((tp (make-thread-pool 8)))
79
(istype '(array worker) (workers tp))
80
(is= 8 (length (workers tp)))
81
(istype 'thread-pool tp)))