File indexing completed on 2025-05-11 08:24:51
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 <rtems/test.h>
0058
0059
0060
0061
0062
0063
0064
0065
0066
0067
0068
0069
0070
0071
0072
0073 typedef struct {
0074
0075
0076
0077 rtems_id part_one;
0078
0079
0080
0081
0082 rtems_id part_many;
0083
0084
0085
0086
0087 rtems_status_code status;
0088
0089
0090
0091
0092 void *buffer;
0093
0094
0095
0096
0097 void *buffer_2;
0098
0099
0100
0101
0102 T_measure_runtime_context *context;
0103
0104
0105
0106
0107 T_measure_runtime_request request;
0108
0109
0110
0111
0112 T_ticks begin;
0113
0114
0115
0116
0117 T_ticks end;
0118 } RtemsPartValPerf_Context;
0119
0120 static RtemsPartValPerf_Context
0121 RtemsPartValPerf_Instance;
0122
0123 static void RtemsPartValPerf_Setup_Context( RtemsPartValPerf_Context *ctx )
0124 {
0125 T_measure_runtime_config config;
0126
0127 memset( &config, 0, sizeof( config ) );
0128 config.sample_count = 100;
0129 ctx->request.arg = ctx;
0130 ctx->request.flags = T_MEASURE_RUNTIME_REPORT_SAMPLES;
0131 ctx->context = T_measure_runtime_create( &config );
0132 T_assert_not_null( ctx->context );
0133 }
0134
0135
0136
0137
0138 static void RtemsPartValPerf_Setup( RtemsPartValPerf_Context *ctx )
0139 {
0140 rtems_status_code sc;
0141 size_t size;
0142 void *area;
0143 uintptr_t length;
0144
0145 size = 2 * sizeof( uintptr_t );
0146
0147 area = T_malloc( size );
0148 sc = rtems_partition_create(
0149 rtems_build_name( ' ', 'O', 'N', 'E' ),
0150 area,
0151 size,
0152 size,
0153 RTEMS_DEFAULT_ATTRIBUTES,
0154 &ctx->part_one
0155 );
0156 T_assert_rsc_success( sc );
0157
0158 length = 100 * size;
0159 area = T_malloc( length );
0160 sc = rtems_partition_create(
0161 rtems_build_name( 'M', 'A', 'N', 'Y' ),
0162 area,
0163 length,
0164 size,
0165 RTEMS_DEFAULT_ATTRIBUTES,
0166 &ctx->part_many
0167 );
0168 T_assert_rsc_success( sc );
0169 }
0170
0171 static void RtemsPartValPerf_Setup_Wrap( void *arg )
0172 {
0173 RtemsPartValPerf_Context *ctx;
0174
0175 ctx = arg;
0176 RtemsPartValPerf_Setup_Context( ctx );
0177 RtemsPartValPerf_Setup( ctx );
0178 }
0179
0180
0181
0182
0183 static void RtemsPartValPerf_Teardown( RtemsPartValPerf_Context *ctx )
0184 {
0185 rtems_status_code sc;
0186
0187 if ( ctx->part_one != 0 ) {
0188 sc = rtems_partition_delete( ctx->part_one );
0189 T_rsc_success( sc );
0190 }
0191
0192 if ( ctx->part_many != 0 ) {
0193 sc = rtems_partition_delete( ctx->part_many );
0194 T_rsc_success( sc );
0195 }
0196 }
0197
0198 static void RtemsPartValPerf_Teardown_Wrap( void *arg )
0199 {
0200 RtemsPartValPerf_Context *ctx;
0201
0202 ctx = arg;
0203 RtemsPartValPerf_Teardown( ctx );
0204 }
0205
0206 static T_fixture RtemsPartValPerf_Fixture = {
0207 .setup = RtemsPartValPerf_Setup_Wrap,
0208 .stop = NULL,
0209 .teardown = RtemsPartValPerf_Teardown_Wrap,
0210 .scope = NULL,
0211 .initial_context = &RtemsPartValPerf_Instance
0212 };
0213
0214
0215
0216
0217
0218
0219
0220
0221
0222
0223 static void RtemsPartReqPerfGetBuffer_Body( RtemsPartValPerf_Context *ctx )
0224 {
0225 ctx->status = rtems_partition_get_buffer( ctx->part_many, &ctx->buffer );
0226 }
0227
0228 static void RtemsPartReqPerfGetBuffer_Body_Wrap( void *arg )
0229 {
0230 RtemsPartValPerf_Context *ctx;
0231
0232 ctx = arg;
0233 RtemsPartReqPerfGetBuffer_Body( ctx );
0234 }
0235
0236
0237
0238
0239 static bool RtemsPartReqPerfGetBuffer_Teardown(
0240 RtemsPartValPerf_Context *ctx,
0241 T_ticks *delta,
0242 uint32_t tic,
0243 uint32_t toc,
0244 unsigned int retry
0245 )
0246 {
0247 rtems_status_code sc;
0248
0249 T_quiet_rsc_success( ctx->status );
0250
0251 sc = rtems_partition_return_buffer( ctx->part_many, ctx->buffer );
0252 T_quiet_rsc_success( sc );
0253
0254 return tic == toc;
0255 }
0256
0257 static bool RtemsPartReqPerfGetBuffer_Teardown_Wrap(
0258 void *arg,
0259 T_ticks *delta,
0260 uint32_t tic,
0261 uint32_t toc,
0262 unsigned int retry
0263 )
0264 {
0265 RtemsPartValPerf_Context *ctx;
0266
0267 ctx = arg;
0268 return RtemsPartReqPerfGetBuffer_Teardown( ctx, delta, tic, toc, retry );
0269 }
0270
0271
0272
0273
0274
0275
0276
0277
0278
0279
0280
0281
0282
0283 static void RtemsPartReqPerfGetNoBuffer_Prepare(
0284 RtemsPartValPerf_Context *ctx
0285 )
0286 {
0287 rtems_status_code sc;
0288
0289 sc = rtems_partition_get_buffer( ctx->part_one, &ctx->buffer_2 );
0290 T_rsc_success( sc );
0291 }
0292
0293
0294
0295
0296 static void RtemsPartReqPerfGetNoBuffer_Body( RtemsPartValPerf_Context *ctx )
0297 {
0298 ctx->status = rtems_partition_get_buffer( ctx->part_one, &ctx->buffer );
0299 }
0300
0301 static void RtemsPartReqPerfGetNoBuffer_Body_Wrap( void *arg )
0302 {
0303 RtemsPartValPerf_Context *ctx;
0304
0305 ctx = arg;
0306 RtemsPartReqPerfGetNoBuffer_Body( ctx );
0307 }
0308
0309
0310
0311
0312 static bool RtemsPartReqPerfGetNoBuffer_Teardown(
0313 RtemsPartValPerf_Context *ctx,
0314 T_ticks *delta,
0315 uint32_t tic,
0316 uint32_t toc,
0317 unsigned int retry
0318 )
0319 {
0320 T_quiet_rsc( ctx->status, RTEMS_UNSATISFIED );
0321
0322 return tic == toc;
0323 }
0324
0325 static bool RtemsPartReqPerfGetNoBuffer_Teardown_Wrap(
0326 void *arg,
0327 T_ticks *delta,
0328 uint32_t tic,
0329 uint32_t toc,
0330 unsigned int retry
0331 )
0332 {
0333 RtemsPartValPerf_Context *ctx;
0334
0335 ctx = arg;
0336 return RtemsPartReqPerfGetNoBuffer_Teardown( ctx, delta, tic, toc, retry );
0337 }
0338
0339
0340
0341
0342 static void RtemsPartReqPerfGetNoBuffer_Cleanup(
0343 RtemsPartValPerf_Context *ctx
0344 )
0345 {
0346 rtems_status_code sc;
0347
0348 sc = rtems_partition_return_buffer( ctx->part_one, ctx->buffer_2 );
0349 T_rsc_success( sc );
0350 }
0351
0352
0353
0354
0355
0356
0357
0358
0359
0360
0361
0362
0363
0364 static void RtemsPartReqPerfReturnBuffer_Setup( RtemsPartValPerf_Context *ctx )
0365 {
0366 rtems_status_code sc;
0367
0368 sc = rtems_partition_get_buffer( ctx->part_many, &ctx->buffer );
0369 T_quiet_rsc_success( sc );
0370 }
0371
0372 static void RtemsPartReqPerfReturnBuffer_Setup_Wrap( void *arg )
0373 {
0374 RtemsPartValPerf_Context *ctx;
0375
0376 ctx = arg;
0377 RtemsPartReqPerfReturnBuffer_Setup( ctx );
0378 }
0379
0380
0381
0382
0383 static void RtemsPartReqPerfReturnBuffer_Body( RtemsPartValPerf_Context *ctx )
0384 {
0385 ctx->status = rtems_partition_return_buffer( ctx->part_many, ctx->buffer );
0386 }
0387
0388 static void RtemsPartReqPerfReturnBuffer_Body_Wrap( void *arg )
0389 {
0390 RtemsPartValPerf_Context *ctx;
0391
0392 ctx = arg;
0393 RtemsPartReqPerfReturnBuffer_Body( ctx );
0394 }
0395
0396
0397
0398
0399 static bool RtemsPartReqPerfReturnBuffer_Teardown(
0400 RtemsPartValPerf_Context *ctx,
0401 T_ticks *delta,
0402 uint32_t tic,
0403 uint32_t toc,
0404 unsigned int retry
0405 )
0406 {
0407 T_quiet_rsc( ctx->status, RTEMS_SUCCESSFUL );
0408
0409 return tic == toc;
0410 }
0411
0412 static bool RtemsPartReqPerfReturnBuffer_Teardown_Wrap(
0413 void *arg,
0414 T_ticks *delta,
0415 uint32_t tic,
0416 uint32_t toc,
0417 unsigned int retry
0418 )
0419 {
0420 RtemsPartValPerf_Context *ctx;
0421
0422 ctx = arg;
0423 return RtemsPartReqPerfReturnBuffer_Teardown( ctx, delta, tic, toc, retry );
0424 }
0425
0426
0427
0428
0429
0430
0431 T_TEST_CASE_FIXTURE( RtemsPartValPerf, &RtemsPartValPerf_Fixture )
0432 {
0433 RtemsPartValPerf_Context *ctx;
0434
0435 ctx = T_fixture_context();
0436
0437 ctx->request.name = "RtemsPartReqPerfGetBuffer";
0438 ctx->request.setup = NULL;
0439 ctx->request.body = RtemsPartReqPerfGetBuffer_Body_Wrap;
0440 ctx->request.teardown = RtemsPartReqPerfGetBuffer_Teardown_Wrap;
0441 T_measure_runtime( ctx->context, &ctx->request );
0442
0443 RtemsPartReqPerfGetNoBuffer_Prepare( ctx );
0444 ctx->request.name = "RtemsPartReqPerfGetNoBuffer";
0445 ctx->request.setup = NULL;
0446 ctx->request.body = RtemsPartReqPerfGetNoBuffer_Body_Wrap;
0447 ctx->request.teardown = RtemsPartReqPerfGetNoBuffer_Teardown_Wrap;
0448 T_measure_runtime( ctx->context, &ctx->request );
0449 RtemsPartReqPerfGetNoBuffer_Cleanup( ctx );
0450
0451 ctx->request.name = "RtemsPartReqPerfReturnBuffer";
0452 ctx->request.setup = RtemsPartReqPerfReturnBuffer_Setup_Wrap;
0453 ctx->request.body = RtemsPartReqPerfReturnBuffer_Body_Wrap;
0454 ctx->request.teardown = RtemsPartReqPerfReturnBuffer_Teardown_Wrap;
0455 T_measure_runtime( ctx->context, &ctx->request );
0456 }
0457
0458