summaryrefslogtreecommitdiffstats
path: root/testsuites/tmtests/tmfine01/init.c
diff options
context:
space:
mode:
Diffstat (limited to 'testsuites/tmtests/tmfine01/init.c')
-rw-r--r--testsuites/tmtests/tmfine01/init.c149
1 files changed, 105 insertions, 44 deletions
diff --git a/testsuites/tmtests/tmfine01/init.c b/testsuites/tmtests/tmfine01/init.c
index e2daa174b9..c05894f6da 100644
--- a/testsuites/tmtests/tmfine01/init.c
+++ b/testsuites/tmtests/tmfine01/init.c
@@ -1,15 +1,28 @@
+/* SPDX-License-Identifier: BSD-2-Clause */
+
/*
- * Copyright (c) 2015, 2017 embedded brains GmbH. All rights reserved.
+ * Copyright (C) 2015, 2024 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,6 +55,8 @@ typedef struct {
typedef struct {
rtems_test_parallel_context base;
+ const char *test_sep;
+ const char *counter_sep;
rtems_id master;
rtems_id sema;
rtems_id mq[CPU_COUNT];
@@ -76,24 +91,46 @@ static rtems_interval test_init(
}
static void test_fini(
- const char *name,
+ test_context *ctx,
+ const char *type,
+ const char *description,
uint32_t *counters,
size_t active_workers
)
{
+ const char *value_sep;
size_t i;
- printf(" <%s activeWorker=\"%zu\">\n", name, active_workers);
+ if (active_workers == 1) {
+ printf(
+ "%s{\n"
+ " \"type\": \"%s\",\n"
+ " \"description\": \"%s\",\n"
+ " \"counter\": [",
+ ctx->test_sep,
+ type,
+ description
+ );
+ ctx->test_sep = ", ";
+ ctx->counter_sep = "\n ";
+ }
+
+ printf("%s[", ctx->counter_sep);
+ ctx->counter_sep = "],\n ";
+ value_sep = "";
for (i = 0; i < active_workers; ++i) {
printf(
- " <Counter worker=\"%zu\">%" PRIu32 "</Counter>\n",
- i,
+ "%s%" PRIu32,
+ value_sep,
counters[i]
);
+ value_sep = ", ";
}
- printf(" </%s>\n", name);
+ if (active_workers == rtems_scheduler_get_processor_maximum()) {
+ printf("]\n ]\n }");
+ }
}
static void test_self_event_body(
@@ -137,7 +174,9 @@ static void test_self_event_fini(
test_context *ctx = (test_context *) base;
test_fini(
- "SelfEvent",
+ ctx,
+ "event",
+ "Send Event to Self",
&ctx->self_event_ops[active_workers - 1][0],
active_workers
);
@@ -188,7 +227,9 @@ static void test_all_to_one_event_fini(
test_context *ctx = (test_context *) base;
test_fini(
- "AllToOneEvent",
+ ctx,
+ "event",
+ "Send Event to One",
&ctx->all_to_one_event_ops[active_workers - 1][0],
active_workers
);
@@ -229,7 +270,9 @@ static void test_one_mutex_fini(
test_context *ctx = (test_context *) base;
test_fini(
- "OneMutex",
+ ctx,
+ "contested-mutex",
+ "Obtain/Release Contested Classic Inheritance Mutex",
&ctx->one_mutex_ops[active_workers - 1][0],
active_workers
);
@@ -283,7 +326,9 @@ static void test_many_mutex_fini(
test_context *ctx = (test_context *) base;
test_fini(
- "ManyMutex",
+ ctx,
+ "private-mutex",
+ "Obtain/Release Private Classic Inheritance Mutex",
&ctx->many_mutex_ops[active_workers - 1][0],
active_workers
);
@@ -334,7 +379,9 @@ static void test_self_msg_fini(
test_context *ctx = (test_context *) base;
test_fini(
- "SelfMsg",
+ ctx,
+ "message",
+ "Send Message to Self",
&ctx->self_msg_ops[active_workers - 1][0],
active_workers
);
@@ -388,7 +435,9 @@ static void test_many_to_one_msg_fini(
test_context *ctx = (test_context *) base;
test_fini(
- "ManyToOneMsg",
+ ctx,
+ "message",
+ "Send Message to One Receiver",
&ctx->many_to_one_msg_ops[active_workers - 1][0],
active_workers
);
@@ -426,7 +475,9 @@ static void test_many_sys_lock_mutex_fini(
test_context *ctx = (test_context *) base;
test_fini(
- "ManySysLockMutex",
+ ctx,
+ "private-mutex",
+ "Obtain/Release Private <sys/lock.h> Mutex",
&ctx->many_sys_lock_mutex_ops[active_workers - 1][0],
active_workers
);
@@ -480,7 +531,9 @@ static void test_many_classic_ceiling_fini(
test_context *ctx = (test_context *) base;
test_fini(
- "ManyClassicCeilingMutex",
+ ctx,
+ "private-mutex",
+ "Obtain/Release Private Classic Ceiling Mutex",
&ctx->many_classic_ceiling_ops[active_workers - 1][0],
active_workers
);
@@ -535,7 +588,9 @@ static void test_many_classic_mrsp_fini(
test_context *ctx = (test_context *) base;
test_fini(
- "ManyClassicMrsPMutex",
+ ctx,
+ "private-mutex",
+ "Obtain/Release Private Classic MrsP Mutex",
&ctx->many_classic_mrsp_ops[active_workers - 1][0],
active_workers
);
@@ -578,7 +633,9 @@ static void test_many_pthread_spinlock_fini(
test_context *ctx = (test_context *) base;
test_fini(
- "ManyPthreadSpinlock",
+ ctx,
+ "private-mutex",
+ "Obtain/Release Private Pthread Spinlock",
&ctx->many_pthread_spinlock_ops[active_workers - 1][0],
active_workers
);
@@ -632,7 +689,9 @@ static void test_many_pthread_mutex_inherit_fini(
test_context *ctx = (test_context *) base;
test_fini(
- "ManyPthreadMutexInherit",
+ ctx,
+ "private-mutex",
+ "Obtain/Release Private Pthread Inheritance Mutex",
&ctx->many_pthread_mutex_inherit_ops[active_workers - 1][0],
active_workers
);
@@ -692,7 +751,9 @@ static void test_many_pthread_mutex_protect_fini(
test_context *ctx = (test_context *) base;
test_fini(
- "ManyPthreadMutexProtect",
+ ctx,
+ "private-mutex",
+ "Obtain/Release Private Pthread Ceiling Mutex",
&ctx->many_pthread_mutex_protect_ops[active_workers - 1][0],
active_workers
);
@@ -716,11 +777,6 @@ static const rtems_test_parallel_job test_jobs[] = {
.cascade = true
}, {
.init = test_init,
- .body = test_many_mutex_body,
- .fini = test_many_mutex_fini,
- .cascade = true
- }, {
- .init = test_init,
.body = test_self_msg_body,
.fini = test_self_msg_fini,
.cascade = true
@@ -731,33 +787,38 @@ static const rtems_test_parallel_job test_jobs[] = {
.cascade = true
}, {
.init = test_init,
+ .body = test_many_pthread_spinlock_body,
+ .fini = test_many_pthread_spinlock_fini,
+ .cascade = true
+ }, {
+ .init = test_init,
.body = test_many_sys_lock_mutex_body,
.fini = test_many_sys_lock_mutex_fini,
.cascade = true
}, {
.init = test_init,
- .body = test_many_classic_ceiling_body,
- .fini = test_many_classic_ceiling_fini,
+ .body = test_many_pthread_mutex_inherit_body,
+ .fini = test_many_pthread_mutex_inherit_fini,
.cascade = true
}, {
.init = test_init,
- .body = test_many_classic_mrsp_body,
- .fini = test_many_classic_mrsp_fini,
+ .body = test_many_mutex_body,
+ .fini = test_many_mutex_fini,
.cascade = true
}, {
.init = test_init,
- .body = test_many_pthread_spinlock_body,
- .fini = test_many_pthread_spinlock_fini,
+ .body = test_many_pthread_mutex_protect_body,
+ .fini = test_many_pthread_mutex_protect_fini,
.cascade = true
}, {
.init = test_init,
- .body = test_many_pthread_mutex_inherit_body,
- .fini = test_many_pthread_mutex_inherit_fini,
+ .body = test_many_classic_ceiling_body,
+ .fini = test_many_classic_ceiling_fini,
.cascade = true
}, {
.init = test_init,
- .body = test_many_pthread_mutex_protect_body,
- .fini = test_many_pthread_mutex_protect_fini,
+ .body = test_many_classic_mrsp_body,
+ .fini = test_many_classic_mrsp_fini,
.cascade = true
}
};
@@ -765,7 +826,6 @@ static const rtems_test_parallel_job test_jobs[] = {
static void Init(rtems_task_argument arg)
{
test_context *ctx = &test_instance;
- const char *test = "TestTimeFine01";
rtems_status_code sc;
size_t i;
@@ -793,8 +853,9 @@ static void Init(rtems_task_argument arg)
rtems_test_assert(sc == RTEMS_SUCCESSFUL);
}
- printf("<%s>\n", test);
+ printf("*** BEGIN OF JSON DATA ***\n[\n ");
+ ctx->test_sep = "";
rtems_test_parallel(
&ctx->base,
NULL,
@@ -802,7 +863,7 @@ static void Init(rtems_task_argument arg)
RTEMS_ARRAY_SIZE(test_jobs)
);
- printf("</%s>\n", test);
+ printf("\n]\n*** END OF JSON DATA ***\n");
TEST_END();
rtems_test_exit(0);