emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master d018843: Fix last change


From: Eli Zaretskii
Subject: [Emacs-diffs] master d018843: Fix last change
Date: Fri, 13 Jan 2017 16:17:49 +0000 (UTC)

branch: master
commit d018843e0e8065b1c9de9474521db069e1aa0025
Author: Eli Zaretskii <address@hidden>
Commit: Eli Zaretskii <address@hidden>

    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.
---
 test/src/thread-tests.el |   18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/test/src/thread-tests.el b/test/src/thread-tests.el
index 22ea907..df8222a 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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]