[Fawkes Git] branch/thofmann/syncpoint: syncpoint: add test to check if all waiters are released simultaneously

Till Hofmann hofmann at kbsg.rwth-aachen.de
Wed May 11 15:26:14 CEST 2016


Changes have been pushed for the project "Fawkes Robotics Software Framework".

Gitweb: http://git.fawkesrobotics.org/fawkes.git
Trac:   http://trac.fawkesrobotics.org

The branch, thofmann/syncpoint has been updated
        to  852d0b6057eeeaa84d151e5e5e5a57183ab2d59c (commit)
      from  e4b196a930ae0b711c9b18cc39a7596e0160ca4d (commit)

http://git.fawkesrobotics.org/fawkes.git/thofmann/syncpoint

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- *Log* ---------------------------------------------------------------
commit 852d0b6057eeeaa84d151e5e5e5a57183ab2d59c
Author:     Till Hofmann <hofmann at kbsg.rwth-aachen.de>
AuthorDate: Wed May 11 15:23:34 2016 +0200
Commit:     Till Hofmann <hofmann at kbsg.rwth-aachen.de>
CommitDate: Wed May 11 15:23:34 2016 +0200

    syncpoint: add test to check if all waiters are released simultaneously
    
    If two waiters wait for a syncpoint and an emitter emits between those
    two wait calls, then both waiters should still be released a the same
    time.

http://git.fawkesrobotics.org/fawkes.git/commit/852d0b6
http://trac.fawkesrobotics.org/changeset/852d0b6

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -


- *Summary* -----------------------------------------------------------
 src/libs/syncpoint/tests/test_syncpoint.cpp |   40 +++++++++++++++++++++++++++
 1 files changed, 40 insertions(+), 0 deletions(-)


- *Diffs* -------------------------------------------------------------

- *commit* 852d0b6057eeeaa84d151e5e5e5a57183ab2d59c - - - - - - - - - -
Author:  Till Hofmann <hofmann at kbsg.rwth-aachen.de>
Date:    Wed May 11 15:23:34 2016 +0200
Subject: syncpoint: add test to check if all waiters are released simultaneously

 src/libs/syncpoint/tests/test_syncpoint.cpp |   40 +++++++++++++++++++++++++++
 1 files changed, 40 insertions(+), 0 deletions(-)

_Diff for modified files_:
diff --git a/src/libs/syncpoint/tests/test_syncpoint.cpp b/src/libs/syncpoint/tests/test_syncpoint.cpp
index ad64e29..ca0e379 100644
--- a/src/libs/syncpoint/tests/test_syncpoint.cpp
+++ b/src/libs/syncpoint/tests/test_syncpoint.cpp
@@ -1107,3 +1107,43 @@ TEST_F(SyncPointManagerTest, LockUntilNextWaitWaiterComesFirstTest)
 
   ASSERT_EQ(0, pthread_tryjoin_np(waiter_thread, NULL));
 }
+
+/** Test whether all waiters are always released at the same time, even if one
+ *  waiter called wait after one emitter already emitted. In particular, this
+ *  tests the following scenario:
+ *  1. waiter1: wait
+ *  2. emitter1: emit
+ *  3. waiter2: wait
+ *  4. emitter2: emit
+ *  5. both waiter1 and waiter2 are released
+ */
+TEST_F(SyncPointManagerTest, WaitersAreAlwaysReleasedSimultaneouslyTest)
+{
+  RefPtr<SyncPoint> sp = manager->get_syncpoint("emitter1", "/test");
+  manager->get_syncpoint("emitter2", "/test");
+  sp->register_emitter("emitter1");
+  sp->register_emitter("emitter2");
+  uint num_threads = 2;
+  pthread_t threads[num_threads];
+  string sp_identifier = "/test";
+  waiter_thread_params params;
+  params.manager = manager;
+  params.thread_nr = 1;
+  params.num_wait_calls = 0;
+  params.sp_identifier = sp_identifier;
+  pthread_create(&threads[0], &attrs, start_waiter_thread, &params);
+  pthread_yield();
+  EXPECT_EQ(EBUSY, pthread_tryjoin_np(threads[0], NULL));
+  sp->emit("emitter1");
+  EXPECT_EQ(EBUSY, pthread_tryjoin_np(threads[0], NULL));
+  params.thread_nr = 2;
+  pthread_create(&threads[1], &attrs, start_waiter_thread, &params);
+  for (uint i = 0; i < num_threads; i++) {
+    EXPECT_EQ(EBUSY, pthread_tryjoin_np(threads[i], NULL));
+  }
+  sp->emit("emitter2");
+  usleep(2000000);
+  for (uint i = 0; i < num_threads; i++) {
+    ASSERT_EQ(0, pthread_tryjoin_np(threads[i], NULL));
+  }
+}




-- 
Fawkes Robotics Framework                 http://www.fawkesrobotics.org


More information about the fawkes-commits mailing list