RTEMS
tr-object-ident.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: BSD-2-Clause */
2 
9 /*
10  * Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de)
11  *
12  * Redistribution and use in source and binary forms, with or without
13  * modification, are permitted provided that the following conditions
14  * are met:
15  * 1. Redistributions of source code must retain the above copyright
16  * notice, this list of conditions and the following disclaimer.
17  * 2. Redistributions in binary form must reproduce the above copyright
18  * notice, this list of conditions and the following disclaimer in the
19  * documentation and/or other materials provided with the distribution.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
25  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31  * POSSIBILITY OF SUCH DAMAGE.
32  */
33 
34 /*
35  * Do not manually edit this file. It is part of the RTEMS quality process
36  * and was automatically generated.
37  *
38  * If you find something that needs to be fixed or worded better please
39  * post a report to an RTEMS mailing list or raise a bug report:
40  *
41  * https://docs.rtems.org/branches/master/user/support/bugs.html
42  *
43  * For information on updating and regenerating please refer to:
44  *
45  * https://docs.rtems.org/branches/master/eng/req/howto.html
46  */
47 
48 #ifdef HAVE_CONFIG_H
49 #include "config.h"
50 #endif
51 
52 #include "tr-object-ident.h"
53 
54 #include <rtems/test.h>
55 
67 typedef struct {
68  rtems_status_code status;
69 
70  rtems_name name;
71 
72  uint32_t node;
73 
74  rtems_id *id;
75 
76  rtems_id id_value;
77 
78  rtems_id id_remote_object;
79 
85 
90  rtems_status_code ( *action )( rtems_name, uint32_t, rtems_id * );
91 
95  size_t pcs[ 3 ];
96 
103 
105  RtemsReqIdent_Instance;
106 
107 static const char * const RtemsReqIdent_PreDesc_Name[] = {
108  "Invalid",
109  "Valid",
110  "NA"
111 };
112 
113 static const char * const RtemsReqIdent_PreDesc_Node[] = {
114  "Local",
115  "Remote",
116  "Invalid",
117  "SearchAll",
118  "SearchOther",
119  "SearchLocal",
120  "NA"
121 };
122 
123 static const char * const RtemsReqIdent_PreDesc_Id[] = {
124  "NullPtr",
125  "Valid",
126  "NA"
127 };
128 
129 static const char * const * const RtemsReqIdent_PreDesc[] = {
130  RtemsReqIdent_PreDesc_Name,
131  RtemsReqIdent_PreDesc_Node,
132  RtemsReqIdent_PreDesc_Id,
133  NULL
134 };
135 
136 static void RtemsReqIdent_Pre_Name_Prepare(
138  RtemsReqIdent_Pre_Name state
139 )
140 {
141  switch ( state ) {
142  case RtemsReqIdent_Pre_Name_Invalid: {
143  ctx->name = 1;
144  break;
145  }
146 
147  case RtemsReqIdent_Pre_Name_Valid: {
148  ctx->name = ClassicObjectIdentName;
149  break;
150  }
151 
152  case RtemsReqIdent_Pre_Name_NA:
153  break;
154  }
155 }
156 
157 static void RtemsReqIdent_Pre_Node_Prepare(
159  RtemsReqIdent_Pre_Node state
160 )
161 {
162  switch ( state ) {
163  case RtemsReqIdent_Pre_Node_Local: {
164  ctx->node = 1;
165  break;
166  }
167 
168  case RtemsReqIdent_Pre_Node_Remote: {
169  ctx->node = 2;
170  break;
171  }
172 
173  case RtemsReqIdent_Pre_Node_Invalid: {
174  ctx->node = 256;
175  break;
176  }
177 
178  case RtemsReqIdent_Pre_Node_SearchAll: {
179  ctx->node = RTEMS_SEARCH_ALL_NODES;
180  break;
181  }
182 
183  case RtemsReqIdent_Pre_Node_SearchOther: {
184  ctx->node = RTEMS_SEARCH_OTHER_NODES;
185  break;
186  }
187 
188  case RtemsReqIdent_Pre_Node_SearchLocal: {
189  ctx->node = RTEMS_SEARCH_LOCAL_NODE;
190  break;
191  }
192 
193  case RtemsReqIdent_Pre_Node_NA:
194  break;
195  }
196 }
197 
198 static void RtemsReqIdent_Pre_Id_Prepare(
200  RtemsReqIdent_Pre_Id state
201 )
202 {
203  switch ( state ) {
204  case RtemsReqIdent_Pre_Id_NullPtr: {
205  ctx->id = NULL;
206  break;
207  }
208 
209  case RtemsReqIdent_Pre_Id_Valid: {
210  ctx->id_value = 0xffffffff;
211  ctx->id = &ctx->id_value;
212  break;
213  }
214 
215  case RtemsReqIdent_Pre_Id_NA:
216  break;
217  }
218 }
219 
220 static void RtemsReqIdent_Post_Status_Check(
222  RtemsReqIdent_Post_Status state
223 )
224 {
225  switch ( state ) {
226  case RtemsReqIdent_Post_Status_Ok: {
227  T_rsc(ctx->status, RTEMS_SUCCESSFUL);
228  break;
229  }
230 
231  case RtemsReqIdent_Post_Status_InvAddr: {
232  T_rsc(ctx->status, RTEMS_INVALID_ADDRESS);
233  break;
234  }
235 
236  case RtemsReqIdent_Post_Status_InvName: {
237  T_rsc(ctx->status, RTEMS_INVALID_NAME);
238  break;
239  }
240 
241  case RtemsReqIdent_Post_Status_InvNode: {
242  T_rsc(ctx->status, RTEMS_INVALID_NODE);
243  break;
244  }
245 
246  case RtemsReqIdent_Post_Status_NA:
247  break;
248  }
249 }
250 
251 static void RtemsReqIdent_Post_Id_Check(
253  RtemsReqIdent_Post_Id state
254 )
255 {
256  switch ( state ) {
257  case RtemsReqIdent_Post_Id_Nop: {
258  T_eq_ptr(ctx->id, &ctx->id_value);
259  T_eq_u32(ctx->id_value, 0xffffffff);
260  break;
261  }
262 
263  case RtemsReqIdent_Post_Id_NullPtr: {
264  T_null(ctx->id)
265  break;
266  }
267 
268  case RtemsReqIdent_Post_Id_LocalObj: {
269  T_eq_ptr(ctx->id, &ctx->id_value);
270  T_eq_u32(ctx->id_value, ctx->id_local_object);
271  break;
272  }
273 
274  case RtemsReqIdent_Post_Id_RemoteObj: {
275  T_eq_ptr(ctx->id, &ctx->id_value);
276  T_eq_u32(ctx->id_value, ctx->id_remote_object);
277  break;
278  }
279 
280  case RtemsReqIdent_Post_Id_NA:
281  break;
282  }
283 }
284 
285 static size_t RtemsReqIdent_Scope( void *arg, char *buf, size_t n )
286 {
288 
289  ctx = arg;
290 
291  if ( ctx->in_action_loop ) {
292  return T_get_scope( RtemsReqIdent_PreDesc, buf, n, ctx->pcs );
293  }
294 
295  return 0;
296 }
297 
298 static T_fixture RtemsReqIdent_Fixture = {
299  .setup = NULL,
300  .stop = NULL,
301  .teardown = NULL,
302  .scope = RtemsReqIdent_Scope,
303  .initial_context = &RtemsReqIdent_Instance
304 };
305 
306 static const uint8_t RtemsReqIdent_TransitionMap[][ 2 ] = {
307  {
308  RtemsReqIdent_Post_Status_InvAddr,
309  RtemsReqIdent_Post_Id_NullPtr
310  }, {
311  RtemsReqIdent_Post_Status_InvName,
312  RtemsReqIdent_Post_Id_Nop
313  }, {
314  RtemsReqIdent_Post_Status_InvAddr,
315  RtemsReqIdent_Post_Id_NullPtr
316  }, {
317  RtemsReqIdent_Post_Status_InvName,
318  RtemsReqIdent_Post_Id_Nop
319  }, {
320  RtemsReqIdent_Post_Status_InvAddr,
321  RtemsReqIdent_Post_Id_NullPtr
322  }, {
323  RtemsReqIdent_Post_Status_InvName,
324  RtemsReqIdent_Post_Id_Nop
325  }, {
326  RtemsReqIdent_Post_Status_InvAddr,
327  RtemsReqIdent_Post_Id_NullPtr
328  }, {
329  RtemsReqIdent_Post_Status_InvName,
330  RtemsReqIdent_Post_Id_Nop
331  }, {
332  RtemsReqIdent_Post_Status_InvAddr,
333  RtemsReqIdent_Post_Id_NullPtr
334  }, {
335  RtemsReqIdent_Post_Status_InvName,
336  RtemsReqIdent_Post_Id_Nop
337  }, {
338  RtemsReqIdent_Post_Status_InvAddr,
339  RtemsReqIdent_Post_Id_NullPtr
340  }, {
341  RtemsReqIdent_Post_Status_InvName,
342  RtemsReqIdent_Post_Id_Nop
343  }, {
344  RtemsReqIdent_Post_Status_InvAddr,
345  RtemsReqIdent_Post_Id_NullPtr
346  }, {
347  RtemsReqIdent_Post_Status_Ok,
348  RtemsReqIdent_Post_Id_LocalObj
349  }, {
350  RtemsReqIdent_Post_Status_InvAddr,
351  RtemsReqIdent_Post_Id_NullPtr
352  }, {
353 #if defined(RTEMS_MULTIPROCESSING)
354  RtemsReqIdent_Post_Status_Ok,
355  RtemsReqIdent_Post_Id_RemoteObj
356 #else
357  RtemsReqIdent_Post_Status_InvName,
358  RtemsReqIdent_Post_Id_Nop
359 #endif
360  }, {
361  RtemsReqIdent_Post_Status_InvAddr,
362  RtemsReqIdent_Post_Id_NullPtr
363  }, {
364  RtemsReqIdent_Post_Status_InvName,
365  RtemsReqIdent_Post_Id_Nop
366  }, {
367  RtemsReqIdent_Post_Status_InvAddr,
368  RtemsReqIdent_Post_Id_NullPtr
369  }, {
370  RtemsReqIdent_Post_Status_Ok,
371  RtemsReqIdent_Post_Id_LocalObj
372  }, {
373  RtemsReqIdent_Post_Status_InvAddr,
374  RtemsReqIdent_Post_Id_NullPtr
375  }, {
376 #if defined(RTEMS_MULTIPROCESSING)
377  RtemsReqIdent_Post_Status_Ok,
378  RtemsReqIdent_Post_Id_RemoteObj
379 #else
380  RtemsReqIdent_Post_Status_InvName,
381  RtemsReqIdent_Post_Id_Nop
382 #endif
383  }, {
384  RtemsReqIdent_Post_Status_InvAddr,
385  RtemsReqIdent_Post_Id_NullPtr
386  }, {
387  RtemsReqIdent_Post_Status_Ok,
388  RtemsReqIdent_Post_Id_LocalObj
389  }
390 };
391 
392 static const struct {
393  uint8_t Skip : 1;
394  uint8_t Pre_Name_NA : 1;
395  uint8_t Pre_Node_NA : 1;
396  uint8_t Pre_Id_NA : 1;
397 } RtemsReqIdent_TransitionInfo[] = {
398  {
399  0, 0, 0, 0
400  }, {
401  0, 0, 0, 0
402  }, {
403  0, 0, 0, 0
404  }, {
405  0, 0, 0, 0
406  }, {
407  0, 0, 0, 0
408  }, {
409  0, 0, 0, 0
410  }, {
411  0, 0, 0, 0
412  }, {
413  0, 0, 0, 0
414  }, {
415  0, 0, 0, 0
416  }, {
417  0, 0, 0, 0
418  }, {
419  0, 0, 0, 0
420  }, {
421  0, 0, 0, 0
422  }, {
423  0, 0, 0, 0
424  }, {
425  0, 0, 0, 0
426  }, {
427  0, 0, 0, 0
428  }, {
429 #if defined(RTEMS_MULTIPROCESSING)
430  0, 0, 0, 0
431 #else
432  0, 0, 0, 0
433 #endif
434  }, {
435  0, 0, 0, 0
436  }, {
437  0, 0, 0, 0
438  }, {
439  0, 0, 0, 0
440  }, {
441  0, 0, 0, 0
442  }, {
443  0, 0, 0, 0
444  }, {
445 #if defined(RTEMS_MULTIPROCESSING)
446  0, 0, 0, 0
447 #else
448  0, 0, 0, 0
449 #endif
450  }, {
451  0, 0, 0, 0
452  }, {
453  0, 0, 0, 0
454  }
455 };
456 
457 static void RtemsReqIdent_Action( RtemsReqIdent_Context *ctx )
458 {
459  ctx->status = ( *ctx->action )( ctx->name, ctx->node, ctx->id );
460 }
461 
462 static T_fixture_node RtemsReqIdent_Node;
463 
465  rtems_id id_local_object,
466  rtems_status_code ( *action )( rtems_name, uint32_t, rtems_id * )
467 )
468 {
470  size_t index;
471 
472  ctx = T_push_fixture( &RtemsReqIdent_Node, &RtemsReqIdent_Fixture );
473 
474  ctx->id_local_object = id_local_object;
475  ctx->action = action;
476  ctx->in_action_loop = true;
477  index = 0;
478 
479  for (
480  ctx->pcs[ 0 ] = RtemsReqIdent_Pre_Name_Invalid;
481  ctx->pcs[ 0 ] < RtemsReqIdent_Pre_Name_NA;
482  ++ctx->pcs[ 0 ]
483  ) {
484  if ( RtemsReqIdent_TransitionInfo[ index ].Pre_Name_NA ) {
485  ctx->pcs[ 0 ] = RtemsReqIdent_Pre_Name_NA;
486  index += ( RtemsReqIdent_Pre_Name_NA - 1 )
487  * RtemsReqIdent_Pre_Node_NA
488  * RtemsReqIdent_Pre_Id_NA;
489  }
490 
491  for (
492  ctx->pcs[ 1 ] = RtemsReqIdent_Pre_Node_Local;
493  ctx->pcs[ 1 ] < RtemsReqIdent_Pre_Node_NA;
494  ++ctx->pcs[ 1 ]
495  ) {
496  if ( RtemsReqIdent_TransitionInfo[ index ].Pre_Node_NA ) {
497  ctx->pcs[ 1 ] = RtemsReqIdent_Pre_Node_NA;
498  index += ( RtemsReqIdent_Pre_Node_NA - 1 )
499  * RtemsReqIdent_Pre_Id_NA;
500  }
501 
502  for (
503  ctx->pcs[ 2 ] = RtemsReqIdent_Pre_Id_NullPtr;
504  ctx->pcs[ 2 ] < RtemsReqIdent_Pre_Id_NA;
505  ++ctx->pcs[ 2 ]
506  ) {
507  if ( RtemsReqIdent_TransitionInfo[ index ].Pre_Id_NA ) {
508  ctx->pcs[ 2 ] = RtemsReqIdent_Pre_Id_NA;
509  index += ( RtemsReqIdent_Pre_Id_NA - 1 );
510  }
511 
512  if ( RtemsReqIdent_TransitionInfo[ index ].Skip ) {
513  ++index;
514  continue;
515  }
516 
517  RtemsReqIdent_Pre_Name_Prepare( ctx, ctx->pcs[ 0 ] );
518  RtemsReqIdent_Pre_Node_Prepare( ctx, ctx->pcs[ 1 ] );
519  RtemsReqIdent_Pre_Id_Prepare( ctx, ctx->pcs[ 2 ] );
520  RtemsReqIdent_Action( ctx );
521  RtemsReqIdent_Post_Status_Check(
522  ctx,
523  RtemsReqIdent_TransitionMap[ index ][ 0 ]
524  );
525  RtemsReqIdent_Post_Id_Check(
526  ctx,
527  RtemsReqIdent_TransitionMap[ index ][ 1 ]
528  );
529  ++index;
530  }
531  }
532  }
533 
534  T_pop_fixture();
535 }
536 
bool in_action_loop
This member indicates if the test action loop is currently executed.
rtems_status_code(* action)(rtems_name, uint32_t, rtems_id *)
This member contains a copy of the corresponding RtemsReqIdent_Run() parameter.
uint32_t rtems_name
This type is used to represent a Classic API object name.
Definition: types.h:227
size_t pcs[3]
This member defines the pre-condition states for the next action.
rtems_id id_local_object
This member contains a copy of the corresponding RtemsReqIdent_Run() parameter.
#define RTEMS_SEARCH_ALL_NODES
%
Definition: object.h:391
This status code indicates successful completion.
Definition: status.h:86
void RtemsReqIdent_Run(rtems_id id_local_object, rtems_status_code(*action)(rtems_name, uint32_t, rtems_id *))
Runs the parameterized test case.
rtems_status_code
This enumeration provides status codes for directives of the Classic API.
Definition: status.h:82
#define RTEMS_SEARCH_OTHER_NODES
%
Definition: object.h:409
This status code indicates that a specified node identifier was invalid.
Definition: status.h:200
This status code indicates that a specified address was invalid.
Definition: status.h:133
Definition: test.h:61
Objects_Id rtems_id
Values of this type identify an RTEMS object.
Definition: types.h:99
This status code indicates that an object name was invalid.
Definition: status.h:101
#define RTEMS_SEARCH_LOCAL_NODE
%
Definition: object.h:400
Test context for spec:/rtems/req/ident test case.