forked from Imagelibrary/rtems
libtest: Add T_check_task_context() action
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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 *);
|
||||
|
||||
69
cpukit/libtest/t-test-rtems-context.c
Normal file
69
cpukit/libtest/t-test-rtems-context.c
Normal file
@@ -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;
|
||||
};
|
||||
}
|
||||
@@ -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) \
|
||||
|
||||
@@ -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,
|
||||
|
||||
53
testsuites/libtests/ttest01/test-task-context.c
Normal file
53
testsuites/libtests/ttest01/test-task-context.c
Normal file
@@ -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).
|
||||
*/
|
||||
Reference in New Issue
Block a user