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

Till Hofmann hofmann at kbsg.rwth-aachen.de
Fri May 13 16:15:05 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
  discards  852d0b6057eeeaa84d151e5e5e5a57183ab2d59c (commit)
        to  32bad7cca8e94fed513f40412ef9ec7586d686e2 (commit)

This update added new revisions after undoing existing revisions.  That is
to say, the old revision is not a strict subset of the new revision.  This
situation occurs when you --force push a change and generate a repository
containing something like this:

 * -- * -- B -- O -- O -- O (852d0b6057eeeaa84d151e5e5e5a57183ab2d59c)
            \
             N -- N -- N (32bad7cca8e94fed513f40412ef9ec7586d686e2)

When this happens we assume that you've already had alert emails for all
of the O revisions, and so we here report only the revisions in the N
branch from the common base, B.

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 32bad7cca8e94fed513f40412ef9ec7586d686e2
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: Fri May 13 13:54:38 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/32bad7c
http://trac.fawkesrobotics.org/changeset/32bad7c

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


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


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

- *commit* 32bad7cca8e94fed513f40412ef9ec7586d686e2 - - - - - - - - - -
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 |   44 +++++++++++++++++++++++++++
 1 files changed, 44 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..5da0e14 100644
--- a/src/libs/syncpoint/tests/test_syncpoint.cpp
+++ b/src/libs/syncpoint/tests/test_syncpoint.cpp
@@ -1107,3 +1107,47 @@ 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)
+{
+  string sp_identifier = "/test";
+  RefPtr<SyncPoint> sp = manager->get_syncpoint("emitter1", sp_identifier);
+  manager->get_syncpoint("emitter2", sp_identifier);
+  sp->register_emitter("emitter1");
+  sp->register_emitter("emitter2");
+  uint num_threads = 2;
+  pthread_t threads[num_threads];
+  waiter_thread_params params[num_threads];
+  for (uint i = 0; i < num_threads; i++) {
+    params[i].manager = manager;
+    params[i].thread_nr = i;
+    params[i].num_wait_calls = 1;
+    params[i].sp_identifier = sp_identifier;
+  }
+  pthread_create(&threads[0], &attrs, start_barrier_waiter_thread, &params[0]);
+  pthread_yield();
+  usleep(10000);
+  EXPECT_EQ(EBUSY, pthread_tryjoin_np(threads[0], NULL));
+  sp->emit("emitter1");
+  usleep(10000);
+  EXPECT_EQ(EBUSY, pthread_tryjoin_np(threads[0], NULL));
+  pthread_create(&threads[1], &attrs, start_barrier_waiter_thread, &params[1]);
+  usleep(10000);
+  for (uint i = 0; i < num_threads; i++) {
+    EXPECT_EQ(EBUSY, pthread_tryjoin_np(threads[i], NULL));
+  }
+  sp->emit("emitter2");
+  usleep(10000);
+  for (uint i = 0; i < num_threads; i++) {
+    EXPECT_EQ(0, pthread_tryjoin_np(threads[i], NULL));
+  }
+}




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


More information about the fawkes-commits mailing list