Back to home page

LXR

 
 

    


File indexing completed on 2025-05-11 08:24:51

0001 /* SPDX-License-Identifier: BSD-2-Clause */
0002 
0003 /**
0004  * @file
0005  *
0006  * @ingroup RtemsEventValSendReceive
0007  * @ingroup RtemsEventValSystemSendReceive
0008  */
0009 
0010 /*
0011  * Copyright (C) 2020 embedded brains GmbH & Co. KG
0012  *
0013  * Redistribution and use in source and binary forms, with or without
0014  * modification, are permitted provided that the following conditions
0015  * are met:
0016  * 1. Redistributions of source code must retain the above copyright
0017  *    notice, this list of conditions and the following disclaimer.
0018  * 2. Redistributions in binary form must reproduce the above copyright
0019  *    notice, this list of conditions and the following disclaimer in the
0020  *    documentation and/or other materials provided with the distribution.
0021  *
0022  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
0023  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
0024  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
0025  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
0026  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
0027  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
0028  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
0029  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
0030  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
0031  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
0032  * POSSIBILITY OF SUCH DAMAGE.
0033  */
0034 
0035 /*
0036  * This file is part of the RTEMS quality process and was automatically
0037  * generated.  If you find something that needs to be fixed or
0038  * worded better please post a report or patch to an RTEMS mailing list
0039  * or raise a bug report:
0040  *
0041  * https://www.rtems.org/bugs.html
0042  *
0043  * For information on updating and regenerating please refer to the How-To
0044  * section in the Software Requirements Engineering chapter of the
0045  * RTEMS Software Engineering manual.  The manual is provided as a part of
0046  * a release.  For development sources please refer to the online
0047  * documentation at:
0048  *
0049  * https://docs.rtems.org
0050  */
0051 
0052 #ifdef HAVE_CONFIG_H
0053 #include "config.h"
0054 #endif
0055 
0056 #include <rtems/rtems/eventimpl.h>
0057 #include <rtems/rtems/tasksdata.h>
0058 #include <rtems/score/statesimpl.h>
0059 #include <rtems/score/threadimpl.h>
0060 
0061 #include "tr-event-send-receive.h"
0062 
0063 #include <rtems/test.h>
0064 
0065 /**
0066  * @defgroup RtemsEventValSendReceive spec:/rtems/event/val/send-receive
0067  *
0068  * @ingroup TestsuitesValidation0
0069  *
0070  * @brief Tests the rtems_event_send() and rtems_event_receive() directives.
0071  *
0072  * This test case performs the following actions:
0073  *
0074  * - Run the event send and receive tests for the application event set defined
0075  *   by spec:/rtems/event/req/send-receive.
0076  *
0077  * @{
0078  */
0079 
0080 static rtems_status_code EventSend(
0081   rtems_id        id,
0082   rtems_event_set event_in
0083 )
0084 {
0085   return rtems_event_send( id, event_in );
0086 }
0087 
0088 static rtems_status_code EventReceive(
0089   rtems_id         event_in,
0090   rtems_option     option_set,
0091   rtems_interval   ticks,
0092   rtems_event_set *event_out
0093 )
0094 {
0095   return rtems_event_receive( event_in, option_set, ticks, event_out );
0096 }
0097 
0098 static rtems_event_set GetPendingEvents( Thread_Control *thread )
0099 {
0100   RTEMS_API_Control *api;
0101 
0102   api = thread->API_Extensions[ THREAD_API_RTEMS ];
0103   return api->Event.pending_events;
0104 }
0105 
0106 /**
0107  * @brief Run the event send and receive tests for the application event set
0108  *   defined by spec:/rtems/event/req/send-receive.
0109  */
0110 static void RtemsEventValSendReceive_Action_0( void )
0111 {
0112   RtemsEventReqSendReceive_Run(
0113     EventSend,
0114     EventReceive,
0115     GetPendingEvents,
0116     THREAD_WAIT_CLASS_EVENT,
0117     STATES_WAITING_FOR_EVENT
0118   );
0119 }
0120 
0121 /**
0122  * @fn void T_case_body_RtemsEventValSendReceive( void )
0123  */
0124 T_TEST_CASE( RtemsEventValSendReceive )
0125 {
0126   RtemsEventValSendReceive_Action_0();
0127 }
0128 
0129 /** @} */
0130 
0131 /**
0132  * @defgroup RtemsEventValSystemSendReceive \
0133  *   spec:/rtems/event/val/system-send-receive
0134  *
0135  * @ingroup TestsuitesValidation0
0136  *
0137  * @brief Tests the rtems_event_system_send() and rtems_event_system_receive()
0138  *   directives.
0139  *
0140  * This test case performs the following actions:
0141  *
0142  * - Run the event send and receive tests for the system event set defined by
0143  *   spec:/rtems/event/req/send-receive.
0144  *
0145  * @{
0146  */
0147 
0148 static rtems_status_code EventSystemSend(
0149   rtems_id        id,
0150   rtems_event_set event_in
0151 )
0152 {
0153   return rtems_event_system_send( id, event_in );
0154 }
0155 
0156 static rtems_status_code EventSystemReceive(
0157   rtems_id         event_in,
0158   rtems_option     option_set,
0159   rtems_interval   ticks,
0160   rtems_event_set *event_out
0161 )
0162 {
0163   return rtems_event_system_receive(
0164     event_in,
0165     option_set,
0166     ticks,
0167     event_out
0168   );
0169 }
0170 
0171 static rtems_event_set GetPendingSystemEvents( Thread_Control *thread )
0172 {
0173   RTEMS_API_Control *api;
0174 
0175   api = thread->API_Extensions[ THREAD_API_RTEMS ];
0176   return api->System_event.pending_events;
0177 }
0178 
0179 /**
0180  * @brief Run the event send and receive tests for the system event set defined
0181  *   by spec:/rtems/event/req/send-receive.
0182  */
0183 static void RtemsEventValSystemSendReceive_Action_0( void )
0184 {
0185   RtemsEventReqSendReceive_Run(
0186     EventSystemSend,
0187     EventSystemReceive,
0188     GetPendingSystemEvents,
0189     THREAD_WAIT_CLASS_SYSTEM_EVENT,
0190     STATES_WAITING_FOR_SYSTEM_EVENT
0191   );
0192 }
0193 
0194 /**
0195  * @fn void T_case_body_RtemsEventValSystemSendReceive( void )
0196  */
0197 T_TEST_CASE( RtemsEventValSystemSendReceive )
0198 {
0199   RtemsEventValSystemSendReceive_Action_0();
0200 }
0201 
0202 /** @} */