summaryrefslogtreecommitdiffstats
path: root/testsuites/smptests/smppsxmutex01/init.c
diff options
context:
space:
mode:
Diffstat (limited to 'testsuites/smptests/smppsxmutex01/init.c')
-rw-r--r--testsuites/smptests/smppsxmutex01/init.c64
1 files changed, 41 insertions, 23 deletions
diff --git a/testsuites/smptests/smppsxmutex01/init.c b/testsuites/smptests/smppsxmutex01/init.c
index 6dd0d020fd..6532f5868d 100644
--- a/testsuites/smptests/smppsxmutex01/init.c
+++ b/testsuites/smptests/smppsxmutex01/init.c
@@ -1,15 +1,28 @@
+/* SPDX-License-Identifier: BSD-2-Clause */
+
/*
- * Copyright (c) 2016 embedded brains GmbH. All rights reserved.
+ * Copyright (c) 2016 embedded brains GmbH & Co. KG
*
- * embedded brains GmbH
- * Dornierstr. 4
- * 82178 Puchheim
- * Germany
- * <rtems@embedded-brains.de>
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
*
- * The license and distribution terms for this file may be
- * found in the file LICENSE in this distribution or at
- * http://www.rtems.org/license/LICENSE.
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
*/
#ifdef HAVE_CONFIG_H
@@ -42,25 +55,11 @@ static test_context test_instance;
static void *thread_b(void *arg)
{
test_context *ctx;
- rtems_id scheduler_b_id;
- rtems_status_code sc;
- rtems_task_priority prio;
int prio_ceiling;
int eno;
ctx = arg;
- rtems_test_assert(rtems_scheduler_get_processor() == 0);
-
- sc = rtems_scheduler_ident(SCHED_B, &scheduler_b_id);
- rtems_test_assert(sc == RTEMS_SUCCESSFUL);
-
- sc = rtems_task_set_priority(pthread_self(), RTEMS_CURRENT_PRIORITY, &prio);
- rtems_test_assert(sc == RTEMS_SUCCESSFUL);
-
- sc = rtems_task_set_scheduler(pthread_self(), scheduler_b_id, prio);
- rtems_test_assert(sc == RTEMS_SUCCESSFUL);
-
rtems_test_assert(rtems_scheduler_get_processor() == 1);
eno = pthread_mutex_init(&ctx->mtx_b, &ctx->mtx_attr);
@@ -119,8 +118,24 @@ static void test(test_context *ctx)
rtems_test_assert(eno == 0);
if (cpu_count > 1) {
+ rtems_id scheduler_a_id;
+ rtems_id scheduler_b_id;
+ rtems_status_code sc;
+ rtems_task_priority prio;
void *exit_code;
+ sc = rtems_scheduler_ident(SCHED_A, &scheduler_a_id);
+ rtems_test_assert(sc == RTEMS_SUCCESSFUL);
+
+ sc = rtems_scheduler_ident(SCHED_B, &scheduler_b_id);
+ rtems_test_assert(sc == RTEMS_SUCCESSFUL);
+
+ sc = rtems_task_set_priority(pthread_self(), RTEMS_CURRENT_PRIORITY, &prio);
+ rtems_test_assert(sc == RTEMS_SUCCESSFUL);
+
+ sc = rtems_task_set_scheduler(pthread_self(), scheduler_b_id, prio);
+ rtems_test_assert(sc == RTEMS_SUCCESSFUL);
+
eno = pthread_create(&ctx->thread_b, NULL, thread_b, ctx);
rtems_test_assert(eno == 0);
@@ -128,6 +143,9 @@ static void test(test_context *ctx)
eno = pthread_join(ctx->thread_b, &exit_code);
rtems_test_assert(eno == 0);
rtems_test_assert(exit_code == ctx);
+
+ sc = rtems_task_set_scheduler(pthread_self(), scheduler_a_id, prio);
+ rtems_test_assert(sc == RTEMS_SUCCESSFUL);
}
eno = pthread_mutex_destroy(&ctx->mtx_a);