summaryrefslogtreecommitdiffstats
path: root/testsuites
diff options
context:
space:
mode:
Diffstat (limited to 'testsuites')
-rw-r--r--testsuites/smptests/smpmutex01/init.c3
-rw-r--r--testsuites/smptests/smpscheduler03/init.c43
-rw-r--r--testsuites/sptests/spmutex01/init.c141
-rw-r--r--testsuites/sptests/spsem03/init.c30
-rw-r--r--testsuites/sptests/spsem03/spsem03.doc4
5 files changed, 176 insertions, 45 deletions
diff --git a/testsuites/smptests/smpmutex01/init.c b/testsuites/smptests/smpmutex01/init.c
index 5adc2e2244..93c059e6fc 100644
--- a/testsuites/smptests/smpmutex01/init.c
+++ b/testsuites/smptests/smpmutex01/init.c
@@ -315,10 +315,9 @@ static void test(void)
request(ctx, B_5_0, REQ_MTX_RELEASE);
check_generations(ctx, B_5_0, A_2_1);
assert_prio(ctx, B_5_0, 5);
- assert_prio(ctx, A_2_1, 0);
+ assert_prio(ctx, A_2_1, 2);
request(ctx, A_2_1, REQ_MTX_RELEASE);
check_generations(ctx, A_2_1, B_5_1);
- assert_prio(ctx, A_2_1, 2);
assert_prio(ctx, B_5_1, 5);
request(ctx, B_5_1, REQ_MTX_RELEASE);
check_generations(ctx, B_5_1, NONE);
diff --git a/testsuites/smptests/smpscheduler03/init.c b/testsuites/smptests/smpscheduler03/init.c
index c114eb90be..50d4894859 100644
--- a/testsuites/smptests/smpscheduler03/init.c
+++ b/testsuites/smptests/smpscheduler03/init.c
@@ -40,28 +40,35 @@ typedef struct {
static test_context test_instance;
-static bool change_priority_filter(
- Thread_Control *thread,
- Priority_Control *new_priority,
- void *arg
+static void apply_priority(
+ Thread_Control *thread,
+ Priority_Control new_priority,
+ bool prepend_it,
+ Thread_queue_Context *queue_context
)
{
- return _Thread_Get_priority( thread ) != *new_priority;
+ _Thread_queue_Context_clear_priority_updates(queue_context);
+ _Thread_Wait_acquire(thread, queue_context);
+ _Thread_Priority_change(
+ thread,
+ &thread->Real_priority,
+ new_priority,
+ prepend_it,
+ queue_context
+ );
+ _Thread_Wait_release(thread, queue_context);
}
static void change_priority(
- Thread_Control *thread,
- Priority_Control new_priority,
- bool prepend_it
+ Thread_Control *thread,
+ Priority_Control new_priority,
+ bool prepend_it
)
{
- _Thread_Change_priority(
- thread,
- new_priority,
- NULL,
- change_priority_filter,
- prepend_it
- );
+ Thread_queue_Context queue_context;
+
+ apply_priority(thread, new_priority, prepend_it, &queue_context);
+ _Thread_Priority_update(&queue_context);
}
static void barrier_wait(test_context *ctx)
@@ -197,11 +204,9 @@ static Thread_Control *update_priority_op(
ISR_lock_Context state_lock_context;
ISR_lock_Context scheduler_lock_context;
Thread_Control *needs_help;
- Scheduler_Node *node;
+ Thread_queue_Context queue_context;
- thread->current_priority = new_priority;
- node = _Scheduler_Thread_get_node(thread);
- _Scheduler_Node_set_priority(node, new_priority, prepend_it);
+ apply_priority(thread, new_priority, prepend_it, &queue_context);
_Thread_State_acquire( thread, &state_lock_context );
scheduler = _Scheduler_Get( thread );
diff --git a/testsuites/sptests/spmutex01/init.c b/testsuites/sptests/spmutex01/init.c
index c3633706bf..72e458f167 100644
--- a/testsuites/sptests/spmutex01/init.c
+++ b/testsuites/sptests/spmutex01/init.c
@@ -41,13 +41,14 @@ typedef enum {
REQ_MTX_0_OBTAIN = RTEMS_EVENT_2,
REQ_MTX_0_RELEASE = RTEMS_EVENT_3,
REQ_MTX_1_OBTAIN = RTEMS_EVENT_4,
- REQ_MTX_1_RELEASE = RTEMS_EVENT_5,
- REQ_MTX_2_OBTAIN = RTEMS_EVENT_6,
- REQ_MTX_2_RELEASE = RTEMS_EVENT_7,
- REQ_MTX_C11_OBTAIN = RTEMS_EVENT_8,
- REQ_MTX_C11_RELEASE = RTEMS_EVENT_9,
- REQ_MTX_POSIX_OBTAIN = RTEMS_EVENT_10,
- REQ_MTX_POSIX_RELEASE = RTEMS_EVENT_11
+ 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_C11_OBTAIN = RTEMS_EVENT_9,
+ REQ_MTX_C11_RELEASE = RTEMS_EVENT_10,
+ REQ_MTX_POSIX_OBTAIN = RTEMS_EVENT_11,
+ REQ_MTX_POSIX_RELEASE = RTEMS_EVENT_12
} request_id;
typedef enum {
@@ -110,6 +111,14 @@ static void send_event(test_context *ctx, task_id id, rtems_event_set events)
rtems_test_assert(sc == RTEMS_SUCCESSFUL);
}
+static void wait(void)
+{
+ rtems_status_code sc;
+
+ sc = rtems_task_wake_after(4);
+ rtems_test_assert(sc == RTEMS_SUCCESSFUL);
+}
+
static rtems_event_set wait_for_events(void)
{
rtems_event_set events;
@@ -141,6 +150,14 @@ static void request(test_context *ctx, task_id id, request_id req)
sync_with_helper(ctx);
}
+static void obtain_timeout(test_context *ctx, mutex_id id)
+{
+ rtems_status_code sc;
+
+ sc = rtems_semaphore_obtain(ctx->mtx[id], RTEMS_WAIT, 2);
+ rtems_test_assert(sc == RTEMS_TIMEOUT);
+}
+
static void obtain(test_context *ctx, mutex_id id)
{
rtems_status_code sc;
@@ -249,6 +266,22 @@ static void assert_prio(
rtems_test_assert(expected == actual);
}
+static void change_prio(
+ test_context *ctx,
+ task_id id,
+ rtems_task_priority prio
+)
+{
+ rtems_status_code sc;
+
+ sc = rtems_task_set_priority(
+ ctx->tasks[id],
+ prio,
+ &prio
+ );
+ rtems_test_assert(sc == RTEMS_SUCCESSFUL);
+}
+
static void helper(rtems_task_argument arg)
{
test_context *ctx = &test_instance;
@@ -283,6 +316,11 @@ static void worker(rtems_task_argument arg)
++ctx->generation[id];
}
+ if ((events & REQ_MTX_1_OBTAIN_TIMEOUT) != 0) {
+ obtain_timeout(ctx, MTX_1);
+ ++ctx->generation[id];
+ }
+
if ((events & REQ_MTX_1_RELEASE) != 0) {
release(ctx, MTX_1);
++ctx->generation[id];
@@ -370,10 +408,19 @@ static void set_up(test_context *ctx)
static void test_inherit(test_context *ctx)
{
+ assert_prio(ctx, M, 3);
obtain(ctx, MTX_0);
request(ctx, A_1, REQ_MTX_0_OBTAIN);
check_generations(ctx, NONE, NONE);
assert_prio(ctx, M, 1);
+ change_prio(ctx, A_1, 2);
+ assert_prio(ctx, M, 2);
+ change_prio(ctx, A_1, 3);
+ assert_prio(ctx, M, 3);
+ change_prio(ctx, A_1, 4);
+ assert_prio(ctx, M, 3);
+ change_prio(ctx, A_1, 1);
+ assert_prio(ctx, M, 1);
release(ctx, MTX_0);
check_generations(ctx, A_1, NONE);
assert_prio(ctx, M, 3);
@@ -383,6 +430,7 @@ static void test_inherit(test_context *ctx)
static void test_inherit_fifo_for_equal_priority(test_context *ctx)
{
+ assert_prio(ctx, M, 3);
obtain(ctx, MTX_0);
request(ctx, A_2_0, REQ_MTX_0_OBTAIN);
request(ctx, A_1, REQ_MTX_0_OBTAIN);
@@ -401,6 +449,82 @@ static void test_inherit_fifo_for_equal_priority(test_context *ctx)
check_generations(ctx, A_2_1, NONE);
}
+static void test_inherit_nested_vertical(test_context *ctx)
+{
+ assert_prio(ctx, M, 3);
+ obtain(ctx, MTX_0);
+ obtain(ctx, MTX_1);
+ request(ctx, A_1, REQ_MTX_1_OBTAIN);
+ check_generations(ctx, NONE, NONE);
+ assert_prio(ctx, M, 1);
+ release(ctx, MTX_1);
+ check_generations(ctx, A_1, NONE);
+ assert_prio(ctx, M, 3);
+ request(ctx, A_1, REQ_MTX_1_RELEASE);
+ check_generations(ctx, A_1, NONE);
+ release(ctx, MTX_0);
+}
+
+static void test_inherit_nested_vertical_timeout(test_context *ctx)
+{
+ assert_prio(ctx, M, 3);
+ obtain(ctx, MTX_0);
+ obtain(ctx, MTX_1);
+ request(ctx, A_1, REQ_MTX_1_OBTAIN_TIMEOUT);
+ check_generations(ctx, NONE, NONE);
+ assert_prio(ctx, M, 1);
+ wait();
+ check_generations(ctx, A_1, NONE);
+ assert_prio(ctx, M, 3);
+ release(ctx, MTX_1);
+ release(ctx, MTX_0);
+}
+
+static void test_inherit_nested_horizontal(test_context *ctx)
+{
+ assert_prio(ctx, M, 3);
+ obtain(ctx, MTX_0);
+ request(ctx, A_2_0, REQ_MTX_1_OBTAIN);
+ check_generations(ctx, A_2_0, NONE);
+ request(ctx, A_2_0, REQ_MTX_0_OBTAIN);
+ check_generations(ctx, NONE, NONE);
+ assert_prio(ctx, M, 2);
+ request(ctx, A_1, REQ_MTX_1_OBTAIN_TIMEOUT);
+ check_generations(ctx, NONE, NONE);
+ assert_prio(ctx, A_2_0, 1);
+ assert_prio(ctx, M, 1);
+ wait();
+ check_generations(ctx, A_1, NONE);
+ assert_prio(ctx, A_2_0, 2);
+ assert_prio(ctx, M, 2);
+ request(ctx, A_1, REQ_MTX_1_OBTAIN);
+ check_generations(ctx, NONE, NONE);
+ assert_prio(ctx, A_2_0, 1);
+ assert_prio(ctx, M, 1);
+ change_prio(ctx, A_1, 2);
+ assert_prio(ctx, M, 2);
+ change_prio(ctx, A_1, 3);
+ assert_prio(ctx, M, 2);
+ change_prio(ctx, A_2_0, 3);
+ assert_prio(ctx, M, 3);
+ change_prio(ctx, A_2_0, 2);
+ assert_prio(ctx, M, 2);
+ change_prio(ctx, A_1, 1);
+ assert_prio(ctx, M, 1);
+ release(ctx, MTX_0);
+ check_generations(ctx, A_2_0, NONE);
+ assert_prio(ctx, A_2_0, 1);
+ assert_prio(ctx, M, 3);
+ request(ctx, A_2_0, REQ_MTX_0_RELEASE);
+ check_generations(ctx, A_2_0, NONE);
+ assert_prio(ctx, A_2_0, 1);
+ request(ctx, A_2_0, REQ_MTX_1_RELEASE);
+ check_generations(ctx, A_1, A_2_0);
+ assert_prio(ctx, A_2_0, 2);
+ request(ctx, A_1, REQ_MTX_1_RELEASE);
+ check_generations(ctx, A_1, NONE);
+}
+
static void test_deadlock_two_classic(test_context *ctx)
{
obtain(ctx, MTX_0);
@@ -547,6 +671,9 @@ static void Init(rtems_task_argument arg)
set_up(ctx);
test_inherit(ctx);
test_inherit_fifo_for_equal_priority(ctx);
+ test_inherit_nested_vertical(ctx);
+ test_inherit_nested_vertical_timeout(ctx);
+ test_inherit_nested_horizontal(ctx);
test_deadlock_two_classic(ctx);
test_deadlock_three_classic(ctx);
test_deadlock_c11_and_classic(ctx);
diff --git a/testsuites/sptests/spsem03/init.c b/testsuites/sptests/spsem03/init.c
index e64a04d326..7f573e5110 100644
--- a/testsuites/sptests/spsem03/init.c
+++ b/testsuites/sptests/spsem03/init.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014 embedded brains GmbH. All rights reserved.
+ * Copyright (c) 2014, 2016 embedded brains GmbH. All rights reserved.
*
* embedded brains GmbH
* Dornierstr. 4
@@ -88,20 +88,7 @@ static void obtain_sema(rtems_id id)
static void inversion_task(rtems_task_argument arg)
{
- test_context *ctx = &test_instance;
-
- /*
- * Here we see that the priority of the high priority task blocked on
- * semaphore B doesn't propagate to the low priority task owning semaphore A
- * on which the owner of semaphore B depends.
- */
- assert_prio(ctx->low, 3);
- assert_prio(ctx->mid, 1);
- assert_prio(ctx->high, 1);
- assert_prio(ctx->inversion, 2);
-
- TEST_END();
- rtems_test_exit(0);
+ assert(0);
}
static void mid_task(rtems_task_argument arg)
@@ -137,6 +124,19 @@ static void Init(rtems_task_argument arg)
obtain_sema(ctx->sem_a);
start_task(ctx->mid, mid_task);
start_task(ctx->high, high_task);
+
+ /*
+ * Here we see that the priority of the high priority task blocked on
+ * semaphore B propagated to the low priority task owning semaphore A
+ * on which the owner of semaphore B depends.
+ */
+ assert_prio(ctx->low, 1);
+ assert_prio(ctx->mid, 1);
+ assert_prio(ctx->high, 1);
+ assert_prio(ctx->inversion, 2);
+
+ TEST_END();
+ rtems_test_exit(0);
}
#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
diff --git a/testsuites/sptests/spsem03/spsem03.doc b/testsuites/sptests/spsem03/spsem03.doc
index 0310965798..a13430e874 100644
--- a/testsuites/sptests/spsem03/spsem03.doc
+++ b/testsuites/sptests/spsem03/spsem03.doc
@@ -8,5 +8,5 @@ directives:
concepts:
- - Demonstrate that the priority inheritance protocol doesn't propagate to
- indirectly referenced semaphore owners.
+ - Demonstrate that the priority inheritance protocol works with indirectly
+ referenced semaphore owners.