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 "ts-config.h"
0058 #include "tx-support.h"
0059
0060 #include <rtems/test.h>
0061
0062
0063
0064
0065
0066
0067
0068
0069
0070 typedef enum {
0071 RtemsSchedulerReqIdent_Pre_Name_Invalid,
0072 RtemsSchedulerReqIdent_Pre_Name_Valid,
0073 RtemsSchedulerReqIdent_Pre_Name_NA
0074 } RtemsSchedulerReqIdent_Pre_Name;
0075
0076 typedef enum {
0077 RtemsSchedulerReqIdent_Pre_Id_Valid,
0078 RtemsSchedulerReqIdent_Pre_Id_Null,
0079 RtemsSchedulerReqIdent_Pre_Id_NA
0080 } RtemsSchedulerReqIdent_Pre_Id;
0081
0082 typedef enum {
0083 RtemsSchedulerReqIdent_Post_Status_Ok,
0084 RtemsSchedulerReqIdent_Post_Status_InvAddr,
0085 RtemsSchedulerReqIdent_Post_Status_InvName,
0086 RtemsSchedulerReqIdent_Post_Status_NA
0087 } RtemsSchedulerReqIdent_Post_Status;
0088
0089 typedef enum {
0090 RtemsSchedulerReqIdent_Post_IdVar_Set,
0091 RtemsSchedulerReqIdent_Post_IdVar_Nop,
0092 RtemsSchedulerReqIdent_Post_IdVar_NA
0093 } RtemsSchedulerReqIdent_Post_IdVar;
0094
0095 typedef struct {
0096 uint8_t Skip : 1;
0097 uint8_t Pre_Name_NA : 1;
0098 uint8_t Pre_Id_NA : 1;
0099 uint8_t Post_Status : 2;
0100 uint8_t Post_IdVar : 2;
0101 } RtemsSchedulerReqIdent_Entry;
0102
0103
0104
0105
0106 typedef struct {
0107
0108
0109
0110 rtems_id id_value;
0111
0112
0113
0114
0115
0116 rtems_status_code status;
0117
0118
0119
0120
0121 rtems_name name;
0122
0123
0124
0125
0126 rtems_id *id;
0127
0128 struct {
0129
0130
0131
0132 size_t pcs[ 2 ];
0133
0134
0135
0136
0137 bool in_action_loop;
0138
0139
0140
0141
0142 size_t index;
0143
0144
0145
0146
0147 RtemsSchedulerReqIdent_Entry entry;
0148
0149
0150
0151
0152
0153 bool skip;
0154 } Map;
0155 } RtemsSchedulerReqIdent_Context;
0156
0157 static RtemsSchedulerReqIdent_Context
0158 RtemsSchedulerReqIdent_Instance;
0159
0160 static const char * const RtemsSchedulerReqIdent_PreDesc_Name[] = {
0161 "Invalid",
0162 "Valid",
0163 "NA"
0164 };
0165
0166 static const char * const RtemsSchedulerReqIdent_PreDesc_Id[] = {
0167 "Valid",
0168 "Null",
0169 "NA"
0170 };
0171
0172 static const char * const * const RtemsSchedulerReqIdent_PreDesc[] = {
0173 RtemsSchedulerReqIdent_PreDesc_Name,
0174 RtemsSchedulerReqIdent_PreDesc_Id,
0175 NULL
0176 };
0177
0178 static void RtemsSchedulerReqIdent_Pre_Name_Prepare(
0179 RtemsSchedulerReqIdent_Context *ctx,
0180 RtemsSchedulerReqIdent_Pre_Name state
0181 )
0182 {
0183 switch ( state ) {
0184 case RtemsSchedulerReqIdent_Pre_Name_Invalid: {
0185
0186
0187
0188 ctx->name = 0;
0189 break;
0190 }
0191
0192 case RtemsSchedulerReqIdent_Pre_Name_Valid: {
0193
0194
0195
0196 ctx->name = TEST_SCHEDULER_A_NAME;
0197 break;
0198 }
0199
0200 case RtemsSchedulerReqIdent_Pre_Name_NA:
0201 break;
0202 }
0203 }
0204
0205 static void RtemsSchedulerReqIdent_Pre_Id_Prepare(
0206 RtemsSchedulerReqIdent_Context *ctx,
0207 RtemsSchedulerReqIdent_Pre_Id state
0208 )
0209 {
0210 switch ( state ) {
0211 case RtemsSchedulerReqIdent_Pre_Id_Valid: {
0212
0213
0214
0215 ctx->id = &ctx->id_value;
0216 break;
0217 }
0218
0219 case RtemsSchedulerReqIdent_Pre_Id_Null: {
0220
0221
0222
0223 ctx->id = NULL;
0224 break;
0225 }
0226
0227 case RtemsSchedulerReqIdent_Pre_Id_NA:
0228 break;
0229 }
0230 }
0231
0232 static void RtemsSchedulerReqIdent_Post_Status_Check(
0233 RtemsSchedulerReqIdent_Context *ctx,
0234 RtemsSchedulerReqIdent_Post_Status state
0235 )
0236 {
0237 switch ( state ) {
0238 case RtemsSchedulerReqIdent_Post_Status_Ok: {
0239
0240
0241
0242
0243 T_rsc_success( ctx->status );
0244 break;
0245 }
0246
0247 case RtemsSchedulerReqIdent_Post_Status_InvAddr: {
0248
0249
0250
0251
0252 T_rsc( ctx->status, RTEMS_INVALID_ADDRESS );
0253 break;
0254 }
0255
0256 case RtemsSchedulerReqIdent_Post_Status_InvName: {
0257
0258
0259
0260
0261 T_rsc( ctx->status, RTEMS_INVALID_NAME );
0262 break;
0263 }
0264
0265 case RtemsSchedulerReqIdent_Post_Status_NA:
0266 break;
0267 }
0268 }
0269
0270 static void RtemsSchedulerReqIdent_Post_IdVar_Check(
0271 RtemsSchedulerReqIdent_Context *ctx,
0272 RtemsSchedulerReqIdent_Post_IdVar state
0273 )
0274 {
0275 switch ( state ) {
0276 case RtemsSchedulerReqIdent_Post_IdVar_Set: {
0277
0278
0279
0280
0281
0282
0283 T_eq_ptr( ctx->id, &ctx->id_value );
0284 T_eq_u32( ctx->id_value, 0x0f010001 );
0285 break;
0286 }
0287
0288 case RtemsSchedulerReqIdent_Post_IdVar_Nop: {
0289
0290
0291
0292
0293
0294 T_eq_u32( ctx->id_value, INVALID_ID );
0295 break;
0296 }
0297
0298 case RtemsSchedulerReqIdent_Post_IdVar_NA:
0299 break;
0300 }
0301 }
0302
0303 static void RtemsSchedulerReqIdent_Prepare(
0304 RtemsSchedulerReqIdent_Context *ctx
0305 )
0306 {
0307 ctx->id_value = INVALID_ID;
0308 }
0309
0310 static void RtemsSchedulerReqIdent_Action(
0311 RtemsSchedulerReqIdent_Context *ctx
0312 )
0313 {
0314 ctx->status = rtems_scheduler_ident( ctx->name, ctx->id );
0315 }
0316
0317 static const RtemsSchedulerReqIdent_Entry
0318 RtemsSchedulerReqIdent_Entries[] = {
0319 { 0, 0, 0, RtemsSchedulerReqIdent_Post_Status_InvAddr,
0320 RtemsSchedulerReqIdent_Post_IdVar_Nop },
0321 { 0, 0, 0, RtemsSchedulerReqIdent_Post_Status_InvName,
0322 RtemsSchedulerReqIdent_Post_IdVar_Nop },
0323 { 0, 0, 0, RtemsSchedulerReqIdent_Post_Status_Ok,
0324 RtemsSchedulerReqIdent_Post_IdVar_Set }
0325 };
0326
0327 static const uint8_t
0328 RtemsSchedulerReqIdent_Map[] = {
0329 1, 0, 2, 0
0330 };
0331
0332 static size_t RtemsSchedulerReqIdent_Scope( void *arg, char *buf, size_t n )
0333 {
0334 RtemsSchedulerReqIdent_Context *ctx;
0335
0336 ctx = arg;
0337
0338 if ( ctx->Map.in_action_loop ) {
0339 return T_get_scope( RtemsSchedulerReqIdent_PreDesc, buf, n, ctx->Map.pcs );
0340 }
0341
0342 return 0;
0343 }
0344
0345 static T_fixture RtemsSchedulerReqIdent_Fixture = {
0346 .setup = NULL,
0347 .stop = NULL,
0348 .teardown = NULL,
0349 .scope = RtemsSchedulerReqIdent_Scope,
0350 .initial_context = &RtemsSchedulerReqIdent_Instance
0351 };
0352
0353 static inline RtemsSchedulerReqIdent_Entry RtemsSchedulerReqIdent_PopEntry(
0354 RtemsSchedulerReqIdent_Context *ctx
0355 )
0356 {
0357 size_t index;
0358
0359 index = ctx->Map.index;
0360 ctx->Map.index = index + 1;
0361 return RtemsSchedulerReqIdent_Entries[
0362 RtemsSchedulerReqIdent_Map[ index ]
0363 ];
0364 }
0365
0366 static void RtemsSchedulerReqIdent_TestVariant(
0367 RtemsSchedulerReqIdent_Context *ctx
0368 )
0369 {
0370 RtemsSchedulerReqIdent_Pre_Name_Prepare( ctx, ctx->Map.pcs[ 0 ] );
0371 RtemsSchedulerReqIdent_Pre_Id_Prepare( ctx, ctx->Map.pcs[ 1 ] );
0372 RtemsSchedulerReqIdent_Action( ctx );
0373 RtemsSchedulerReqIdent_Post_Status_Check( ctx, ctx->Map.entry.Post_Status );
0374 RtemsSchedulerReqIdent_Post_IdVar_Check( ctx, ctx->Map.entry.Post_IdVar );
0375 }
0376
0377
0378
0379
0380 T_TEST_CASE_FIXTURE( RtemsSchedulerReqIdent, &RtemsSchedulerReqIdent_Fixture )
0381 {
0382 RtemsSchedulerReqIdent_Context *ctx;
0383
0384 ctx = T_fixture_context();
0385 ctx->Map.in_action_loop = true;
0386 ctx->Map.index = 0;
0387
0388 for (
0389 ctx->Map.pcs[ 0 ] = RtemsSchedulerReqIdent_Pre_Name_Invalid;
0390 ctx->Map.pcs[ 0 ] < RtemsSchedulerReqIdent_Pre_Name_NA;
0391 ++ctx->Map.pcs[ 0 ]
0392 ) {
0393 for (
0394 ctx->Map.pcs[ 1 ] = RtemsSchedulerReqIdent_Pre_Id_Valid;
0395 ctx->Map.pcs[ 1 ] < RtemsSchedulerReqIdent_Pre_Id_NA;
0396 ++ctx->Map.pcs[ 1 ]
0397 ) {
0398 ctx->Map.entry = RtemsSchedulerReqIdent_PopEntry( ctx );
0399 RtemsSchedulerReqIdent_Prepare( ctx );
0400 RtemsSchedulerReqIdent_TestVariant( ctx );
0401 }
0402 }
0403 }
0404
0405