![]() |
|
|||
File indexing completed on 2025-05-11 08:24:53
0001 /* SPDX-License-Identifier: BSD-2-Clause */ 0002 0003 /** 0004 * @file 0005 * 0006 * @ingroup ScoreThreadValIdleBodyNoReturn 0007 */ 0008 0009 /* 0010 * Copyright (C) 2022 embedded brains GmbH & Co. KG 0011 * 0012 * Redistribution and use in source and binary forms, with or without 0013 * modification, are permitted provided that the following conditions 0014 * are met: 0015 * 1. Redistributions of source code must retain the above copyright 0016 * notice, this list of conditions and the following disclaimer. 0017 * 2. Redistributions in binary form must reproduce the above copyright 0018 * notice, this list of conditions and the following disclaimer in the 0019 * documentation and/or other materials provided with the distribution. 0020 * 0021 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 0022 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 0023 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 0024 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 0025 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 0026 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 0027 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 0028 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 0029 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 0030 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 0031 * POSSIBILITY OF SUCH DAMAGE. 0032 */ 0033 0034 /* 0035 * This file is part of the RTEMS quality process and was automatically 0036 * generated. If you find something that needs to be fixed or 0037 * worded better please post a report or patch to an RTEMS mailing list 0038 * or raise a bug report: 0039 * 0040 * https://www.rtems.org/bugs.html 0041 * 0042 * For information on updating and regenerating please refer to the How-To 0043 * section in the Software Requirements Engineering chapter of the 0044 * RTEMS Software Engineering manual. The manual is provided as a part of 0045 * a release. For development sources please refer to the online 0046 * documentation at: 0047 * 0048 * https://docs.rtems.org 0049 */ 0050 0051 #ifdef HAVE_CONFIG_H 0052 #include "config.h" 0053 #endif 0054 0055 #include <bsp.h> 0056 0057 #include "tx-support.h" 0058 0059 #include <rtems/test.h> 0060 0061 /** 0062 * @defgroup ScoreThreadValIdleBodyNoReturn \ 0063 * spec:/score/thread/val/idle-body-no-return 0064 * 0065 * @ingroup TestsuitesValidation0 0066 * 0067 * @brief Tests thread idle body behaviour. 0068 * 0069 * This test case performs the following actions: 0070 * 0071 * - Create threads which execute an thread idle body. Check that the thread 0072 * idle body does not return. If it would return, then an 0073 * INTERNAL_ERROR_THREAD_EXITTED fatal error would occur. 0074 * 0075 * - Check that the CPU port thread idle body does not return. 0076 * 0077 * - Where the BSP provides an idle thread body, check that it does not 0078 * return. 0079 * 0080 * - Clean up all used resources. 0081 * 0082 * @{ 0083 */ 0084 0085 /** 0086 * @brief Test context for spec:/score/thread/val/idle-body-no-return test 0087 * case. 0088 */ 0089 typedef struct { 0090 /** 0091 * @brief This member contains a counter. 0092 */ 0093 uint32_t counter; 0094 } ScoreThreadValIdleBodyNoReturn_Context; 0095 0096 static ScoreThreadValIdleBodyNoReturn_Context 0097 ScoreThreadValIdleBodyNoReturn_Instance; 0098 0099 typedef ScoreThreadValIdleBodyNoReturn_Context Context; 0100 0101 static void CheckIdleBody( Context *ctx, rtems_task_entry entry ) 0102 { 0103 rtems_id id; 0104 rtems_interval interval; 0105 rtems_status_code sc; 0106 0107 ctx->counter = 0; 0108 id = CreateTask( "WORK", PRIO_LOW ); 0109 StartTask( id, entry, ctx ); 0110 0111 /* 0112 * With optimization disabled, coverage enabled, SMP enabled and a slow 0113 * target, things may take some time. 0114 */ 0115 interval = 1; 0116 while ( ctx->counter == 0 && interval <= 1024 ) { 0117 0118 sc = rtems_task_wake_after( interval ); 0119 T_rsc_success( sc ); 0120 0121 interval *= 2; 0122 } 0123 0124 sc = rtems_task_wake_after( interval ); 0125 T_rsc_success( sc ); 0126 0127 T_eq_u32( ctx->counter, 1 ); 0128 DeleteTask( id ); 0129 } 0130 0131 static void CPUThreadIdleBody( rtems_task_argument arg ) 0132 { 0133 Context *ctx; 0134 0135 ctx = (Context *) arg; 0136 ++ctx->counter; 0137 0138 (void) _CPU_Thread_Idle_body( 0 ); 0139 } 0140 0141 #if defined(BSP_IDLE_TASK_BODY) 0142 static void BSPIdleTaskBody( rtems_task_argument arg ) 0143 { 0144 Context *ctx; 0145 0146 ctx = (Context *) arg; 0147 ++ctx->counter; 0148 0149 (void) BSP_IDLE_TASK_BODY( 0 ); 0150 } 0151 #endif 0152 0153 static T_fixture ScoreThreadValIdleBodyNoReturn_Fixture = { 0154 .setup = NULL, 0155 .stop = NULL, 0156 .teardown = NULL, 0157 .scope = NULL, 0158 .initial_context = &ScoreThreadValIdleBodyNoReturn_Instance 0159 }; 0160 0161 /** 0162 * @brief Create threads which execute an thread idle body. Check that the 0163 * thread idle body does not return. If it would return, then an 0164 * INTERNAL_ERROR_THREAD_EXITTED fatal error would occur. 0165 */ 0166 static void ScoreThreadValIdleBodyNoReturn_Action_0( 0167 ScoreThreadValIdleBodyNoReturn_Context *ctx 0168 ) 0169 { 0170 SetSelfPriority( PRIO_NORMAL ); 0171 0172 /* 0173 * Check that the CPU port thread idle body does not return. 0174 */ 0175 CheckIdleBody( ctx, CPUThreadIdleBody ); 0176 0177 /* 0178 * Where the BSP provides an idle thread body, check that it does not return. 0179 */ 0180 #if defined(BSP_IDLE_TASK_BODY) 0181 CheckIdleBody( ctx, BSPIdleTaskBody ); 0182 #endif 0183 0184 /* 0185 * Clean up all used resources. 0186 */ 0187 RestoreRunnerPriority(); 0188 } 0189 0190 /** 0191 * @fn void T_case_body_ScoreThreadValIdleBodyNoReturn( void ) 0192 */ 0193 T_TEST_CASE_FIXTURE( 0194 ScoreThreadValIdleBodyNoReturn, 0195 &ScoreThreadValIdleBodyNoReturn_Fixture 0196 ) 0197 { 0198 ScoreThreadValIdleBodyNoReturn_Context *ctx; 0199 0200 ctx = T_fixture_context(); 0201 0202 ScoreThreadValIdleBodyNoReturn_Action_0( ctx ); 0203 } 0204 0205 /** @} */
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |