[rtems commit] smptests/smpmrsp01: Fix due to API changes
Sebastian Huber
sebh at rtems.org
Thu Jun 23 08:38:28 UTC 2016
Module: rtems
Branch: master
Commit: ec5d95e15e3c9ed00c0d1c6fd7785338fdb92d49
Changeset: http://git.rtems.org/rtems/commit/?id=ec5d95e15e3c9ed00c0d1c6fd7785338fdb92d49
Author: Sebastian Huber <sebastian.huber at embedded-brains.de>
Date: Thu Jun 23 10:31:04 2016 +0200
smptests/smpmrsp01: Fix due to API changes
Commit 77ff5599e0d8e6d91190a379be21a332f83252b0 introduced a change in
the rtems_semaphore_create() behaviour for MrsP semaphores. The ceiling
priorities for all schedulers except the scheduler of the executing
thread are initialized to zero.
---
testsuites/smptests/smpmrsp01/init.c | 228 +++++++++--------------------------
1 file changed, 60 insertions(+), 168 deletions(-)
diff --git a/testsuites/smptests/smpmrsp01/init.c b/testsuites/smptests/smpmrsp01/init.c
index 17f0f8b..dca8662 100644
--- a/testsuites/smptests/smpmrsp01/init.c
+++ b/testsuites/smptests/smpmrsp01/init.c
@@ -214,6 +214,41 @@ static void print_switch_events(test_context *ctx)
}
}
+static void create_mrsp_sema(
+ test_context *ctx,
+ rtems_id *id,
+ rtems_task_priority prio
+)
+{
+ uint32_t cpu_count = rtems_get_processor_count();
+ uint32_t index;
+ rtems_status_code sc;
+
+ sc = rtems_semaphore_create(
+ rtems_build_name('M', 'R', 'S', 'P'),
+ 1,
+ RTEMS_MULTIPROCESSOR_RESOURCE_SHARING
+ | RTEMS_BINARY_SEMAPHORE,
+ prio,
+ id
+ );
+ rtems_test_assert(sc == RTEMS_SUCCESSFUL);
+
+ for (index = 1; index < cpu_count; index = ((index + 2) & ~UINT32_C(1))) {
+ rtems_task_priority old_prio;
+
+ old_prio = 1;
+ sc = rtems_semaphore_set_priority(
+ *id,
+ ctx->scheduler_ids[index],
+ prio,
+ &old_prio
+ );
+ rtems_test_assert(sc == RTEMS_SUCCESSFUL);
+ rtems_test_assert(old_prio == 0);
+ }
+}
+
static void run_task(rtems_task_argument arg)
{
volatile bool *run = (volatile bool *) arg;
@@ -321,15 +356,7 @@ static void test_mrsp_obtain_and_release(test_context *ctx)
/* Create a MrsP semaphore object and lock it */
- sc = rtems_semaphore_create(
- rtems_build_name('M', 'R', 'S', 'P'),
- 1,
- RTEMS_MULTIPROCESSOR_RESOURCE_SHARING
- | RTEMS_BINARY_SEMAPHORE,
- 2,
- &ctx->mrsp_ids[0]
- );
- rtems_test_assert(sc == RTEMS_SUCCESSFUL);
+ create_mrsp_sema(ctx, &ctx->mrsp_ids[0], 2);
assert_prio(RTEMS_SELF, 3);
@@ -561,35 +588,9 @@ static void test_mrsp_obtain_after_migration(test_context *ctx)
/* Create a MrsP semaphore objects */
- sc = rtems_semaphore_create(
- rtems_build_name('M', 'R', 'S', 'P'),
- 1,
- RTEMS_MULTIPROCESSOR_RESOURCE_SHARING
- | RTEMS_BINARY_SEMAPHORE,
- 3,
- &ctx->mrsp_ids[0]
- );
- rtems_test_assert(sc == RTEMS_SUCCESSFUL);
-
- sc = rtems_semaphore_create(
- rtems_build_name('M', 'R', 'S', 'P'),
- 1,
- RTEMS_MULTIPROCESSOR_RESOURCE_SHARING
- | RTEMS_BINARY_SEMAPHORE,
- 2,
- &ctx->mrsp_ids[1]
- );
- rtems_test_assert(sc == RTEMS_SUCCESSFUL);
-
- sc = rtems_semaphore_create(
- rtems_build_name('M', 'R', 'S', 'P'),
- 1,
- RTEMS_MULTIPROCESSOR_RESOURCE_SHARING
- | RTEMS_BINARY_SEMAPHORE,
- 1,
- &ctx->mrsp_ids[2]
- );
- rtems_test_assert(sc == RTEMS_SUCCESSFUL);
+ create_mrsp_sema(ctx, &ctx->mrsp_ids[0], 3);
+ create_mrsp_sema(ctx, &ctx->mrsp_ids[1], 2);
+ create_mrsp_sema(ctx, &ctx->mrsp_ids[2], 1);
prio = 4;
sc = rtems_semaphore_set_priority(
@@ -687,22 +688,14 @@ static void test_mrsp_obtain_after_migration(test_context *ctx)
rtems_test_assert(sc == RTEMS_SUCCESSFUL);
}
-static void test_mrsp_flush_error(void)
+static void test_mrsp_flush_error(test_context *ctx)
{
rtems_status_code sc;
rtems_id id;
puts("test MrsP flush error");
- sc = rtems_semaphore_create(
- rtems_build_name('M', 'R', 'S', 'P'),
- 1,
- RTEMS_MULTIPROCESSOR_RESOURCE_SHARING
- | RTEMS_BINARY_SEMAPHORE,
- 1,
- &id
- );
- rtems_test_assert(sc == RTEMS_SUCCESSFUL);
+ create_mrsp_sema(ctx, &id, 1);
sc = rtems_semaphore_flush(id);
rtems_test_assert(sc == RTEMS_NOT_DEFINED);
@@ -729,22 +722,14 @@ static void test_mrsp_initially_locked_error(void)
rtems_test_assert(sc == RTEMS_INVALID_NUMBER);
}
-static void test_mrsp_nested_obtain_error(void)
+static void test_mrsp_nested_obtain_error(test_context *ctx)
{
rtems_status_code sc;
rtems_id id;
puts("test MrsP nested obtain error");
- sc = rtems_semaphore_create(
- rtems_build_name('M', 'R', 'S', 'P'),
- 1,
- RTEMS_MULTIPROCESSOR_RESOURCE_SHARING
- | RTEMS_BINARY_SEMAPHORE,
- 1,
- &id
- );
- rtems_test_assert(sc == RTEMS_SUCCESSFUL);
+ create_mrsp_sema(ctx, &id, 1);
sc = rtems_semaphore_obtain(id, RTEMS_WAIT, RTEMS_NO_TIMEOUT);
rtems_test_assert(sc == RTEMS_SUCCESSFUL);
@@ -759,7 +744,7 @@ static void test_mrsp_nested_obtain_error(void)
rtems_test_assert(sc == RTEMS_SUCCESSFUL);
}
-static void test_mrsp_unlock_order_error(void)
+static void test_mrsp_unlock_order_error(test_context *ctx)
{
rtems_status_code sc;
rtems_id id_a;
@@ -767,25 +752,8 @@ static void test_mrsp_unlock_order_error(void)
puts("test MrsP unlock order error");
- sc = rtems_semaphore_create(
- rtems_build_name(' ', ' ', ' ', 'A'),
- 1,
- RTEMS_MULTIPROCESSOR_RESOURCE_SHARING
- | RTEMS_BINARY_SEMAPHORE,
- 1,
- &id_a
- );
- rtems_test_assert(sc == RTEMS_SUCCESSFUL);
-
- sc = rtems_semaphore_create(
- rtems_build_name(' ', ' ', ' ', 'B'),
- 1,
- RTEMS_MULTIPROCESSOR_RESOURCE_SHARING
- | RTEMS_BINARY_SEMAPHORE,
- 1,
- &id_b
- );
- rtems_test_assert(sc == RTEMS_SUCCESSFUL);
+ create_mrsp_sema(ctx, &id_a, 1);
+ create_mrsp_sema(ctx, &id_b, 1);
sc = rtems_semaphore_obtain(id_a, RTEMS_WAIT, RTEMS_NO_TIMEOUT);
rtems_test_assert(sc == RTEMS_SUCCESSFUL);
@@ -842,25 +810,8 @@ static void test_mrsp_deadlock_error(test_context *ctx)
change_prio(RTEMS_SELF, prio);
- sc = rtems_semaphore_create(
- rtems_build_name(' ', ' ', ' ', 'A'),
- 1,
- RTEMS_MULTIPROCESSOR_RESOURCE_SHARING
- | RTEMS_BINARY_SEMAPHORE,
- prio,
- &ctx->mrsp_ids[0]
- );
- rtems_test_assert(sc == RTEMS_SUCCESSFUL);
-
- sc = rtems_semaphore_create(
- rtems_build_name(' ', ' ', ' ', 'B'),
- 1,
- RTEMS_MULTIPROCESSOR_RESOURCE_SHARING
- | RTEMS_BINARY_SEMAPHORE,
- prio,
- &ctx->mrsp_ids[1]
- );
- rtems_test_assert(sc == RTEMS_SUCCESSFUL);
+ create_mrsp_sema(ctx, &ctx->mrsp_ids[0], prio);
+ create_mrsp_sema(ctx, &ctx->mrsp_ids[1], prio);
sc = rtems_task_create(
rtems_build_name('W', 'O', 'R', 'K'),
@@ -900,7 +851,7 @@ static void test_mrsp_deadlock_error(test_context *ctx)
rtems_test_assert(sc == RTEMS_SUCCESSFUL);
}
-static void test_mrsp_multiple_obtain(void)
+static void test_mrsp_multiple_obtain(test_context *ctx)
{
rtems_status_code sc;
rtems_id sem_a_id;
@@ -911,35 +862,9 @@ static void test_mrsp_multiple_obtain(void)
change_prio(RTEMS_SELF, 4);
- sc = rtems_semaphore_create(
- rtems_build_name(' ', ' ', ' ', 'A'),
- 1,
- RTEMS_MULTIPROCESSOR_RESOURCE_SHARING
- | RTEMS_BINARY_SEMAPHORE,
- 3,
- &sem_a_id
- );
- rtems_test_assert(sc == RTEMS_SUCCESSFUL);
-
- sc = rtems_semaphore_create(
- rtems_build_name(' ', ' ', ' ', 'B'),
- 1,
- RTEMS_MULTIPROCESSOR_RESOURCE_SHARING
- | RTEMS_BINARY_SEMAPHORE,
- 2,
- &sem_b_id
- );
- rtems_test_assert(sc == RTEMS_SUCCESSFUL);
-
- sc = rtems_semaphore_create(
- rtems_build_name(' ', ' ', ' ', 'C'),
- 1,
- RTEMS_MULTIPROCESSOR_RESOURCE_SHARING
- | RTEMS_BINARY_SEMAPHORE,
- 1,
- &sem_c_id
- );
- rtems_test_assert(sc == RTEMS_SUCCESSFUL);
+ create_mrsp_sema(ctx, &sem_a_id, 3);
+ create_mrsp_sema(ctx, &sem_b_id, 2);
+ create_mrsp_sema(ctx, &sem_c_id, 1);
assert_prio(RTEMS_SELF, 4);
@@ -1262,16 +1187,7 @@ static void test_mrsp_various_block_and_unblock(test_context *ctx)
ctx->high_run[0] = false;
ctx->high_run[1] = false;
- sc = rtems_semaphore_create(
- rtems_build_name(' ', ' ', ' ', 'A'),
- 1,
- RTEMS_MULTIPROCESSOR_RESOURCE_SHARING
- | RTEMS_BINARY_SEMAPHORE,
- 3,
- &ctx->mrsp_ids[0]
- );
- rtems_test_assert(sc == RTEMS_SUCCESSFUL);
-
+ create_mrsp_sema(ctx, &ctx->mrsp_ids[0], 3);
assert_prio(RTEMS_SELF, 4);
sc = rtems_task_create(
@@ -1379,15 +1295,7 @@ static void test_mrsp_obtain_and_sleep_and_release(test_context *ctx)
sc = rtems_task_start(run_task_id, run_task, (rtems_task_argument) &run);
rtems_test_assert(sc == RTEMS_SUCCESSFUL);
- sc = rtems_semaphore_create(
- rtems_build_name('S', 'E', 'M', 'A'),
- 1,
- RTEMS_MULTIPROCESSOR_RESOURCE_SHARING
- | RTEMS_BINARY_SEMAPHORE,
- 1,
- &sem_id
- );
- rtems_test_assert(sc == RTEMS_SUCCESSFUL);
+ create_mrsp_sema(ctx, &sem_id, 1);
rtems_test_assert(!run);
@@ -1448,15 +1356,7 @@ static void test_mrsp_obtain_and_release_with_help(test_context *ctx)
reset_switch_events(ctx);
- sc = rtems_semaphore_create(
- rtems_build_name('S', 'E', 'M', 'A'),
- 1,
- RTEMS_MULTIPROCESSOR_RESOURCE_SHARING
- | RTEMS_BINARY_SEMAPHORE,
- 2,
- &ctx->mrsp_ids[0]
- );
- rtems_test_assert(sc == RTEMS_SUCCESSFUL);
+ create_mrsp_sema(ctx, &ctx->mrsp_ids[0], 2);
sc = rtems_semaphore_obtain(ctx->mrsp_ids[0], RTEMS_WAIT, RTEMS_NO_TIMEOUT);
rtems_test_assert(sc == RTEMS_SUCCESSFUL);
@@ -1691,15 +1591,7 @@ static void test_mrsp_load(test_context *ctx)
rtems_test_assert(sc == RTEMS_SUCCESSFUL);
for (index = 0; index < MRSP_COUNT; ++index) {
- sc = rtems_semaphore_create(
- 'A' + index,
- 1,
- RTEMS_MULTIPROCESSOR_RESOURCE_SHARING
- | RTEMS_BINARY_SEMAPHORE,
- 3 + index,
- &ctx->mrsp_ids[index]
- );
- rtems_test_assert(sc == RTEMS_SUCCESSFUL);
+ create_mrsp_sema(ctx, &ctx->mrsp_ids[index], 3 + index);
}
for (index = 0; index < cpu_count; ++index) {
@@ -1851,12 +1743,12 @@ static void Init(rtems_task_argument arg)
rtems_test_assert(sc == RTEMS_SUCCESSFUL);
}
- test_mrsp_flush_error();
+ test_mrsp_flush_error(ctx);
test_mrsp_initially_locked_error();
- test_mrsp_nested_obtain_error();
- test_mrsp_unlock_order_error();
+ test_mrsp_nested_obtain_error(ctx);
+ test_mrsp_unlock_order_error(ctx);
test_mrsp_deadlock_error(ctx);
- test_mrsp_multiple_obtain();
+ test_mrsp_multiple_obtain(ctx);
if (cpu_count > 1) {
test_mrsp_various_block_and_unblock(ctx);
More information about the vc
mailing list