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 <grlib/irqamp.h>
0056
0057 #include <rtems/test.h>
0058
0059
0060
0061
0062
0063
0064
0065
0066
0067
0068 typedef enum {
0069 DevGrlibReqIrqampGetTimestamp_Pre_NumberOfTimestampRegisterSets_Zero,
0070 DevGrlibReqIrqampGetTimestamp_Pre_NumberOfTimestampRegisterSets_Positive,
0071 DevGrlibReqIrqampGetTimestamp_Pre_NumberOfTimestampRegisterSets_NA
0072 } DevGrlibReqIrqampGetTimestamp_Pre_NumberOfTimestampRegisterSets;
0073
0074 typedef enum {
0075 DevGrlibReqIrqampGetTimestamp_Post_Result_Registers,
0076 DevGrlibReqIrqampGetTimestamp_Post_Result_Null,
0077 DevGrlibReqIrqampGetTimestamp_Post_Result_NA
0078 } DevGrlibReqIrqampGetTimestamp_Post_Result;
0079
0080 typedef struct {
0081 uint8_t Skip : 1;
0082 uint8_t Pre_NumberOfTimestampRegisterSets_NA : 1;
0083 uint8_t Post_Result : 2;
0084 } DevGrlibReqIrqampGetTimestamp_Entry;
0085
0086
0087
0088
0089 typedef struct {
0090
0091
0092
0093
0094 irqamp_timestamp *result;
0095
0096
0097
0098
0099 irqamp irqamp_regs;
0100
0101 struct {
0102
0103
0104
0105 size_t pcs[ 1 ];
0106
0107
0108
0109
0110 bool in_action_loop;
0111
0112
0113
0114
0115 size_t index;
0116
0117
0118
0119
0120 DevGrlibReqIrqampGetTimestamp_Entry entry;
0121
0122
0123
0124
0125
0126 bool skip;
0127 } Map;
0128 } DevGrlibReqIrqampGetTimestamp_Context;
0129
0130 static DevGrlibReqIrqampGetTimestamp_Context
0131 DevGrlibReqIrqampGetTimestamp_Instance;
0132
0133 static const char * const DevGrlibReqIrqampGetTimestamp_PreDesc_NumberOfTimestampRegisterSets[] = {
0134 "Zero",
0135 "Positive",
0136 "NA"
0137 };
0138
0139 static const char * const * const DevGrlibReqIrqampGetTimestamp_PreDesc[] = {
0140 DevGrlibReqIrqampGetTimestamp_PreDesc_NumberOfTimestampRegisterSets,
0141 NULL
0142 };
0143
0144 static void
0145 DevGrlibReqIrqampGetTimestamp_Pre_NumberOfTimestampRegisterSets_Prepare(
0146 DevGrlibReqIrqampGetTimestamp_Context *ctx,
0147 DevGrlibReqIrqampGetTimestamp_Pre_NumberOfTimestampRegisterSets state
0148 )
0149 {
0150 switch ( state ) {
0151 case DevGrlibReqIrqampGetTimestamp_Pre_NumberOfTimestampRegisterSets_Zero: {
0152
0153
0154
0155
0156 ctx->irqamp_regs.itstmp[ 0 ].itstmpc = 0;
0157 break;
0158 }
0159
0160 case DevGrlibReqIrqampGetTimestamp_Pre_NumberOfTimestampRegisterSets_Positive: {
0161
0162
0163
0164
0165 ctx->irqamp_regs.itstmp[ 0 ].itstmpc = IRQAMP_ITSTMPC_TSTAMP( 1 );
0166 break;
0167 }
0168
0169 case DevGrlibReqIrqampGetTimestamp_Pre_NumberOfTimestampRegisterSets_NA:
0170 break;
0171 }
0172 }
0173
0174 static void DevGrlibReqIrqampGetTimestamp_Post_Result_Check(
0175 DevGrlibReqIrqampGetTimestamp_Context *ctx,
0176 DevGrlibReqIrqampGetTimestamp_Post_Result state
0177 )
0178 {
0179 switch ( state ) {
0180 case DevGrlibReqIrqampGetTimestamp_Post_Result_Registers: {
0181
0182
0183
0184
0185
0186 T_not_null( ctx->result );
0187 break;
0188 }
0189
0190 case DevGrlibReqIrqampGetTimestamp_Post_Result_Null: {
0191
0192
0193
0194 T_null( ctx->result );
0195 break;
0196 }
0197
0198 case DevGrlibReqIrqampGetTimestamp_Post_Result_NA:
0199 break;
0200 }
0201 }
0202
0203 static void DevGrlibReqIrqampGetTimestamp_Action(
0204 DevGrlibReqIrqampGetTimestamp_Context *ctx
0205 )
0206 {
0207 ctx->result = irqamp_get_timestamp_registers( &ctx->irqamp_regs );
0208 }
0209
0210 static const DevGrlibReqIrqampGetTimestamp_Entry
0211 DevGrlibReqIrqampGetTimestamp_Entries[] = {
0212 { 0, 0, DevGrlibReqIrqampGetTimestamp_Post_Result_Null },
0213 { 0, 0, DevGrlibReqIrqampGetTimestamp_Post_Result_Registers }
0214 };
0215
0216 static const uint8_t
0217 DevGrlibReqIrqampGetTimestamp_Map[] = {
0218 0, 1
0219 };
0220
0221 static size_t DevGrlibReqIrqampGetTimestamp_Scope(
0222 void *arg,
0223 char *buf,
0224 size_t n
0225 )
0226 {
0227 DevGrlibReqIrqampGetTimestamp_Context *ctx;
0228
0229 ctx = arg;
0230
0231 if ( ctx->Map.in_action_loop ) {
0232 return T_get_scope(
0233 DevGrlibReqIrqampGetTimestamp_PreDesc,
0234 buf,
0235 n,
0236 ctx->Map.pcs
0237 );
0238 }
0239
0240 return 0;
0241 }
0242
0243 static T_fixture DevGrlibReqIrqampGetTimestamp_Fixture = {
0244 .setup = NULL,
0245 .stop = NULL,
0246 .teardown = NULL,
0247 .scope = DevGrlibReqIrqampGetTimestamp_Scope,
0248 .initial_context = &DevGrlibReqIrqampGetTimestamp_Instance
0249 };
0250
0251 static inline DevGrlibReqIrqampGetTimestamp_Entry
0252 DevGrlibReqIrqampGetTimestamp_PopEntry(
0253 DevGrlibReqIrqampGetTimestamp_Context *ctx
0254 )
0255 {
0256 size_t index;
0257
0258 index = ctx->Map.index;
0259 ctx->Map.index = index + 1;
0260 return DevGrlibReqIrqampGetTimestamp_Entries[
0261 DevGrlibReqIrqampGetTimestamp_Map[ index ]
0262 ];
0263 }
0264
0265 static void DevGrlibReqIrqampGetTimestamp_TestVariant(
0266 DevGrlibReqIrqampGetTimestamp_Context *ctx
0267 )
0268 {
0269 DevGrlibReqIrqampGetTimestamp_Pre_NumberOfTimestampRegisterSets_Prepare(
0270 ctx,
0271 ctx->Map.pcs[ 0 ]
0272 );
0273 DevGrlibReqIrqampGetTimestamp_Action( ctx );
0274 DevGrlibReqIrqampGetTimestamp_Post_Result_Check(
0275 ctx,
0276 ctx->Map.entry.Post_Result
0277 );
0278 }
0279
0280
0281
0282
0283 T_TEST_CASE_FIXTURE(
0284 DevGrlibReqIrqampGetTimestamp,
0285 &DevGrlibReqIrqampGetTimestamp_Fixture
0286 )
0287 {
0288 DevGrlibReqIrqampGetTimestamp_Context *ctx;
0289
0290 ctx = T_fixture_context();
0291 ctx->Map.in_action_loop = true;
0292 ctx->Map.index = 0;
0293
0294 for (
0295 ctx->Map.pcs[ 0 ] = DevGrlibReqIrqampGetTimestamp_Pre_NumberOfTimestampRegisterSets_Zero;
0296 ctx->Map.pcs[ 0 ] < DevGrlibReqIrqampGetTimestamp_Pre_NumberOfTimestampRegisterSets_NA;
0297 ++ctx->Map.pcs[ 0 ]
0298 ) {
0299 ctx->Map.entry = DevGrlibReqIrqampGetTimestamp_PopEntry( ctx );
0300 DevGrlibReqIrqampGetTimestamp_TestVariant( ctx );
0301 }
0302 }
0303
0304