From 556e45f24b6c02a37fa20402fc84c927fc406dac Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Fri, 20 Dec 2019 09:29:33 +0100 Subject: libtest: Add T_check_task_context() action --- testsuites/libtests/Makefile.am | 1 + testsuites/libtests/ttest01/init.c | 10 ++++- testsuites/libtests/ttest01/test-task-context.c | 53 +++++++++++++++++++++++++ 3 files changed, 62 insertions(+), 2 deletions(-) create mode 100644 testsuites/libtests/ttest01/test-task-context.c (limited to 'testsuites/libtests') 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 #include +#include #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 + +#include + +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). + */ -- cgit v1.2.3