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-local.h"
0056
0057 #include <rtems/test.h>
0058
0059
0060
0061
0062
0063
0064
0065
0066
0067 typedef struct {
0068 uint8_t Skip : 1;
0069 uint8_t Pre_Name_NA : 1;
0070 uint8_t Pre_Id_NA : 1;
0071 uint8_t Post_Status : 2;
0072 uint8_t Post_Id : 2;
0073 } RtemsReqIdentLocal_Entry;
0074
0075
0076
0077
0078 typedef struct {
0079 rtems_status_code status;
0080
0081 rtems_name name;
0082
0083 rtems_id *id;
0084
0085 rtems_id id_value;
0086
0087
0088
0089
0090
0091 rtems_id id_local_object;
0092
0093
0094
0095
0096
0097 rtems_name name_local_object;
0098
0099
0100
0101
0102
0103 rtems_status_code ( *action )( rtems_name, rtems_id * );
0104
0105 struct {
0106
0107
0108
0109 size_t pcs[ 2 ];
0110
0111
0112
0113
0114 bool in_action_loop;
0115
0116
0117
0118
0119 size_t index;
0120
0121
0122
0123
0124 RtemsReqIdentLocal_Entry entry;
0125
0126
0127
0128
0129
0130 bool skip;
0131 } Map;
0132 } RtemsReqIdentLocal_Context;
0133
0134 static RtemsReqIdentLocal_Context
0135 RtemsReqIdentLocal_Instance;
0136
0137 static const char * const RtemsReqIdentLocal_PreDesc_Name[] = {
0138 "Invalid",
0139 "Valid",
0140 "NA"
0141 };
0142
0143 static const char * const RtemsReqIdentLocal_PreDesc_Id[] = {
0144 "Valid",
0145 "Null",
0146 "NA"
0147 };
0148
0149 static const char * const * const RtemsReqIdentLocal_PreDesc[] = {
0150 RtemsReqIdentLocal_PreDesc_Name,
0151 RtemsReqIdentLocal_PreDesc_Id,
0152 NULL
0153 };
0154
0155 static void RtemsReqIdentLocal_Pre_Name_Prepare(
0156 RtemsReqIdentLocal_Context *ctx,
0157 RtemsReqIdentLocal_Pre_Name state
0158 )
0159 {
0160 switch ( state ) {
0161 case RtemsReqIdentLocal_Pre_Name_Invalid: {
0162
0163
0164
0165
0166 ctx->name = 1;
0167 break;
0168 }
0169
0170 case RtemsReqIdentLocal_Pre_Name_Valid: {
0171
0172
0173
0174
0175 ctx->name = ctx->name_local_object;
0176 break;
0177 }
0178
0179 case RtemsReqIdentLocal_Pre_Name_NA:
0180 break;
0181 }
0182 }
0183
0184 static void RtemsReqIdentLocal_Pre_Id_Prepare(
0185 RtemsReqIdentLocal_Context *ctx,
0186 RtemsReqIdentLocal_Pre_Id state
0187 )
0188 {
0189 switch ( state ) {
0190 case RtemsReqIdentLocal_Pre_Id_Valid: {
0191
0192
0193
0194 ctx->id_value = 0xffffffff;
0195 ctx->id = &ctx->id_value;
0196 break;
0197 }
0198
0199 case RtemsReqIdentLocal_Pre_Id_Null: {
0200
0201
0202
0203 ctx->id = NULL;
0204 break;
0205 }
0206
0207 case RtemsReqIdentLocal_Pre_Id_NA:
0208 break;
0209 }
0210 }
0211
0212 static void RtemsReqIdentLocal_Post_Status_Check(
0213 RtemsReqIdentLocal_Context *ctx,
0214 RtemsReqIdentLocal_Post_Status state
0215 )
0216 {
0217 switch ( state ) {
0218 case RtemsReqIdentLocal_Post_Status_Ok: {
0219
0220
0221
0222 T_rsc( ctx->status, RTEMS_SUCCESSFUL );
0223 break;
0224 }
0225
0226 case RtemsReqIdentLocal_Post_Status_InvAddr: {
0227
0228
0229
0230 T_rsc( ctx->status, RTEMS_INVALID_ADDRESS );
0231 break;
0232 }
0233
0234 case RtemsReqIdentLocal_Post_Status_InvName: {
0235
0236
0237
0238 T_rsc( ctx->status, RTEMS_INVALID_NAME );
0239 break;
0240 }
0241
0242 case RtemsReqIdentLocal_Post_Status_NA:
0243 break;
0244 }
0245 }
0246
0247 static void RtemsReqIdentLocal_Post_Id_Check(
0248 RtemsReqIdentLocal_Context *ctx,
0249 RtemsReqIdentLocal_Post_Id state
0250 )
0251 {
0252 switch ( state ) {
0253 case RtemsReqIdentLocal_Post_Id_Nop: {
0254
0255
0256
0257
0258 T_eq_ptr( ctx->id, &ctx->id_value );
0259 T_eq_u32( ctx->id_value, 0xffffffff );
0260 break;
0261 }
0262
0263 case RtemsReqIdentLocal_Post_Id_Null: {
0264
0265
0266
0267 T_null( ctx->id )
0268 break;
0269 }
0270
0271 case RtemsReqIdentLocal_Post_Id_Id: {
0272
0273
0274
0275
0276
0277
0278
0279 T_eq_ptr( ctx->id, &ctx->id_value );
0280 T_eq_u32( ctx->id_value, ctx->id_local_object );
0281 break;
0282 }
0283
0284 case RtemsReqIdentLocal_Post_Id_NA:
0285 break;
0286 }
0287 }
0288
0289 static void RtemsReqIdentLocal_Action( RtemsReqIdentLocal_Context *ctx )
0290 {
0291 ctx->status = ( *ctx->action )( ctx->name, ctx->id );
0292 }
0293
0294 static const RtemsReqIdentLocal_Entry
0295 RtemsReqIdentLocal_Entries[] = {
0296 { 0, 0, 0, RtemsReqIdentLocal_Post_Status_InvAddr,
0297 RtemsReqIdentLocal_Post_Id_Null },
0298 { 0, 0, 0, RtemsReqIdentLocal_Post_Status_InvName,
0299 RtemsReqIdentLocal_Post_Id_Nop },
0300 { 0, 0, 0, RtemsReqIdentLocal_Post_Status_Ok, RtemsReqIdentLocal_Post_Id_Id }
0301 };
0302
0303 static const uint8_t
0304 RtemsReqIdentLocal_Map[] = {
0305 1, 0, 2, 0
0306 };
0307
0308 static size_t RtemsReqIdentLocal_Scope( void *arg, char *buf, size_t n )
0309 {
0310 RtemsReqIdentLocal_Context *ctx;
0311
0312 ctx = arg;
0313
0314 if ( ctx->Map.in_action_loop ) {
0315 return T_get_scope( RtemsReqIdentLocal_PreDesc, buf, n, ctx->Map.pcs );
0316 }
0317
0318 return 0;
0319 }
0320
0321 static T_fixture RtemsReqIdentLocal_Fixture = {
0322 .setup = NULL,
0323 .stop = NULL,
0324 .teardown = NULL,
0325 .scope = RtemsReqIdentLocal_Scope,
0326 .initial_context = &RtemsReqIdentLocal_Instance
0327 };
0328
0329 static inline RtemsReqIdentLocal_Entry RtemsReqIdentLocal_PopEntry(
0330 RtemsReqIdentLocal_Context *ctx
0331 )
0332 {
0333 size_t index;
0334
0335 index = ctx->Map.index;
0336 ctx->Map.index = index + 1;
0337 return RtemsReqIdentLocal_Entries[
0338 RtemsReqIdentLocal_Map[ index ]
0339 ];
0340 }
0341
0342 static void RtemsReqIdentLocal_TestVariant( RtemsReqIdentLocal_Context *ctx )
0343 {
0344 RtemsReqIdentLocal_Pre_Name_Prepare( ctx, ctx->Map.pcs[ 0 ] );
0345 RtemsReqIdentLocal_Pre_Id_Prepare( ctx, ctx->Map.pcs[ 1 ] );
0346 RtemsReqIdentLocal_Action( ctx );
0347 RtemsReqIdentLocal_Post_Status_Check( ctx, ctx->Map.entry.Post_Status );
0348 RtemsReqIdentLocal_Post_Id_Check( ctx, ctx->Map.entry.Post_Id );
0349 }
0350
0351 static T_fixture_node RtemsReqIdentLocal_Node;
0352
0353 static T_remark RtemsReqIdentLocal_Remark = {
0354 .next = NULL,
0355 .remark = "RtemsReqIdentLocal"
0356 };
0357
0358 void RtemsReqIdentLocal_Run(
0359 rtems_id id_local_object,
0360 rtems_name name_local_object,
0361 rtems_status_code ( *action )( rtems_name, rtems_id * )
0362 )
0363 {
0364 RtemsReqIdentLocal_Context *ctx;
0365
0366 ctx = &RtemsReqIdentLocal_Instance;
0367 ctx->id_local_object = id_local_object;
0368 ctx->name_local_object = name_local_object;
0369 ctx->action = action;
0370
0371 ctx = T_push_fixture( &RtemsReqIdentLocal_Node, &RtemsReqIdentLocal_Fixture );
0372 ctx->Map.in_action_loop = true;
0373 ctx->Map.index = 0;
0374
0375 for (
0376 ctx->Map.pcs[ 0 ] = RtemsReqIdentLocal_Pre_Name_Invalid;
0377 ctx->Map.pcs[ 0 ] < RtemsReqIdentLocal_Pre_Name_NA;
0378 ++ctx->Map.pcs[ 0 ]
0379 ) {
0380 for (
0381 ctx->Map.pcs[ 1 ] = RtemsReqIdentLocal_Pre_Id_Valid;
0382 ctx->Map.pcs[ 1 ] < RtemsReqIdentLocal_Pre_Id_NA;
0383 ++ctx->Map.pcs[ 1 ]
0384 ) {
0385 ctx->Map.entry = RtemsReqIdentLocal_PopEntry( ctx );
0386 RtemsReqIdentLocal_TestVariant( ctx );
0387 }
0388 }
0389
0390 T_add_remark( &RtemsReqIdentLocal_Remark );
0391 T_pop_fixture();
0392 }
0393
0394