Index: testsuites/smptests/smpmrsp01/init.c
===================================================================
--- testsuites/smptests/smpmrsp01/init.c	(revision 0c1413c28476173022c70c451127d4bce361aac1)
+++ testsuites/smptests/smpmrsp01/init.c	(revision ec5d95e15e3c9ed00c0d1c6fd7785338fdb92d49)
@@ -215,4 +215,39 @@
 }
 
+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)
 {
@@ -322,13 +357,5 @@
   /* 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);
@@ -562,33 +589,7 @@
   /* 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;
@@ -688,5 +689,5 @@
 }
 
-static void test_mrsp_flush_error(void)
+static void test_mrsp_flush_error(test_context *ctx)
 {
   rtems_status_code sc;
@@ -695,13 +696,5 @@
   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);
@@ -730,5 +723,5 @@
 }
 
-static void test_mrsp_nested_obtain_error(void)
+static void test_mrsp_nested_obtain_error(test_context *ctx)
 {
   rtems_status_code sc;
@@ -737,13 +730,5 @@
   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);
@@ -760,5 +745,5 @@
 }
 
-static void test_mrsp_unlock_order_error(void)
+static void test_mrsp_unlock_order_error(test_context *ctx)
 {
   rtems_status_code sc;
@@ -768,23 +753,6 @@
   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);
@@ -843,23 +811,6 @@
   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(
@@ -901,5 +852,5 @@
 }
 
-static void test_mrsp_multiple_obtain(void)
+static void test_mrsp_multiple_obtain(test_context *ctx)
 {
   rtems_status_code sc;
@@ -912,33 +863,7 @@
   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);
@@ -1263,14 +1188,5 @@
   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);
 
@@ -1380,13 +1296,5 @@
   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);
@@ -1449,13 +1357,5 @@
   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);
@@ -1692,13 +1592,5 @@
 
   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);
   }
 
@@ -1852,10 +1744,10 @@
   }
 
-  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) {
