[PATCH 08/11] sptests/spmutex01: test flush with inherit prio

Gedare Bloom gedare at rtems.org
Fri Mar 23 16:15:44 UTC 2018


From: Sebastian Huber <sebastian.huber at embedded-brains.de>

---
 testsuites/sptests/spmutex01/init.c | 48 ++++++++++++++++++++++++++++++++-----
 1 file changed, 42 insertions(+), 6 deletions(-)

diff --git a/testsuites/sptests/spmutex01/init.c b/testsuites/sptests/spmutex01/init.c
index c411bc4..d3bc1ed 100644
--- a/testsuites/sptests/spmutex01/init.c
+++ b/testsuites/sptests/spmutex01/init.c
@@ -31,12 +31,13 @@ typedef enum {
   REQ_WAKE_UP_MASTER = RTEMS_EVENT_0,
   REQ_WAKE_UP_HELPER = RTEMS_EVENT_1,
   REQ_MTX_0_OBTAIN = RTEMS_EVENT_2,
-  REQ_MTX_0_RELEASE = RTEMS_EVENT_3,
-  REQ_MTX_1_OBTAIN = RTEMS_EVENT_4,
-  REQ_MTX_1_OBTAIN_TIMEOUT = RTEMS_EVENT_5,
-  REQ_MTX_1_RELEASE = RTEMS_EVENT_6,
-  REQ_MTX_2_OBTAIN = RTEMS_EVENT_7,
-  REQ_MTX_2_RELEASE = RTEMS_EVENT_8,
+  REQ_MTX_0_OBTAIN_UNSATISFIED = RTEMS_EVENT_3,
+  REQ_MTX_0_RELEASE = RTEMS_EVENT_4,
+  REQ_MTX_1_OBTAIN = RTEMS_EVENT_5,
+  REQ_MTX_1_OBTAIN_TIMEOUT = RTEMS_EVENT_6,
+  REQ_MTX_1_RELEASE = RTEMS_EVENT_7,
+  REQ_MTX_2_OBTAIN = RTEMS_EVENT_8,
+  REQ_MTX_2_RELEASE = RTEMS_EVENT_9,
 } request_id;
 
 typedef enum {
@@ -141,6 +142,14 @@ static void obtain_timeout(test_context *ctx, mutex_id id)
   rtems_test_assert(sc == RTEMS_TIMEOUT);
 }
 
+static void obtain_unsatisfied(test_context *ctx, mutex_id id)
+{
+  rtems_status_code sc;
+
+  sc = rtems_semaphore_obtain(ctx->mtx[id], RTEMS_WAIT, RTEMS_NO_TIMEOUT);
+  rtems_test_assert(sc == RTEMS_UNSATISFIED);
+}
+
 static void obtain(test_context *ctx, mutex_id id)
 {
   rtems_status_code sc;
@@ -157,6 +166,14 @@ static void release(test_context *ctx, mutex_id id)
   rtems_test_assert(sc == RTEMS_SUCCESSFUL);
 }
 
+static void flush(test_context *ctx, mutex_id id)
+{
+  rtems_status_code sc;
+
+  sc = rtems_semaphore_flush(ctx->mtx[id]);
+  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
+}
+
 static void check_generations(test_context *ctx, task_id a, task_id b)
 {
   size_t i;
@@ -232,6 +249,11 @@ static void worker(rtems_task_argument arg)
       ++ctx->generation[id];
     }
 
+    if ((events & REQ_MTX_0_OBTAIN_UNSATISFIED) != 0) {
+      obtain_unsatisfied(ctx, MTX_0);
+      ++ctx->generation[id];
+    }
+
     if ((events & REQ_MTX_0_RELEASE) != 0) {
       release(ctx, MTX_0);
       ++ctx->generation[id];
@@ -407,6 +429,19 @@ static void test_inherit_nested_horizontal(test_context *ctx)
   check_generations(ctx, A_1, NONE);
 }
 
+static void test_inherit_flush(test_context *ctx)
+{
+  assert_prio(ctx, M, 3);
+  obtain(ctx, MTX_0);
+  request(ctx, A_1, REQ_MTX_0_OBTAIN_UNSATISFIED);
+  check_generations(ctx, NONE, NONE);
+  assert_prio(ctx, M, 1);
+  flush(ctx, MTX_0);
+  check_generations(ctx, A_1, NONE);
+  assert_prio(ctx, M, 3);
+  release(ctx, MTX_0);
+}
+
 static void tear_down(test_context *ctx)
 {
   rtems_status_code sc;
@@ -437,6 +472,7 @@ static void Init(rtems_task_argument arg)
   test_inherit_nested_vertical(ctx);
   test_inherit_nested_vertical_timeout(ctx);
   test_inherit_nested_horizontal(ctx);
+  test_inherit_flush(ctx);
   tear_down(ctx);
 
   rtems_test_assert(rtems_resource_snapshot_check(&snapshot));
-- 
2.7.4



More information about the devel mailing list