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 <limits.h>
0056 #include <rtems.h>
0057
0058 #include "ts-config.h"
0059 #include "tx-support.h"
0060
0061 #include <rtems/test.h>
0062
0063
0064
0065
0066
0067
0068
0069
0070
0071
0072 typedef enum {
0073 RtemsSchedulerReqGetMaximumPriority_Pre_Id_Invalid,
0074 RtemsSchedulerReqGetMaximumPriority_Pre_Id_Scheduler,
0075 RtemsSchedulerReqGetMaximumPriority_Pre_Id_NA
0076 } RtemsSchedulerReqGetMaximumPriority_Pre_Id;
0077
0078 typedef enum {
0079 RtemsSchedulerReqGetMaximumPriority_Pre_Prio_Valid,
0080 RtemsSchedulerReqGetMaximumPriority_Pre_Prio_Null,
0081 RtemsSchedulerReqGetMaximumPriority_Pre_Prio_NA
0082 } RtemsSchedulerReqGetMaximumPriority_Pre_Prio;
0083
0084 typedef enum {
0085 RtemsSchedulerReqGetMaximumPriority_Post_Status_Ok,
0086 RtemsSchedulerReqGetMaximumPriority_Post_Status_InvAddr,
0087 RtemsSchedulerReqGetMaximumPriority_Post_Status_InvId,
0088 RtemsSchedulerReqGetMaximumPriority_Post_Status_NA
0089 } RtemsSchedulerReqGetMaximumPriority_Post_Status;
0090
0091 typedef enum {
0092 RtemsSchedulerReqGetMaximumPriority_Post_PrioObj_Set,
0093 RtemsSchedulerReqGetMaximumPriority_Post_PrioObj_Nop,
0094 RtemsSchedulerReqGetMaximumPriority_Post_PrioObj_NA
0095 } RtemsSchedulerReqGetMaximumPriority_Post_PrioObj;
0096
0097 typedef struct {
0098 uint8_t Skip : 1;
0099 uint8_t Pre_Id_NA : 1;
0100 uint8_t Pre_Prio_NA : 1;
0101 uint8_t Post_Status : 2;
0102 uint8_t Post_PrioObj : 2;
0103 } RtemsSchedulerReqGetMaximumPriority_Entry;
0104
0105
0106
0107
0108
0109 typedef struct {
0110
0111
0112
0113 rtems_id scheduler_id;
0114
0115
0116
0117
0118
0119 rtems_task_priority priority_obj;
0120
0121
0122
0123
0124
0125 rtems_status_code status;
0126
0127
0128
0129
0130 rtems_id id;
0131
0132
0133
0134
0135 rtems_task_priority *priority;
0136
0137 struct {
0138
0139
0140
0141 size_t pcs[ 2 ];
0142
0143
0144
0145
0146 bool in_action_loop;
0147
0148
0149
0150
0151 size_t index;
0152
0153
0154
0155
0156 RtemsSchedulerReqGetMaximumPriority_Entry entry;
0157
0158
0159
0160
0161
0162 bool skip;
0163 } Map;
0164 } RtemsSchedulerReqGetMaximumPriority_Context;
0165
0166 static RtemsSchedulerReqGetMaximumPriority_Context
0167 RtemsSchedulerReqGetMaximumPriority_Instance;
0168
0169 static const char * const RtemsSchedulerReqGetMaximumPriority_PreDesc_Id[] = {
0170 "Invalid",
0171 "Scheduler",
0172 "NA"
0173 };
0174
0175 static const char * const RtemsSchedulerReqGetMaximumPriority_PreDesc_Prio[] = {
0176 "Valid",
0177 "Null",
0178 "NA"
0179 };
0180
0181 static const char * const * const RtemsSchedulerReqGetMaximumPriority_PreDesc[] = {
0182 RtemsSchedulerReqGetMaximumPriority_PreDesc_Id,
0183 RtemsSchedulerReqGetMaximumPriority_PreDesc_Prio,
0184 NULL
0185 };
0186
0187 static void RtemsSchedulerReqGetMaximumPriority_Pre_Id_Prepare(
0188 RtemsSchedulerReqGetMaximumPriority_Context *ctx,
0189 RtemsSchedulerReqGetMaximumPriority_Pre_Id state
0190 )
0191 {
0192 switch ( state ) {
0193 case RtemsSchedulerReqGetMaximumPriority_Pre_Id_Invalid: {
0194
0195
0196
0197
0198 ctx->id = INVALID_ID;
0199 break;
0200 }
0201
0202 case RtemsSchedulerReqGetMaximumPriority_Pre_Id_Scheduler: {
0203
0204
0205
0206 ctx->id = ctx->scheduler_id;
0207 break;
0208 }
0209
0210 case RtemsSchedulerReqGetMaximumPriority_Pre_Id_NA:
0211 break;
0212 }
0213 }
0214
0215 static void RtemsSchedulerReqGetMaximumPriority_Pre_Prio_Prepare(
0216 RtemsSchedulerReqGetMaximumPriority_Context *ctx,
0217 RtemsSchedulerReqGetMaximumPriority_Pre_Prio state
0218 )
0219 {
0220 switch ( state ) {
0221 case RtemsSchedulerReqGetMaximumPriority_Pre_Prio_Valid: {
0222
0223
0224
0225
0226 ctx->priority = &ctx->priority_obj;
0227 break;
0228 }
0229
0230 case RtemsSchedulerReqGetMaximumPriority_Pre_Prio_Null: {
0231
0232
0233
0234 ctx->priority = NULL;
0235 break;
0236 }
0237
0238 case RtemsSchedulerReqGetMaximumPriority_Pre_Prio_NA:
0239 break;
0240 }
0241 }
0242
0243 static void RtemsSchedulerReqGetMaximumPriority_Post_Status_Check(
0244 RtemsSchedulerReqGetMaximumPriority_Context *ctx,
0245 RtemsSchedulerReqGetMaximumPriority_Post_Status state
0246 )
0247 {
0248 switch ( state ) {
0249 case RtemsSchedulerReqGetMaximumPriority_Post_Status_Ok: {
0250
0251
0252
0253
0254 T_rsc_success( ctx->status );
0255 break;
0256 }
0257
0258 case RtemsSchedulerReqGetMaximumPriority_Post_Status_InvAddr: {
0259
0260
0261
0262
0263 T_rsc( ctx->status, RTEMS_INVALID_ADDRESS );
0264 break;
0265 }
0266
0267 case RtemsSchedulerReqGetMaximumPriority_Post_Status_InvId: {
0268
0269
0270
0271
0272 T_rsc( ctx->status, RTEMS_INVALID_ID );
0273 break;
0274 }
0275
0276 case RtemsSchedulerReqGetMaximumPriority_Post_Status_NA:
0277 break;
0278 }
0279 }
0280
0281 static void RtemsSchedulerReqGetMaximumPriority_Post_PrioObj_Check(
0282 RtemsSchedulerReqGetMaximumPriority_Context *ctx,
0283 RtemsSchedulerReqGetMaximumPriority_Post_PrioObj state
0284 )
0285 {
0286 switch ( state ) {
0287 case RtemsSchedulerReqGetMaximumPriority_Post_PrioObj_Set: {
0288
0289
0290
0291
0292
0293
0294 #if defined(RTEMS_SMP)
0295 T_eq_u32( ctx->priority_obj, INT_MAX );
0296 #else
0297 T_eq_u32( ctx->priority_obj, 127 );
0298 #endif
0299 break;
0300 }
0301
0302 case RtemsSchedulerReqGetMaximumPriority_Post_PrioObj_Nop: {
0303
0304
0305
0306
0307
0308 T_eq_u32( ctx->priority_obj, PRIO_INVALID );
0309 break;
0310 }
0311
0312 case RtemsSchedulerReqGetMaximumPriority_Post_PrioObj_NA:
0313 break;
0314 }
0315 }
0316
0317 static void RtemsSchedulerReqGetMaximumPriority_Setup(
0318 RtemsSchedulerReqGetMaximumPriority_Context *ctx
0319 )
0320 {
0321 rtems_status_code sc;
0322
0323 sc = rtems_scheduler_ident(
0324 TEST_SCHEDULER_A_NAME,
0325 &ctx->scheduler_id
0326 );
0327 T_rsc_success( sc );
0328 }
0329
0330 static void RtemsSchedulerReqGetMaximumPriority_Setup_Wrap( void *arg )
0331 {
0332 RtemsSchedulerReqGetMaximumPriority_Context *ctx;
0333
0334 ctx = arg;
0335 ctx->Map.in_action_loop = false;
0336 RtemsSchedulerReqGetMaximumPriority_Setup( ctx );
0337 }
0338
0339 static void RtemsSchedulerReqGetMaximumPriority_Prepare(
0340 RtemsSchedulerReqGetMaximumPriority_Context *ctx
0341 )
0342 {
0343 ctx->priority_obj = PRIO_INVALID;
0344 }
0345
0346 static void RtemsSchedulerReqGetMaximumPriority_Action(
0347 RtemsSchedulerReqGetMaximumPriority_Context *ctx
0348 )
0349 {
0350 ctx->status = rtems_scheduler_get_maximum_priority( ctx->id, ctx->priority );
0351 }
0352
0353 static const RtemsSchedulerReqGetMaximumPriority_Entry
0354 RtemsSchedulerReqGetMaximumPriority_Entries[] = {
0355 { 0, 0, 0, RtemsSchedulerReqGetMaximumPriority_Post_Status_InvAddr,
0356 RtemsSchedulerReqGetMaximumPriority_Post_PrioObj_Nop },
0357 { 0, 0, 0, RtemsSchedulerReqGetMaximumPriority_Post_Status_InvId,
0358 RtemsSchedulerReqGetMaximumPriority_Post_PrioObj_Nop },
0359 { 0, 0, 0, RtemsSchedulerReqGetMaximumPriority_Post_Status_Ok,
0360 RtemsSchedulerReqGetMaximumPriority_Post_PrioObj_Set }
0361 };
0362
0363 static const uint8_t
0364 RtemsSchedulerReqGetMaximumPriority_Map[] = {
0365 1, 0, 2, 0
0366 };
0367
0368 static size_t RtemsSchedulerReqGetMaximumPriority_Scope(
0369 void *arg,
0370 char *buf,
0371 size_t n
0372 )
0373 {
0374 RtemsSchedulerReqGetMaximumPriority_Context *ctx;
0375
0376 ctx = arg;
0377
0378 if ( ctx->Map.in_action_loop ) {
0379 return T_get_scope(
0380 RtemsSchedulerReqGetMaximumPriority_PreDesc,
0381 buf,
0382 n,
0383 ctx->Map.pcs
0384 );
0385 }
0386
0387 return 0;
0388 }
0389
0390 static T_fixture RtemsSchedulerReqGetMaximumPriority_Fixture = {
0391 .setup = RtemsSchedulerReqGetMaximumPriority_Setup_Wrap,
0392 .stop = NULL,
0393 .teardown = NULL,
0394 .scope = RtemsSchedulerReqGetMaximumPriority_Scope,
0395 .initial_context = &RtemsSchedulerReqGetMaximumPriority_Instance
0396 };
0397
0398 static inline RtemsSchedulerReqGetMaximumPriority_Entry
0399 RtemsSchedulerReqGetMaximumPriority_PopEntry(
0400 RtemsSchedulerReqGetMaximumPriority_Context *ctx
0401 )
0402 {
0403 size_t index;
0404
0405 index = ctx->Map.index;
0406 ctx->Map.index = index + 1;
0407 return RtemsSchedulerReqGetMaximumPriority_Entries[
0408 RtemsSchedulerReqGetMaximumPriority_Map[ index ]
0409 ];
0410 }
0411
0412 static void RtemsSchedulerReqGetMaximumPriority_TestVariant(
0413 RtemsSchedulerReqGetMaximumPriority_Context *ctx
0414 )
0415 {
0416 RtemsSchedulerReqGetMaximumPriority_Pre_Id_Prepare( ctx, ctx->Map.pcs[ 0 ] );
0417 RtemsSchedulerReqGetMaximumPriority_Pre_Prio_Prepare(
0418 ctx,
0419 ctx->Map.pcs[ 1 ]
0420 );
0421 RtemsSchedulerReqGetMaximumPriority_Action( ctx );
0422 RtemsSchedulerReqGetMaximumPriority_Post_Status_Check(
0423 ctx,
0424 ctx->Map.entry.Post_Status
0425 );
0426 RtemsSchedulerReqGetMaximumPriority_Post_PrioObj_Check(
0427 ctx,
0428 ctx->Map.entry.Post_PrioObj
0429 );
0430 }
0431
0432
0433
0434
0435 T_TEST_CASE_FIXTURE(
0436 RtemsSchedulerReqGetMaximumPriority,
0437 &RtemsSchedulerReqGetMaximumPriority_Fixture
0438 )
0439 {
0440 RtemsSchedulerReqGetMaximumPriority_Context *ctx;
0441
0442 ctx = T_fixture_context();
0443 ctx->Map.in_action_loop = true;
0444 ctx->Map.index = 0;
0445
0446 for (
0447 ctx->Map.pcs[ 0 ] = RtemsSchedulerReqGetMaximumPriority_Pre_Id_Invalid;
0448 ctx->Map.pcs[ 0 ] < RtemsSchedulerReqGetMaximumPriority_Pre_Id_NA;
0449 ++ctx->Map.pcs[ 0 ]
0450 ) {
0451 for (
0452 ctx->Map.pcs[ 1 ] = RtemsSchedulerReqGetMaximumPriority_Pre_Prio_Valid;
0453 ctx->Map.pcs[ 1 ] < RtemsSchedulerReqGetMaximumPriority_Pre_Prio_NA;
0454 ++ctx->Map.pcs[ 1 ]
0455 ) {
0456 ctx->Map.entry = RtemsSchedulerReqGetMaximumPriority_PopEntry( ctx );
0457 RtemsSchedulerReqGetMaximumPriority_Prepare( ctx );
0458 RtemsSchedulerReqGetMaximumPriority_TestVariant( ctx );
0459 }
0460 }
0461 }
0462
0463