File indexing completed on 2025-05-11 08:24:52
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051 #ifdef HAVE_CONFIG_H
0052 #include "config.h"
0053 #endif
0054
0055 #include <rtems.h>
0056
0057 #include "tx-support.h"
0058
0059 #include <rtems/test.h>
0060
0061
0062
0063
0064
0065
0066
0067
0068
0069 typedef enum {
0070 RtemsTaskReqIsSuspended_Pre_Id_Invalid,
0071 RtemsTaskReqIsSuspended_Pre_Id_Task,
0072 RtemsTaskReqIsSuspended_Pre_Id_NA
0073 } RtemsTaskReqIsSuspended_Pre_Id;
0074
0075 typedef enum {
0076 RtemsTaskReqIsSuspended_Pre_Suspended_Yes,
0077 RtemsTaskReqIsSuspended_Pre_Suspended_No,
0078 RtemsTaskReqIsSuspended_Pre_Suspended_NA
0079 } RtemsTaskReqIsSuspended_Pre_Suspended;
0080
0081 typedef enum {
0082 RtemsTaskReqIsSuspended_Post_Status_Ok,
0083 RtemsTaskReqIsSuspended_Post_Status_InvId,
0084 RtemsTaskReqIsSuspended_Post_Status_AlrdySus,
0085 RtemsTaskReqIsSuspended_Post_Status_NA
0086 } RtemsTaskReqIsSuspended_Post_Status;
0087
0088 typedef struct {
0089 uint8_t Skip : 1;
0090 uint8_t Pre_Id_NA : 1;
0091 uint8_t Pre_Suspended_NA : 1;
0092 uint8_t Post_Status : 2;
0093 } RtemsTaskReqIsSuspended_Entry;
0094
0095
0096
0097
0098 typedef struct {
0099
0100
0101
0102 rtems_id worker_id;
0103
0104
0105
0106
0107
0108 bool suspend;
0109
0110
0111
0112
0113
0114 rtems_status_code status;
0115
0116
0117
0118
0119 rtems_id id;
0120
0121 struct {
0122
0123
0124
0125
0126 size_t pci[ 2 ];
0127
0128
0129
0130
0131 size_t pcs[ 2 ];
0132
0133
0134
0135
0136 bool in_action_loop;
0137
0138
0139
0140
0141 size_t index;
0142
0143
0144
0145
0146 RtemsTaskReqIsSuspended_Entry entry;
0147
0148
0149
0150
0151
0152 bool skip;
0153 } Map;
0154 } RtemsTaskReqIsSuspended_Context;
0155
0156 static RtemsTaskReqIsSuspended_Context
0157 RtemsTaskReqIsSuspended_Instance;
0158
0159 static const char * const RtemsTaskReqIsSuspended_PreDesc_Id[] = {
0160 "Invalid",
0161 "Task",
0162 "NA"
0163 };
0164
0165 static const char * const RtemsTaskReqIsSuspended_PreDesc_Suspended[] = {
0166 "Yes",
0167 "No",
0168 "NA"
0169 };
0170
0171 static const char * const * const RtemsTaskReqIsSuspended_PreDesc[] = {
0172 RtemsTaskReqIsSuspended_PreDesc_Id,
0173 RtemsTaskReqIsSuspended_PreDesc_Suspended,
0174 NULL
0175 };
0176
0177 static void Worker( rtems_task_argument arg )
0178 {
0179 while ( true ) {
0180
0181 }
0182 }
0183
0184 static void RtemsTaskReqIsSuspended_Pre_Id_Prepare(
0185 RtemsTaskReqIsSuspended_Context *ctx,
0186 RtemsTaskReqIsSuspended_Pre_Id state
0187 )
0188 {
0189 switch ( state ) {
0190 case RtemsTaskReqIsSuspended_Pre_Id_Invalid: {
0191
0192
0193
0194 ctx->id = INVALID_ID;
0195 break;
0196 }
0197
0198 case RtemsTaskReqIsSuspended_Pre_Id_Task: {
0199
0200
0201
0202 ctx->id = ctx->worker_id;
0203 break;
0204 }
0205
0206 case RtemsTaskReqIsSuspended_Pre_Id_NA:
0207 break;
0208 }
0209 }
0210
0211 static void RtemsTaskReqIsSuspended_Pre_Suspended_Prepare(
0212 RtemsTaskReqIsSuspended_Context *ctx,
0213 RtemsTaskReqIsSuspended_Pre_Suspended state
0214 )
0215 {
0216 switch ( state ) {
0217 case RtemsTaskReqIsSuspended_Pre_Suspended_Yes: {
0218
0219
0220
0221 ctx->suspend = true;
0222 break;
0223 }
0224
0225 case RtemsTaskReqIsSuspended_Pre_Suspended_No: {
0226
0227
0228
0229 ctx->suspend = false;
0230 break;
0231 }
0232
0233 case RtemsTaskReqIsSuspended_Pre_Suspended_NA:
0234 break;
0235 }
0236 }
0237
0238 static void RtemsTaskReqIsSuspended_Post_Status_Check(
0239 RtemsTaskReqIsSuspended_Context *ctx,
0240 RtemsTaskReqIsSuspended_Post_Status state
0241 )
0242 {
0243 switch ( state ) {
0244 case RtemsTaskReqIsSuspended_Post_Status_Ok: {
0245
0246
0247
0248
0249 T_rsc_success( ctx->status );
0250 break;
0251 }
0252
0253 case RtemsTaskReqIsSuspended_Post_Status_InvId: {
0254
0255
0256
0257
0258 T_rsc( ctx->status, RTEMS_INVALID_ID );
0259 break;
0260 }
0261
0262 case RtemsTaskReqIsSuspended_Post_Status_AlrdySus: {
0263
0264
0265
0266
0267 T_rsc( ctx->status, RTEMS_ALREADY_SUSPENDED );
0268 break;
0269 }
0270
0271 case RtemsTaskReqIsSuspended_Post_Status_NA:
0272 break;
0273 }
0274 }
0275
0276 static void RtemsTaskReqIsSuspended_Setup(
0277 RtemsTaskReqIsSuspended_Context *ctx
0278 )
0279 {
0280 ctx->worker_id = CreateTask( "WORK", PRIO_LOW );
0281 StartTask( ctx->worker_id, Worker, ctx );
0282 }
0283
0284 static void RtemsTaskReqIsSuspended_Setup_Wrap( void *arg )
0285 {
0286 RtemsTaskReqIsSuspended_Context *ctx;
0287
0288 ctx = arg;
0289 ctx->Map.in_action_loop = false;
0290 RtemsTaskReqIsSuspended_Setup( ctx );
0291 }
0292
0293 static void RtemsTaskReqIsSuspended_Teardown(
0294 RtemsTaskReqIsSuspended_Context *ctx
0295 )
0296 {
0297 DeleteTask( ctx->worker_id );
0298 }
0299
0300 static void RtemsTaskReqIsSuspended_Teardown_Wrap( void *arg )
0301 {
0302 RtemsTaskReqIsSuspended_Context *ctx;
0303
0304 ctx = arg;
0305 ctx->Map.in_action_loop = false;
0306 RtemsTaskReqIsSuspended_Teardown( ctx );
0307 }
0308
0309 static void RtemsTaskReqIsSuspended_Action(
0310 RtemsTaskReqIsSuspended_Context *ctx
0311 )
0312 {
0313 if ( ctx->suspend ) {
0314 SuspendTask( ctx->worker_id );
0315 }
0316
0317 ctx->status = rtems_task_is_suspended( ctx->id );
0318
0319 if ( ctx->suspend ) {
0320 ResumeTask( ctx->worker_id );
0321 }
0322 }
0323
0324 static const RtemsTaskReqIsSuspended_Entry
0325 RtemsTaskReqIsSuspended_Entries[] = {
0326 { 0, 0, 1, RtemsTaskReqIsSuspended_Post_Status_InvId },
0327 { 0, 0, 0, RtemsTaskReqIsSuspended_Post_Status_AlrdySus },
0328 { 0, 0, 0, RtemsTaskReqIsSuspended_Post_Status_Ok }
0329 };
0330
0331 static const uint8_t
0332 RtemsTaskReqIsSuspended_Map[] = {
0333 0, 0, 1, 2
0334 };
0335
0336 static size_t RtemsTaskReqIsSuspended_Scope( void *arg, char *buf, size_t n )
0337 {
0338 RtemsTaskReqIsSuspended_Context *ctx;
0339
0340 ctx = arg;
0341
0342 if ( ctx->Map.in_action_loop ) {
0343 return T_get_scope(
0344 RtemsTaskReqIsSuspended_PreDesc,
0345 buf,
0346 n,
0347 ctx->Map.pcs
0348 );
0349 }
0350
0351 return 0;
0352 }
0353
0354 static T_fixture RtemsTaskReqIsSuspended_Fixture = {
0355 .setup = RtemsTaskReqIsSuspended_Setup_Wrap,
0356 .stop = NULL,
0357 .teardown = RtemsTaskReqIsSuspended_Teardown_Wrap,
0358 .scope = RtemsTaskReqIsSuspended_Scope,
0359 .initial_context = &RtemsTaskReqIsSuspended_Instance
0360 };
0361
0362 static inline RtemsTaskReqIsSuspended_Entry RtemsTaskReqIsSuspended_PopEntry(
0363 RtemsTaskReqIsSuspended_Context *ctx
0364 )
0365 {
0366 size_t index;
0367
0368 index = ctx->Map.index;
0369 ctx->Map.index = index + 1;
0370 return RtemsTaskReqIsSuspended_Entries[
0371 RtemsTaskReqIsSuspended_Map[ index ]
0372 ];
0373 }
0374
0375 static void RtemsTaskReqIsSuspended_SetPreConditionStates(
0376 RtemsTaskReqIsSuspended_Context *ctx
0377 )
0378 {
0379 ctx->Map.pcs[ 0 ] = ctx->Map.pci[ 0 ];
0380
0381 if ( ctx->Map.entry.Pre_Suspended_NA ) {
0382 ctx->Map.pcs[ 1 ] = RtemsTaskReqIsSuspended_Pre_Suspended_NA;
0383 } else {
0384 ctx->Map.pcs[ 1 ] = ctx->Map.pci[ 1 ];
0385 }
0386 }
0387
0388 static void RtemsTaskReqIsSuspended_TestVariant(
0389 RtemsTaskReqIsSuspended_Context *ctx
0390 )
0391 {
0392 RtemsTaskReqIsSuspended_Pre_Id_Prepare( ctx, ctx->Map.pcs[ 0 ] );
0393 RtemsTaskReqIsSuspended_Pre_Suspended_Prepare( ctx, ctx->Map.pcs[ 1 ] );
0394 RtemsTaskReqIsSuspended_Action( ctx );
0395 RtemsTaskReqIsSuspended_Post_Status_Check( ctx, ctx->Map.entry.Post_Status );
0396 }
0397
0398
0399
0400
0401 T_TEST_CASE_FIXTURE(
0402 RtemsTaskReqIsSuspended,
0403 &RtemsTaskReqIsSuspended_Fixture
0404 )
0405 {
0406 RtemsTaskReqIsSuspended_Context *ctx;
0407
0408 ctx = T_fixture_context();
0409 ctx->Map.in_action_loop = true;
0410 ctx->Map.index = 0;
0411
0412 for (
0413 ctx->Map.pci[ 0 ] = RtemsTaskReqIsSuspended_Pre_Id_Invalid;
0414 ctx->Map.pci[ 0 ] < RtemsTaskReqIsSuspended_Pre_Id_NA;
0415 ++ctx->Map.pci[ 0 ]
0416 ) {
0417 for (
0418 ctx->Map.pci[ 1 ] = RtemsTaskReqIsSuspended_Pre_Suspended_Yes;
0419 ctx->Map.pci[ 1 ] < RtemsTaskReqIsSuspended_Pre_Suspended_NA;
0420 ++ctx->Map.pci[ 1 ]
0421 ) {
0422 ctx->Map.entry = RtemsTaskReqIsSuspended_PopEntry( ctx );
0423 RtemsTaskReqIsSuspended_SetPreConditionStates( ctx );
0424 RtemsTaskReqIsSuspended_TestVariant( ctx );
0425 }
0426 }
0427 }
0428
0429