summaryrefslogtreecommitdiff
path: root/test/src/thread-tests.el
diff options
context:
space:
mode:
authorEli Zaretskii <eliz@gnu.org>2017-01-13 18:17:12 +0200
committerEli Zaretskii <eliz@gnu.org>2017-01-13 18:17:12 +0200
commitd018843e0e8065b1c9de9474521db069e1aa0025 (patch)
tree15543040b297e01832ebde6fa561ae524e9be51d /test/src/thread-tests.el
parent26b5426de8a51b88556e1dc4c2c328875f2dfb01 (diff)
downloademacs-d018843e0e8065b1c9de9474521db069e1aa0025.tar.gz
Fix last change
* test/src/thread-tests.el (threads-condvar-wait): Revert previous change. Make sure no other threads from previous tests are running, to avoid interfering with our thread counts.
Diffstat (limited to 'test/src/thread-tests.el')
-rw-r--r--test/src/thread-tests.el18
1 files changed, 9 insertions, 9 deletions
diff --git a/test/src/thread-tests.el b/test/src/thread-tests.el
index 22ea90727ce..df8222a21aa 100644
--- a/test/src/thread-tests.el
+++ b/test/src/thread-tests.el
@@ -257,14 +257,17 @@
(ert-deftest threads-condvar-wait ()
"test waiting on conditional variable"
(let ((cv-mutex (make-mutex))
- (nthreads (length (all-threads)))
new-thread)
+ ;; We could have spurious threads from the previous tests still
+ ;; running; wait for them to die.
+ (while (> (length (all-threads)) 1)
+ (thread-yield))
(setq threads-condvar (make-condition-variable cv-mutex))
(setq new-thread (make-thread #'threads-test-condvar-wait))
;; Make sure new-thread is alive.
(should (thread-alive-p new-thread))
- (should (= (length (all-threads)) (1+ nthreads)))
+ (should (= (length (all-threads)) 2))
;; Wait for new-thread to become blocked on the condvar.
(while (not (eq (thread--blocker new-thread) threads-condvar))
(thread-yield))
@@ -272,21 +275,18 @@
;; Notify the waiting thread.
(with-mutex cv-mutex
(condition-notify threads-condvar t))
- ;; Allow new-thread to process the notification. Sleeping for too
- ;; short time here will fail the length test below.
- (sleep-for 1)
+ ;; Allow new-thread to process the notification.
+ (sleep-for 0.1)
;; Make sure the thread is still there. This used to fail due to
;; a bug in thread.c:condition_wait_callback.
(should (thread-alive-p new-thread))
- (should (= (length (all-threads)) (1+ nthreads)))
- (should (memq new-thread (all-threads)))
- ;; Make sure the other thread waits at the condition variable again.
+ (should (= (length (all-threads)) 2))
(should (eq (thread--blocker new-thread) threads-condvar))
;; Signal the thread.
(thread-signal new-thread 'error '("Die, die, die!"))
(sleep-for 0.1)
;; Make sure the thread died.
- (should (= (length (all-threads)) nthreads))))
+ (should (= (length (all-threads)) 1))))
;;; threads.el ends here