From: Waldemar Kozaczuk <jwkozac...@gmail.com>
Committer: Waldemar Kozaczuk <jwkozac...@gmail.com>
Branch: master

Make tst-unordered-ring-mpsc test more robust

Changed each test case to acquire lock on migration_lock
to ensure that the thread test is executed on does not
migrate from one cpu to another one. We have seen one
occurenence when this test failed most likely
because of this issue.

Signed-off-by: Waldemar Kozaczuk <jwkozac...@gmail.com>

---
diff --git a/tests/tst-unordered-ring-mpsc.cc b/tests/tst-unordered-ring-mpsc.cc
--- a/tests/tst-unordered-ring-mpsc.cc
+++ b/tests/tst-unordered-ring-mpsc.cc
@@ -15,6 +15,7 @@
 #include <unordered_set>
 #include <osv/latch.hh>
 #include <osv/elf.hh>
+#include <osv/migration-lock.hh>

 using value_t = int;
 using set_t = std::unordered_set<value_t>;
@@ -32,6 +33,7 @@ static set_t drain(Ring& ring)

 BOOST_AUTO_TEST_CASE(test_insert_and_drain)
 {
+    SCOPE_LOCK(migration_lock);
     unordered_ring_mpsc<value_t,16> ring;

     assert(ring.push(1));
@@ -51,6 +53,7 @@ BOOST_AUTO_TEST_CASE(test_insert_and_drain)

 BOOST_AUTO_TEST_CASE(test_when_ring_gets_full)
 {
+    SCOPE_LOCK(migration_lock);
     unordered_ring_mpsc<value_t,4> ring;

     assert(ring.push(1));
@@ -72,6 +75,7 @@ BOOST_AUTO_TEST_CASE(test_when_ring_gets_full)

 BOOST_AUTO_TEST_CASE(test_concurrent_access)
 {
+    SCOPE_LOCK(migration_lock);
     constexpr value_t n_items = 1024*128;
     unordered_ring_mpsc<value_t,n_items*2> ring;

--
You received this message because you are subscribed to the Google Groups "OSv 
Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to osv-dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to