summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2019-12-20 09:29:33 +0100
committerSebastian Huber <sebastian.huber@embedded-brains.de>2019-12-20 11:06:13 +0100
commit556e45f24b6c02a37fa20402fc84c927fc406dac (patch)
tree7ef0041d4a44d78867ffd286a327a3311fca70f8
parentlibtest: Use test configuration in T_now() (diff)
downloadrtems-556e45f24b6c02a37fa20402fc84c927fc406dac.tar.bz2
libtest: Add T_check_task_context() action
-rw-r--r--cpukit/Makefile.am1
-rw-r--r--cpukit/include/t.h2
-rw-r--r--cpukit/libtest/t-test-rtems-context.c69
-rw-r--r--testsuites/libtests/Makefile.am1
-rw-r--r--testsuites/libtests/ttest01/init.c10
-rw-r--r--testsuites/libtests/ttest01/test-task-context.c53
6 files changed, 134 insertions, 2 deletions
diff --git a/cpukit/Makefile.am b/cpukit/Makefile.am
index 2983fc5b9e..930f21aeb1 100644
--- a/cpukit/Makefile.am
+++ b/cpukit/Makefile.am
@@ -1853,6 +1853,7 @@ librtemstest_a_SOURCES += libtest/t-test-checks-psx.c
librtemstest_a_SOURCES += libtest/t-test-hash-sha256.c
librtemstest_a_SOURCES += libtest/t-test-malloc.c
librtemstest_a_SOURCES += libtest/t-test-rtems.c
+librtemstest_a_SOURCES += libtest/t-test-rtems-context.c
librtemstest_a_SOURCES += libtest/t-test-rtems-fds.c
librtemstest_a_SOURCES += libtest/t-test-rtems-heap.c
librtemstest_a_SOURCES += libtest/t-test-rtems-measure.c
diff --git a/cpukit/include/t.h b/cpukit/include/t.h
index 12a03b2a1c..ecdc03f94c 100644
--- a/cpukit/include/t.h
+++ b/cpukit/include/t.h
@@ -2266,6 +2266,8 @@ void T_report_hash_sha256(T_event, const char *);
void T_check_heap(T_event, const char *);
#ifdef __rtems__
+void T_check_task_context(T_event, const char *);
+
void T_check_file_descriptors(T_event, const char *);
void T_check_rtems_barriers(T_event, const char *);
diff --git a/cpukit/libtest/t-test-rtems-context.c b/cpukit/libtest/t-test-rtems-context.c
new file mode 100644
index 0000000000..b6b31e521c
--- /dev/null
+++ b/cpukit/libtest/t-test-rtems-context.c
@@ -0,0 +1,69 @@
+/*
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (C) 2019 embedded brains GmbH
+ *
+ * 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.
+ *
+ * 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.
+ */
+
+#undef __STRICT_ANSI__
+
+#include <t.h>
+
+#include <rtems/score/isrlevel.h>
+#include <rtems/score/percpu.h>
+#include <rtems/score/threaddispatch.h>
+
+#include <inttypes.h>
+
+static void
+T_do_check_task_context(void)
+{
+ uint32_t v;
+
+ v = _Thread_Dispatch_get_disable_level();
+ T_check_true(v == 0, NULL,
+ "Wrong thread dispatch disabled level (%" PRIu32 ")", v);
+
+ v = _ISR_Nest_level;
+ T_check_true(v == 0, NULL,
+ "Wrong ISR nest level (%" PRIu32 ")", v);
+
+ v = _ISR_Get_level();
+ T_check_true(v == 0, NULL,
+ "Wrong ISR level (%" PRIu32 ")", v);
+}
+
+void
+T_check_task_context(T_event event, const char *name)
+{
+ (void)name;
+
+ switch (event) {
+ case T_EVENT_RUN_INITIALIZE_LATE:
+ case T_EVENT_CASE_END:
+ T_do_check_task_context();
+ break;
+ default:
+ break;
+ };
+}
diff --git a/testsuites/libtests/Makefile.am b/testsuites/libtests/Makefile.am
index a22e153c30..f3bcde998d 100644
--- a/testsuites/libtests/Makefile.am
+++ b/testsuites/libtests/Makefile.am
@@ -1509,6 +1509,7 @@ ttest01_SOURCES += ttest01/test-psx.c
ttest01_SOURCES += ttest01/test-rtems.c
ttest01_SOURCES += ttest01/test-simple.c
ttest01_SOURCES += ttest01/test-step.c
+ttest01_SOURCES += ttest01/test-task-context.c
ttest01_SOURCES += ttest01/test-time.c
ttest01_SOURCES += ttest01/test-verbosity.c
ttest01_CPPFLAGS = $(AM_CPPFLAGS) $(TEST_FLAGS_ttest01) \
diff --git a/testsuites/libtests/ttest01/init.c b/testsuites/libtests/ttest01/init.c
index 31b57cf6f9..7abbd9e364 100644
--- a/testsuites/libtests/ttest01/init.c
+++ b/testsuites/libtests/ttest01/init.c
@@ -32,6 +32,7 @@
#include <rtems.h>
#include <rtems/bspIo.h>
+#include <rtems/score/threaddispatch.h>
#include "t-self-test.h"
@@ -112,6 +113,10 @@ case_late(const char *name)
{
test_context *ctx;
+ if (strcmp(name, "check_task_context") == 0) {
+ _Thread_Dispatch_enable(_Per_CPU_Get());
+ }
+
ctx = &test_instance;
++ctx->case_end_count;
test_assert(ctx->c != NULL);
@@ -177,8 +182,8 @@ run_initialize(void)
T_set_putchar(censor_putchar, ctx, &ctx->putchar, &ctx->putchar_arg);
}
-static const char expected_final[] = "Z:ttest01:C:341:N:1316:F:790:D:0.685999\n"
-"Y:ReportHash:SHA256:cb5ba027ade5b907d9e988776e393835f34a76cc2381d67bb9db44d986a3fecf\n";
+static const char expected_final[] = "Z:ttest01:C:342:N:1316:F:791:D:0.687999\n"
+"Y:ReportHash:SHA256:d4c293b499e6e557afcf6123cb604e8976cc5b987021f1f8c9f6193fc38a386e\n";
static void
run_finalize(void)
@@ -228,6 +233,7 @@ static char buffer[512];
static const T_action actions[] = {
T_report_hash_sha256,
test_action,
+ T_check_task_context,
T_check_file_descriptors,
T_check_rtems_barriers,
T_check_rtems_extensions,
diff --git a/testsuites/libtests/ttest01/test-task-context.c b/testsuites/libtests/ttest01/test-task-context.c
new file mode 100644
index 0000000000..1a82f745b5
--- /dev/null
+++ b/testsuites/libtests/ttest01/test-task-context.c
@@ -0,0 +1,53 @@
+#include <t.h>
+
+#include <rtems/score/threaddispatch.h>
+
+T_TEST_CASE(check_task_context)
+{
+ _Thread_Dispatch_disable();
+}
+
+#include "t-self-test.h"
+
+T_TEST_OUTPUT(check_task_context,
+"B:check_task_context\n"
+"F:*:0:UI1:*:*:Wrong thread dispatch disabled level (1)\n"
+"E:check_task_context:N:0:F:1:D:0.001000\n");
+
+/*
+ * The license is at the end of the file to be able to use the test code and
+ * output in examples in the documentation. This is also the reason for the
+ * dual licensing. The license for RTEMS documentation is CC-BY-SA-4.0.
+ */
+
+/*
+ * SPDX-License-Identifier: BSD-2-Clause OR CC-BY-SA-4.0
+ *
+ * Copyright (C) 2019 embedded brains GmbH
+ *
+ * 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.
+ *
+ * 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.
+ *
+ * ALTERNATIVELY, this software may be distributed under the terms of the
+ * Creative Commons Attribution-ShareAlike 4.0 International Public License as
+ * published by Creative Commons, PO Box 1866, Mountain View, CA 94042
+ * (https://creativecommons.org/licenses/by-sa/4.0/legalcode).
+ */