summaryrefslogtreecommitdiffstats
path: root/testsuites/sptests/spmutex01/init.c
diff options
context:
space:
mode:
Diffstat (limited to 'testsuites/sptests/spmutex01/init.c')
-rw-r--r--testsuites/sptests/spmutex01/init.c48
1 files changed, 42 insertions, 6 deletions
diff --git a/testsuites/sptests/spmutex01/init.c b/testsuites/sptests/spmutex01/init.c
index c411bc436c..d3bc1ed79a 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));