RTEMS
tr-event.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 #ifdef HAVE_CONFIG_H
35 #include "config.h"
36 #endif
37 
38 #include <rtems.h>
39 
40 #include "tr-event.h"
41 
42 #include <rtems/test.h>
43 
161 static void ReqRtemsEventValEvent_Wrap( rtems_event_set event, int number )
162 {
164  rtems_event_set out;
165 
166  T_plan(32);
167 
168  /* No action */
169  T_step_eq_u32( 0, event, ( (rtems_event_set) 1 ) << number );
170  T_step_eq_u32( 1, event & RTEMS_PENDING_EVENTS, 0 );
171 
172  out = RTEMS_ALL_EVENTS;
173  sc = rtems_event_receive(
176  0,
177  &out
178  );
179  T_step_rsc_success( 2, sc );
180  T_step_eq_u32( 3, out, 0 );
181 
182  out = RTEMS_ALL_EVENTS;
186  0,
187  &out
188  );
189  T_step_rsc_success( 4, sc );
190  T_step_eq_u32( 5, out, 0 );
191 
192  out = RTEMS_ALL_EVENTS;
193  sc = rtems_event_receive(
196  0,
197  &out
198  );
199  T_step_rsc( 6, sc, RTEMS_UNSATISFIED );
200  T_step_eq_u32( 7, out, 0 );
201 
202  out = RTEMS_ALL_EVENTS;
206  0,
207  &out
208  );
209  T_step_rsc( 8, sc, RTEMS_UNSATISFIED );
210  T_step_eq_u32( 9, out, 0 );
211 
212  sc = rtems_event_send( RTEMS_SELF, event );
213  T_step_rsc_success( 10, sc );
214 
215  out = RTEMS_ALL_EVENTS;
216  sc = rtems_event_receive(
219  0,
220  &out
221  );
222  T_step_rsc_success( 11, sc );
223  T_step_eq_u32( 12, out, event );
224 
225  out = RTEMS_ALL_EVENTS;
229  0,
230  &out
231  );
232  T_step_rsc_success( 13, sc );
233  T_step_eq_u32( 14, out, 0 );
234 
235  out = 0;
236  sc = rtems_event_receive(
239  0,
240  &out
241  );
242  T_step_rsc_success( 15, sc );
243  T_step_eq_u32( 16, out, event );
244 
245  out = RTEMS_ALL_EVENTS;
249  0,
250  &out
251  );
252  T_step_rsc( 17, sc, RTEMS_UNSATISFIED );
253  T_step_eq_u32( 18, out, 0 );
254 
255  sc = rtems_event_system_send( RTEMS_SELF, event );
256  T_step_rsc_success( 19, sc );
257 
258  out = RTEMS_ALL_EVENTS;
259  sc = rtems_event_receive(
262  0,
263  &out
264  );
265  T_step_rsc_success( 20, sc );
266  T_step_eq_u32( 21, out, 0 );
267 
268  out = RTEMS_ALL_EVENTS;
272  0,
273  &out
274  );
275  T_step_rsc_success( 22, sc );
276  T_step_eq_u32( 23, out, event );
277 
278  out = RTEMS_ALL_EVENTS;
279  sc = rtems_event_receive(
282  0,
283  &out
284  );
285  T_step_rsc( 24, sc, RTEMS_UNSATISFIED );
286  T_step_eq_u32( 25, out, 0 );
287 
288  out = 0;
292  0,
293  &out
294  );
295  T_step_rsc_success( 26, sc );
296  T_step_eq_u32( 27, out, event );
297 
298  out = RTEMS_ALL_EVENTS;
299  sc = rtems_event_receive(
302  0,
303  &out
304  );
305  T_step_rsc_success( 28, sc );
306  T_step_eq_u32( 29, out, 0 );
307 
308  out = RTEMS_ALL_EVENTS;
312  0,
313  &out
314  );
315  T_step_rsc_success( 30, sc );
316  T_step_eq_u32( 31, out, 0 );
317 }
318 
319 static T_fixture_node ReqRtemsEventValEvent_Node;
320 
322 {
323  T_push_fixture( &ReqRtemsEventValEvent_Node, &T_empty_fixture );
324  ReqRtemsEventValEvent_Wrap( event, number );
325  T_pop_fixture();
326 }
327 
#define RTEMS_NO_WAIT
This option constant indicates that the task does not want to wait on the resource.
Definition: options.h:112
#define RTEMS_DEFAULT_OPTIONS
This option constant is the default option set.
Definition: options.h:79
rtems_status_code rtems_event_system_send(rtems_id id, rtems_event_set event_in)
Sends a system event set to a task.
This status code indicates that the request was not satisfied.
Definition: status.h:154
#define RTEMS_ALL_EVENTS
This constant contains all events in an event set.
Definition: event.h:207
rtems_status_code rtems_event_system_receive(rtems_event_set event_in, rtems_option option_set, rtems_interval ticks, rtems_event_set *event_out)
Receives or gets a system event set.
#define RTEMS_SELF
%
Definition: tasks.h:1046
#define RTEMS_PENDING_EVENTS
This constant used to get the set of pending events in rtems_event_receive().
Definition: event.h:477
rtems_status_code
This enumeration provides status codes for directives of the Classic API.
Definition: status.h:82
#define RTEMS_EVENT_ANY
This option constant indicates that the task wishes to wait until at least one of the events of inter...
Definition: options.h:99
This header file defines the RTEMS Classic API.
rtems_status_code rtems_event_receive(rtems_event_set event_in, rtems_option option_set, rtems_interval ticks, rtems_event_set *event_out)
Receives or gets an event set.
Definition: eventreceive.c:27
void ReqRtemsEventValEvent_Run(rtems_event_set event, int number)
Runs the parameterized test case.
Definition: tr-event.c:321
uint32_t rtems_event_set
This integer type can hold an event set of up to 32 events represented as a bit field.
Definition: event.h:94
rtems_status_code rtems_event_send(rtems_id id, rtems_event_set event_in)
Sends an event set to a task.
Definition: eventsend.c:25