File indexing completed on 2025-05-11 08:24:53
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 "tr-object-ident.h"
0056
0057 #include <rtems/test.h>
0058
0059
0060
0061
0062
0063
0064
0065
0066
0067 typedef struct {
0068 uint16_t Skip : 1;
0069 uint16_t Pre_Name_NA : 1;
0070 uint16_t Pre_Node_NA : 1;
0071 uint16_t Pre_Id_NA : 1;
0072 uint16_t Post_Status : 3;
0073 uint16_t Post_Id : 3;
0074 } RtemsReqIdent_Entry;
0075
0076
0077
0078
0079 typedef struct {
0080 rtems_status_code status;
0081
0082 rtems_name name;
0083
0084 uint32_t node;
0085
0086 rtems_id *id;
0087
0088 rtems_id id_value;
0089
0090 rtems_id id_remote_object;
0091
0092
0093
0094
0095
0096 rtems_id id_local_object;
0097
0098
0099
0100
0101
0102 rtems_name name_local_object;
0103
0104
0105
0106
0107
0108 rtems_status_code ( *action )( rtems_name, uint32_t, rtems_id * );
0109
0110 struct {
0111
0112
0113
0114 size_t pcs[ 3 ];
0115
0116
0117
0118
0119 bool in_action_loop;
0120
0121
0122
0123
0124 size_t index;
0125
0126
0127
0128
0129 RtemsReqIdent_Entry entry;
0130
0131
0132
0133
0134
0135 bool skip;
0136 } Map;
0137 } RtemsReqIdent_Context;
0138
0139 static RtemsReqIdent_Context
0140 RtemsReqIdent_Instance;
0141
0142 static const char * const RtemsReqIdent_PreDesc_Name[] = {
0143 "Invalid",
0144 "Valid",
0145 "NA"
0146 };
0147
0148 static const char * const RtemsReqIdent_PreDesc_Node[] = {
0149 "Local",
0150 "Remote",
0151 "Invalid",
0152 "SearchAll",
0153 "SearchOther",
0154 "SearchLocal",
0155 "NA"
0156 };
0157
0158 static const char * const RtemsReqIdent_PreDesc_Id[] = {
0159 "Valid",
0160 "Null",
0161 "NA"
0162 };
0163
0164 static const char * const * const RtemsReqIdent_PreDesc[] = {
0165 RtemsReqIdent_PreDesc_Name,
0166 RtemsReqIdent_PreDesc_Node,
0167 RtemsReqIdent_PreDesc_Id,
0168 NULL
0169 };
0170
0171 static void RtemsReqIdent_Pre_Name_Prepare(
0172 RtemsReqIdent_Context *ctx,
0173 RtemsReqIdent_Pre_Name state
0174 )
0175 {
0176 switch ( state ) {
0177 case RtemsReqIdent_Pre_Name_Invalid: {
0178
0179
0180
0181
0182 ctx->name = 1;
0183 break;
0184 }
0185
0186 case RtemsReqIdent_Pre_Name_Valid: {
0187
0188
0189
0190
0191 ctx->name = ctx->name_local_object;
0192 break;
0193 }
0194
0195 case RtemsReqIdent_Pre_Name_NA:
0196 break;
0197 }
0198 }
0199
0200 static void RtemsReqIdent_Pre_Node_Prepare(
0201 RtemsReqIdent_Context *ctx,
0202 RtemsReqIdent_Pre_Node state
0203 )
0204 {
0205 switch ( state ) {
0206 case RtemsReqIdent_Pre_Node_Local: {
0207
0208
0209
0210 ctx->node = 1;
0211 break;
0212 }
0213
0214 case RtemsReqIdent_Pre_Node_Remote: {
0215
0216
0217
0218 ctx->node = 2;
0219 break;
0220 }
0221
0222 case RtemsReqIdent_Pre_Node_Invalid: {
0223
0224
0225
0226 ctx->node = 256;
0227 break;
0228 }
0229
0230 case RtemsReqIdent_Pre_Node_SearchAll: {
0231
0232
0233
0234 ctx->node = RTEMS_SEARCH_ALL_NODES;
0235 break;
0236 }
0237
0238 case RtemsReqIdent_Pre_Node_SearchOther: {
0239
0240
0241
0242 ctx->node = RTEMS_SEARCH_OTHER_NODES;
0243 break;
0244 }
0245
0246 case RtemsReqIdent_Pre_Node_SearchLocal: {
0247
0248
0249
0250 ctx->node = RTEMS_SEARCH_LOCAL_NODE;
0251 break;
0252 }
0253
0254 case RtemsReqIdent_Pre_Node_NA:
0255 break;
0256 }
0257 }
0258
0259 static void RtemsReqIdent_Pre_Id_Prepare(
0260 RtemsReqIdent_Context *ctx,
0261 RtemsReqIdent_Pre_Id state
0262 )
0263 {
0264 switch ( state ) {
0265 case RtemsReqIdent_Pre_Id_Valid: {
0266
0267
0268
0269 ctx->id_value = 0xffffffff;
0270 ctx->id = &ctx->id_value;
0271 break;
0272 }
0273
0274 case RtemsReqIdent_Pre_Id_Null: {
0275
0276
0277
0278 ctx->id = NULL;
0279 break;
0280 }
0281
0282 case RtemsReqIdent_Pre_Id_NA:
0283 break;
0284 }
0285 }
0286
0287 static void RtemsReqIdent_Post_Status_Check(
0288 RtemsReqIdent_Context *ctx,
0289 RtemsReqIdent_Post_Status state
0290 )
0291 {
0292 switch ( state ) {
0293 case RtemsReqIdent_Post_Status_Ok: {
0294
0295
0296
0297 T_rsc(ctx->status, RTEMS_SUCCESSFUL);
0298 break;
0299 }
0300
0301 case RtemsReqIdent_Post_Status_InvAddr: {
0302
0303
0304
0305 T_rsc(ctx->status, RTEMS_INVALID_ADDRESS);
0306 break;
0307 }
0308
0309 case RtemsReqIdent_Post_Status_InvName: {
0310
0311
0312
0313 T_rsc(ctx->status, RTEMS_INVALID_NAME);
0314 break;
0315 }
0316
0317 case RtemsReqIdent_Post_Status_InvNode: {
0318
0319
0320
0321 T_rsc(ctx->status, RTEMS_INVALID_NODE);
0322 break;
0323 }
0324
0325 case RtemsReqIdent_Post_Status_NA:
0326 break;
0327 }
0328 }
0329
0330 static void RtemsReqIdent_Post_Id_Check(
0331 RtemsReqIdent_Context *ctx,
0332 RtemsReqIdent_Post_Id state
0333 )
0334 {
0335 switch ( state ) {
0336 case RtemsReqIdent_Post_Id_Nop: {
0337
0338
0339
0340
0341 T_eq_ptr(ctx->id, &ctx->id_value);
0342 T_eq_u32(ctx->id_value, 0xffffffff);
0343 break;
0344 }
0345
0346 case RtemsReqIdent_Post_Id_Null: {
0347
0348
0349
0350 T_null(ctx->id)
0351 break;
0352 }
0353
0354 case RtemsReqIdent_Post_Id_LocalObj: {
0355
0356
0357
0358
0359
0360
0361
0362 T_eq_ptr(ctx->id, &ctx->id_value);
0363 T_eq_u32(ctx->id_value, ctx->id_local_object);
0364 break;
0365 }
0366
0367 case RtemsReqIdent_Post_Id_RemoteObj: {
0368
0369
0370
0371
0372
0373
0374
0375
0376
0377
0378
0379 T_eq_ptr(ctx->id, &ctx->id_value);
0380 T_eq_u32(ctx->id_value, ctx->id_remote_object);
0381 break;
0382 }
0383
0384 case RtemsReqIdent_Post_Id_NA:
0385 break;
0386 }
0387 }
0388
0389 static void RtemsReqIdent_Action( RtemsReqIdent_Context *ctx )
0390 {
0391 ctx->status = ( *ctx->action )( ctx->name, ctx->node, ctx->id );
0392 }
0393
0394 static const RtemsReqIdent_Entry
0395 RtemsReqIdent_Entries[] = {
0396 { 0, 0, 0, 0, RtemsReqIdent_Post_Status_InvAddr, RtemsReqIdent_Post_Id_Null },
0397 { 0, 0, 0, 0, RtemsReqIdent_Post_Status_InvName, RtemsReqIdent_Post_Id_Nop },
0398 { 0, 0, 0, 0, RtemsReqIdent_Post_Status_Ok, RtemsReqIdent_Post_Id_LocalObj },
0399 #if defined(RTEMS_MULTIPROCESSING)
0400 { 0, 0, 0, 0, RtemsReqIdent_Post_Status_Ok, RtemsReqIdent_Post_Id_RemoteObj }
0401 #else
0402 { 0, 0, 0, 0, RtemsReqIdent_Post_Status_InvName, RtemsReqIdent_Post_Id_Nop }
0403 #endif
0404 };
0405
0406 static const uint8_t
0407 RtemsReqIdent_Map[] = {
0408 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 2, 0, 3, 0, 1, 0, 2, 0, 3, 0, 2, 0
0409 };
0410
0411 static size_t RtemsReqIdent_Scope( void *arg, char *buf, size_t n )
0412 {
0413 RtemsReqIdent_Context *ctx;
0414
0415 ctx = arg;
0416
0417 if ( ctx->Map.in_action_loop ) {
0418 return T_get_scope( RtemsReqIdent_PreDesc, buf, n, ctx->Map.pcs );
0419 }
0420
0421 return 0;
0422 }
0423
0424 static T_fixture RtemsReqIdent_Fixture = {
0425 .setup = NULL,
0426 .stop = NULL,
0427 .teardown = NULL,
0428 .scope = RtemsReqIdent_Scope,
0429 .initial_context = &RtemsReqIdent_Instance
0430 };
0431
0432 static inline RtemsReqIdent_Entry RtemsReqIdent_PopEntry(
0433 RtemsReqIdent_Context *ctx
0434 )
0435 {
0436 size_t index;
0437
0438 index = ctx->Map.index;
0439 ctx->Map.index = index + 1;
0440 return RtemsReqIdent_Entries[
0441 RtemsReqIdent_Map[ index ]
0442 ];
0443 }
0444
0445 static void RtemsReqIdent_TestVariant( RtemsReqIdent_Context *ctx )
0446 {
0447 RtemsReqIdent_Pre_Name_Prepare( ctx, ctx->Map.pcs[ 0 ] );
0448 RtemsReqIdent_Pre_Node_Prepare( ctx, ctx->Map.pcs[ 1 ] );
0449 RtemsReqIdent_Pre_Id_Prepare( ctx, ctx->Map.pcs[ 2 ] );
0450 RtemsReqIdent_Action( ctx );
0451 RtemsReqIdent_Post_Status_Check( ctx, ctx->Map.entry.Post_Status );
0452 RtemsReqIdent_Post_Id_Check( ctx, ctx->Map.entry.Post_Id );
0453 }
0454
0455 static T_fixture_node RtemsReqIdent_Node;
0456
0457 static T_remark RtemsReqIdent_Remark = {
0458 .next = NULL,
0459 .remark = "RtemsReqIdent"
0460 };
0461
0462 void RtemsReqIdent_Run(
0463 rtems_id id_local_object,
0464 rtems_name name_local_object,
0465 rtems_status_code ( *action )( rtems_name, uint32_t, rtems_id * )
0466 )
0467 {
0468 RtemsReqIdent_Context *ctx;
0469
0470 ctx = &RtemsReqIdent_Instance;
0471 ctx->id_local_object = id_local_object;
0472 ctx->name_local_object = name_local_object;
0473 ctx->action = action;
0474
0475 ctx = T_push_fixture( &RtemsReqIdent_Node, &RtemsReqIdent_Fixture );
0476 ctx->Map.in_action_loop = true;
0477 ctx->Map.index = 0;
0478
0479 for (
0480 ctx->Map.pcs[ 0 ] = RtemsReqIdent_Pre_Name_Invalid;
0481 ctx->Map.pcs[ 0 ] < RtemsReqIdent_Pre_Name_NA;
0482 ++ctx->Map.pcs[ 0 ]
0483 ) {
0484 for (
0485 ctx->Map.pcs[ 1 ] = RtemsReqIdent_Pre_Node_Local;
0486 ctx->Map.pcs[ 1 ] < RtemsReqIdent_Pre_Node_NA;
0487 ++ctx->Map.pcs[ 1 ]
0488 ) {
0489 for (
0490 ctx->Map.pcs[ 2 ] = RtemsReqIdent_Pre_Id_Valid;
0491 ctx->Map.pcs[ 2 ] < RtemsReqIdent_Pre_Id_NA;
0492 ++ctx->Map.pcs[ 2 ]
0493 ) {
0494 ctx->Map.entry = RtemsReqIdent_PopEntry( ctx );
0495 RtemsReqIdent_TestVariant( ctx );
0496 }
0497 }
0498 }
0499
0500 T_add_remark( &RtemsReqIdent_Remark );
0501 T_pop_fixture();
0502 }
0503
0504