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 <string.h>
0056 #include <grlib/apbuart.h>
0057
0058 #include <rtems/test.h>
0059
0060
0061
0062
0063
0064
0065
0066
0067
0068
0069 typedef enum {
0070 DevGrlibReqApbuartInbyteNonblocking_Pre_DataReady_Yes,
0071 DevGrlibReqApbuartInbyteNonblocking_Pre_DataReady_No,
0072 DevGrlibReqApbuartInbyteNonblocking_Pre_DataReady_NA
0073 } DevGrlibReqApbuartInbyteNonblocking_Pre_DataReady;
0074
0075 typedef enum {
0076 DevGrlibReqApbuartInbyteNonblocking_Post_Result_Data,
0077 DevGrlibReqApbuartInbyteNonblocking_Post_Result_MinusOne,
0078 DevGrlibReqApbuartInbyteNonblocking_Post_Result_NA
0079 } DevGrlibReqApbuartInbyteNonblocking_Post_Result;
0080
0081 typedef enum {
0082 DevGrlibReqApbuartInbyteNonblocking_Post_ErrorFlags_Cleared,
0083 DevGrlibReqApbuartInbyteNonblocking_Post_ErrorFlags_NA
0084 } DevGrlibReqApbuartInbyteNonblocking_Post_ErrorFlags;
0085
0086 typedef struct {
0087 uint8_t Skip : 1;
0088 uint8_t Pre_DataReady_NA : 1;
0089 uint8_t Post_Result : 2;
0090 uint8_t Post_ErrorFlags : 1;
0091 } DevGrlibReqApbuartInbyteNonblocking_Entry;
0092
0093
0094
0095
0096
0097 typedef struct {
0098
0099
0100
0101 apbuart regs;
0102
0103
0104
0105
0106
0107 int result;
0108
0109 struct {
0110
0111
0112
0113 size_t pcs[ 1 ];
0114
0115
0116
0117
0118 bool in_action_loop;
0119
0120
0121
0122
0123 size_t index;
0124
0125
0126
0127
0128 DevGrlibReqApbuartInbyteNonblocking_Entry entry;
0129
0130
0131
0132
0133
0134 bool skip;
0135 } Map;
0136 } DevGrlibReqApbuartInbyteNonblocking_Context;
0137
0138 static DevGrlibReqApbuartInbyteNonblocking_Context
0139 DevGrlibReqApbuartInbyteNonblocking_Instance;
0140
0141 static const char * const DevGrlibReqApbuartInbyteNonblocking_PreDesc_DataReady[] = {
0142 "Yes",
0143 "No",
0144 "NA"
0145 };
0146
0147 static const char * const * const DevGrlibReqApbuartInbyteNonblocking_PreDesc[] = {
0148 DevGrlibReqApbuartInbyteNonblocking_PreDesc_DataReady,
0149 NULL
0150 };
0151
0152 static void DevGrlibReqApbuartInbyteNonblocking_Pre_DataReady_Prepare(
0153 DevGrlibReqApbuartInbyteNonblocking_Context *ctx,
0154 DevGrlibReqApbuartInbyteNonblocking_Pre_DataReady state
0155 )
0156 {
0157 switch ( state ) {
0158 case DevGrlibReqApbuartInbyteNonblocking_Pre_DataReady_Yes: {
0159
0160
0161
0162
0163 ctx->regs.status |= APBUART_STATUS_DR;
0164 break;
0165 }
0166
0167 case DevGrlibReqApbuartInbyteNonblocking_Pre_DataReady_No: {
0168
0169
0170
0171
0172 ctx->regs.status &= ~APBUART_STATUS_DR;
0173 break;
0174 }
0175
0176 case DevGrlibReqApbuartInbyteNonblocking_Pre_DataReady_NA:
0177 break;
0178 }
0179 }
0180
0181 static void DevGrlibReqApbuartInbyteNonblocking_Post_Result_Check(
0182 DevGrlibReqApbuartInbyteNonblocking_Context *ctx,
0183 DevGrlibReqApbuartInbyteNonblocking_Post_Result state
0184 )
0185 {
0186 switch ( state ) {
0187 case DevGrlibReqApbuartInbyteNonblocking_Post_Result_Data: {
0188
0189
0190
0191
0192
0193 T_eq_int( ctx->result, 0xff );
0194 break;
0195 }
0196
0197 case DevGrlibReqApbuartInbyteNonblocking_Post_Result_MinusOne: {
0198
0199
0200
0201 T_eq_int( ctx->result, -1 );
0202 break;
0203 }
0204
0205 case DevGrlibReqApbuartInbyteNonblocking_Post_Result_NA:
0206 break;
0207 }
0208 }
0209
0210 static void DevGrlibReqApbuartInbyteNonblocking_Post_ErrorFlags_Check(
0211 DevGrlibReqApbuartInbyteNonblocking_Context *ctx,
0212 DevGrlibReqApbuartInbyteNonblocking_Post_ErrorFlags state
0213 )
0214 {
0215 switch ( state ) {
0216 case DevGrlibReqApbuartInbyteNonblocking_Post_ErrorFlags_Cleared: {
0217
0218
0219
0220
0221
0222 T_eq_u32( ctx->regs.status & 0x78, 0 );
0223 break;
0224 }
0225
0226 case DevGrlibReqApbuartInbyteNonblocking_Post_ErrorFlags_NA:
0227 break;
0228 }
0229 }
0230
0231 static void DevGrlibReqApbuartInbyteNonblocking_Prepare(
0232 DevGrlibReqApbuartInbyteNonblocking_Context *ctx
0233 )
0234 {
0235 memset( &ctx->regs, 0, sizeof( ctx->regs ) );
0236 ctx->regs.status = 0x78;
0237 ctx->regs.data = 0xff;
0238 }
0239
0240 static void DevGrlibReqApbuartInbyteNonblocking_Action(
0241 DevGrlibReqApbuartInbyteNonblocking_Context *ctx
0242 )
0243 {
0244 ctx->result = apbuart_inbyte_nonblocking( &ctx->regs );
0245 }
0246
0247 static const DevGrlibReqApbuartInbyteNonblocking_Entry
0248 DevGrlibReqApbuartInbyteNonblocking_Entries[] = {
0249 { 0, 0, DevGrlibReqApbuartInbyteNonblocking_Post_Result_Data,
0250 DevGrlibReqApbuartInbyteNonblocking_Post_ErrorFlags_Cleared },
0251 { 0, 0, DevGrlibReqApbuartInbyteNonblocking_Post_Result_MinusOne,
0252 DevGrlibReqApbuartInbyteNonblocking_Post_ErrorFlags_Cleared }
0253 };
0254
0255 static const uint8_t
0256 DevGrlibReqApbuartInbyteNonblocking_Map[] = {
0257 0, 1
0258 };
0259
0260 static size_t DevGrlibReqApbuartInbyteNonblocking_Scope(
0261 void *arg,
0262 char *buf,
0263 size_t n
0264 )
0265 {
0266 DevGrlibReqApbuartInbyteNonblocking_Context *ctx;
0267
0268 ctx = arg;
0269
0270 if ( ctx->Map.in_action_loop ) {
0271 return T_get_scope(
0272 DevGrlibReqApbuartInbyteNonblocking_PreDesc,
0273 buf,
0274 n,
0275 ctx->Map.pcs
0276 );
0277 }
0278
0279 return 0;
0280 }
0281
0282 static T_fixture DevGrlibReqApbuartInbyteNonblocking_Fixture = {
0283 .setup = NULL,
0284 .stop = NULL,
0285 .teardown = NULL,
0286 .scope = DevGrlibReqApbuartInbyteNonblocking_Scope,
0287 .initial_context = &DevGrlibReqApbuartInbyteNonblocking_Instance
0288 };
0289
0290 static inline DevGrlibReqApbuartInbyteNonblocking_Entry
0291 DevGrlibReqApbuartInbyteNonblocking_PopEntry(
0292 DevGrlibReqApbuartInbyteNonblocking_Context *ctx
0293 )
0294 {
0295 size_t index;
0296
0297 index = ctx->Map.index;
0298 ctx->Map.index = index + 1;
0299 return DevGrlibReqApbuartInbyteNonblocking_Entries[
0300 DevGrlibReqApbuartInbyteNonblocking_Map[ index ]
0301 ];
0302 }
0303
0304 static void DevGrlibReqApbuartInbyteNonblocking_TestVariant(
0305 DevGrlibReqApbuartInbyteNonblocking_Context *ctx
0306 )
0307 {
0308 DevGrlibReqApbuartInbyteNonblocking_Pre_DataReady_Prepare(
0309 ctx,
0310 ctx->Map.pcs[ 0 ]
0311 );
0312 DevGrlibReqApbuartInbyteNonblocking_Action( ctx );
0313 DevGrlibReqApbuartInbyteNonblocking_Post_Result_Check(
0314 ctx,
0315 ctx->Map.entry.Post_Result
0316 );
0317 DevGrlibReqApbuartInbyteNonblocking_Post_ErrorFlags_Check(
0318 ctx,
0319 ctx->Map.entry.Post_ErrorFlags
0320 );
0321 }
0322
0323
0324
0325
0326 T_TEST_CASE_FIXTURE(
0327 DevGrlibReqApbuartInbyteNonblocking,
0328 &DevGrlibReqApbuartInbyteNonblocking_Fixture
0329 )
0330 {
0331 DevGrlibReqApbuartInbyteNonblocking_Context *ctx;
0332
0333 ctx = T_fixture_context();
0334 ctx->Map.in_action_loop = true;
0335 ctx->Map.index = 0;
0336
0337 for (
0338 ctx->Map.pcs[ 0 ] = DevGrlibReqApbuartInbyteNonblocking_Pre_DataReady_Yes;
0339 ctx->Map.pcs[ 0 ] < DevGrlibReqApbuartInbyteNonblocking_Pre_DataReady_NA;
0340 ++ctx->Map.pcs[ 0 ]
0341 ) {
0342 ctx->Map.entry = DevGrlibReqApbuartInbyteNonblocking_PopEntry( ctx );
0343 DevGrlibReqApbuartInbyteNonblocking_Prepare( ctx );
0344 DevGrlibReqApbuartInbyteNonblocking_TestVariant( ctx );
0345 }
0346 }
0347
0348