RTEMS
tr-object-ident-local.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-local.h"
53 
54 #include <rtems/test.h>
55 
67 typedef struct {
68  rtems_status_code status;
69 
70  rtems_name name;
71 
72  rtems_id *id;
73 
74  rtems_id id_value;
75 
81 
87 
91  size_t pcs[ 2 ];
92 
99 
101  RtemsReqIdentLocal_Instance;
102 
103 static const char * const RtemsReqIdentLocal_PreDesc_Name[] = {
104  "Invalid",
105  "Valid",
106  "NA"
107 };
108 
109 static const char * const RtemsReqIdentLocal_PreDesc_Id[] = {
110  "NullPtr",
111  "Valid",
112  "NA"
113 };
114 
115 static const char * const * const RtemsReqIdentLocal_PreDesc[] = {
116  RtemsReqIdentLocal_PreDesc_Name,
117  RtemsReqIdentLocal_PreDesc_Id,
118  NULL
119 };
120 
121 static void RtemsReqIdentLocal_Pre_Name_Prepare(
123  RtemsReqIdentLocal_Pre_Name state
124 )
125 {
126  switch ( state ) {
127  case RtemsReqIdentLocal_Pre_Name_Invalid: {
128  ctx->name = 1;
129  break;
130  }
131 
132  case RtemsReqIdentLocal_Pre_Name_Valid: {
133  ctx->name = ClassicObjectLocalIdentName;
134  break;
135  }
136 
137  case RtemsReqIdentLocal_Pre_Name_NA:
138  break;
139  }
140 }
141 
142 static void RtemsReqIdentLocal_Pre_Id_Prepare(
144  RtemsReqIdentLocal_Pre_Id state
145 )
146 {
147  switch ( state ) {
148  case RtemsReqIdentLocal_Pre_Id_NullPtr: {
149  ctx->id = NULL;
150  break;
151  }
152 
153  case RtemsReqIdentLocal_Pre_Id_Valid: {
154  ctx->id_value = 0xffffffff;
155  ctx->id = &ctx->id_value;
156  break;
157  }
158 
159  case RtemsReqIdentLocal_Pre_Id_NA:
160  break;
161  }
162 }
163 
164 static void RtemsReqIdentLocal_Post_Status_Check(
166  RtemsReqIdentLocal_Post_Status state
167 )
168 {
169  switch ( state ) {
170  case RtemsReqIdentLocal_Post_Status_Ok: {
171  T_rsc( ctx->status, RTEMS_SUCCESSFUL );
172  break;
173  }
174 
175  case RtemsReqIdentLocal_Post_Status_InvAddr: {
176  T_rsc( ctx->status, RTEMS_INVALID_ADDRESS );
177  break;
178  }
179 
180  case RtemsReqIdentLocal_Post_Status_InvName: {
181  T_rsc( ctx->status, RTEMS_INVALID_NAME );
182  break;
183  }
184 
185  case RtemsReqIdentLocal_Post_Status_NA:
186  break;
187  }
188 }
189 
190 static void RtemsReqIdentLocal_Post_Id_Check(
192  RtemsReqIdentLocal_Post_Id state
193 )
194 {
195  switch ( state ) {
196  case RtemsReqIdentLocal_Post_Id_Nop: {
197  T_eq_ptr( ctx->id, &ctx->id_value );
198  T_eq_u32( ctx->id_value, 0xffffffff );
199  break;
200  }
201 
202  case RtemsReqIdentLocal_Post_Id_NullPtr: {
203  T_null( ctx->id )
204  break;
205  }
206 
207  case RtemsReqIdentLocal_Post_Id_Id: {
208  T_eq_ptr( ctx->id, &ctx->id_value );
209  T_eq_u32( ctx->id_value, ctx->id_local_object );
210  break;
211  }
212 
213  case RtemsReqIdentLocal_Post_Id_NA:
214  break;
215  }
216 }
217 
218 static size_t RtemsReqIdentLocal_Scope( void *arg, char *buf, size_t n )
219 {
221 
222  ctx = arg;
223 
224  if ( ctx->in_action_loop ) {
225  return T_get_scope( RtemsReqIdentLocal_PreDesc, buf, n, ctx->pcs );
226  }
227 
228  return 0;
229 }
230 
231 static T_fixture RtemsReqIdentLocal_Fixture = {
232  .setup = NULL,
233  .stop = NULL,
234  .teardown = NULL,
235  .scope = RtemsReqIdentLocal_Scope,
236  .initial_context = &RtemsReqIdentLocal_Instance
237 };
238 
239 static const uint8_t RtemsReqIdentLocal_TransitionMap[][ 2 ] = {
240  {
241  RtemsReqIdentLocal_Post_Status_InvAddr,
242  RtemsReqIdentLocal_Post_Id_NullPtr
243  }, {
244  RtemsReqIdentLocal_Post_Status_InvName,
245  RtemsReqIdentLocal_Post_Id_Nop
246  }, {
247  RtemsReqIdentLocal_Post_Status_InvAddr,
248  RtemsReqIdentLocal_Post_Id_NullPtr
249  }, {
250  RtemsReqIdentLocal_Post_Status_Ok,
251  RtemsReqIdentLocal_Post_Id_Id
252  }
253 };
254 
255 static const struct {
256  uint8_t Skip : 1;
257  uint8_t Pre_Name_NA : 1;
258  uint8_t Pre_Id_NA : 1;
259 } RtemsReqIdentLocal_TransitionInfo[] = {
260  {
261  0, 0, 0
262  }, {
263  0, 0, 0
264  }, {
265  0, 0, 0
266  }, {
267  0, 0, 0
268  }
269 };
270 
271 static void RtemsReqIdentLocal_Action( RtemsReqIdentLocal_Context *ctx )
272 {
273  ctx->status = ( *ctx->action )( ctx->name, ctx->id );
274 }
275 
276 static T_fixture_node RtemsReqIdentLocal_Node;
277 
279  rtems_id id_local_object,
280  rtems_status_code ( *action )( rtems_name, rtems_id * )
281 )
282 {
284  size_t index;
285 
286  ctx = T_push_fixture( &RtemsReqIdentLocal_Node, &RtemsReqIdentLocal_Fixture );
287 
288  ctx->id_local_object = id_local_object;
289  ctx->action = action;
290  ctx->in_action_loop = true;
291  index = 0;
292 
293  for (
294  ctx->pcs[ 0 ] = RtemsReqIdentLocal_Pre_Name_Invalid;
295  ctx->pcs[ 0 ] < RtemsReqIdentLocal_Pre_Name_NA;
296  ++ctx->pcs[ 0 ]
297  ) {
298  if ( RtemsReqIdentLocal_TransitionInfo[ index ].Pre_Name_NA ) {
299  ctx->pcs[ 0 ] = RtemsReqIdentLocal_Pre_Name_NA;
300  index += ( RtemsReqIdentLocal_Pre_Name_NA - 1 )
301  * RtemsReqIdentLocal_Pre_Id_NA;
302  }
303 
304  for (
305  ctx->pcs[ 1 ] = RtemsReqIdentLocal_Pre_Id_NullPtr;
306  ctx->pcs[ 1 ] < RtemsReqIdentLocal_Pre_Id_NA;
307  ++ctx->pcs[ 1 ]
308  ) {
309  if ( RtemsReqIdentLocal_TransitionInfo[ index ].Pre_Id_NA ) {
310  ctx->pcs[ 1 ] = RtemsReqIdentLocal_Pre_Id_NA;
311  index += ( RtemsReqIdentLocal_Pre_Id_NA - 1 );
312  }
313 
314  if ( RtemsReqIdentLocal_TransitionInfo[ index ].Skip ) {
315  ++index;
316  continue;
317  }
318 
319  RtemsReqIdentLocal_Pre_Name_Prepare( ctx, ctx->pcs[ 0 ] );
320  RtemsReqIdentLocal_Pre_Id_Prepare( ctx, ctx->pcs[ 1 ] );
321  RtemsReqIdentLocal_Action( ctx );
322  RtemsReqIdentLocal_Post_Status_Check(
323  ctx,
324  RtemsReqIdentLocal_TransitionMap[ index ][ 0 ]
325  );
326  RtemsReqIdentLocal_Post_Id_Check(
327  ctx,
328  RtemsReqIdentLocal_TransitionMap[ index ][ 1 ]
329  );
330  ++index;
331  }
332  }
333 
334  T_pop_fixture();
335 }
336 
Test context for spec:/rtems/req/ident-local test case.
rtems_status_code(* action)(rtems_name, rtems_id *)
This member contains a copy of the corresponding RtemsReqIdentLocal_Run() parameter.
uint32_t rtems_name
This type is used to represent a Classic API object name.
Definition: types.h:227
size_t pcs[2]
This member defines the pre-condition states for the next action.
void RtemsReqIdentLocal_Run(rtems_id id_local_object, rtems_status_code(*action)(rtems_name, rtems_id *))
Runs the parameterized test case.
This status code indicates successful completion.
Definition: status.h:86
rtems_status_code
This enumeration provides status codes for directives of the Classic API.
Definition: status.h:82
bool in_action_loop
This member indicates if the test action loop is currently executed.
rtems_id id_local_object
This member contains a copy of the corresponding RtemsReqIdentLocal_Run() parameter.
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