Back to home page

LXR

 
 

    


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

0001 /* SPDX-License-Identifier: BSD-2-Clause */
0002 
0003 /**
0004  * @file
0005  *
0006  * @ingroup RtemsEventValEventConstant
0007  */
0008 
0009 /*
0010  * Copyright (C) 2020 embedded brains GmbH & Co. KG
0011  *
0012  * Redistribution and use in source and binary forms, with or without
0013  * modification, are permitted provided that the following conditions
0014  * are met:
0015  * 1. Redistributions of source code must retain the above copyright
0016  *    notice, this list of conditions and the following disclaimer.
0017  * 2. Redistributions in binary form must reproduce the above copyright
0018  *    notice, this list of conditions and the following disclaimer in the
0019  *    documentation and/or other materials provided with the distribution.
0020  *
0021  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
0022  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
0023  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
0024  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
0025  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
0026  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
0027  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
0028  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
0029  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
0030  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
0031  * POSSIBILITY OF SUCH DAMAGE.
0032  */
0033 
0034 /*
0035  * This file is part of the RTEMS quality process and was automatically
0036  * generated.  If you find something that needs to be fixed or
0037  * worded better please post a report or patch to an RTEMS mailing list
0038  * or raise a bug report:
0039  *
0040  * https://www.rtems.org/bugs.html
0041  *
0042  * For information on updating and regenerating please refer to the How-To
0043  * section in the Software Requirements Engineering chapter of the
0044  * RTEMS Software Engineering manual.  The manual is provided as a part of
0045  * a release.  For development sources please refer to the online
0046  * documentation at:
0047  *
0048  * https://docs.rtems.org
0049  */
0050 
0051 #ifdef HAVE_CONFIG_H
0052 #include "config.h"
0053 #endif
0054 
0055 #include <rtems.h>
0056 
0057 #include "tr-event-constant.h"
0058 
0059 #include <rtems/test.h>
0060 
0061 /**
0062  * @defgroup RtemsEventValEventConstant spec:/rtems/event/val/event-constant
0063  *
0064  * @ingroup TestsuitesValidationNoClock0
0065  *
0066  * @brief Tests an event constant and number of the Event Manager using the
0067  *   Classic and system event sets of the executing task.
0068  *
0069  * This test case performs the following actions:
0070  *
0071  * - Validate the event constant.
0072  *
0073  *   - Check that the event constant is equal to the event number bit in the
0074  *     event set.
0075  *
0076  *   - Check that the event number bit of the event constant is not set in
0077  *     RTEMS_PENDING_EVENTS.
0078  *
0079  * - Get all pending events of the Classic event set of the executing task.
0080  *
0081  *   - Check that the directive call was successful.
0082  *
0083  *   - Check that there were no pending events.
0084  *
0085  * - Get all pending events of the system event set of the executing task.
0086  *
0087  *   - Check that the directive call was successful.
0088  *
0089  *   - Check that there were no pending events.
0090  *
0091  * - Receive all pending events of the Classic event set of the executing task.
0092  *
0093  *   - Check that the directive call was unsatisfied.
0094  *
0095  *   - Check that there were no events received.
0096  *
0097  * - Receive all pending events of the system event set of the executing task.
0098  *
0099  *   - Check that the directive call was unsatisfied.
0100  *
0101  *   - Check that there were no events received.
0102  *
0103  * - Send the event to the Classic event set of the executing task.
0104  *
0105  *   - Check that the directive call was successful.
0106  *
0107  * - Get all pending events of the Classic event set of the executing task.
0108  *
0109  *   - Check that the directive call was successful.
0110  *
0111  *   - Check that the pending event is equal to the event sent by a previous
0112  *     action.
0113  *
0114  * - Get all pending events of the system event set of the executing task.
0115  *
0116  *   - Check that the directive call was successful.
0117  *
0118  *   - Check that there were no pending events.
0119  *
0120  * - Receive any event of the Classic event set of the executing task.
0121  *
0122  *   - Check that the directive call was successful.
0123  *
0124  *   - Check that the received event is equal to the event sent by a previous
0125  *     action.
0126  *
0127  * - Receive any event of the system event set of the executing task.
0128  *
0129  *   - Check that the directive call was unsatisfied.
0130  *
0131  *   - Check that the no events were received.
0132  *
0133  * - Send the event to the Classic event set of the executing task.
0134  *
0135  *   - Check that the directive call was successful.
0136  *
0137  * - Get all pending events of the Classic event set of the executing task.
0138  *
0139  *   - Check that the directive call was successful.
0140  *
0141  *   - Check that there were no pending events.
0142  *
0143  * - Get all pending events of the system event set of the executing task.
0144  *
0145  *   - Check that the directive call was successful.
0146  *
0147  *   - Check that the pending event is equal to the event sent by a previous
0148  *     action.
0149  *
0150  * - Receive any event of the Classic event set of the executing task.
0151  *
0152  *   - Check that the directive call was unsatisfied.
0153  *
0154  *   - Check that the no events were received.
0155  *
0156  * - Receive any event of the system event set of the executing task.
0157  *
0158  *   - Check that the directive call was successful.
0159  *
0160  *   - Check that the received event is equal to the event sent by a previous
0161  *     action.
0162  *
0163  * - Get all pending events of the Classic event set of the executing task.
0164  *
0165  *   - Check that the directive call was successful.
0166  *
0167  *   - Check that there were no pending events.
0168  *
0169  * - Get all pending events of the system event set of the executing task.
0170  *
0171  *   - Check that the directive call was successful.
0172  *
0173  *   - Check that there were no pending events.
0174  *
0175  * @{
0176  */
0177 
0178 /**
0179  * @brief Test context for spec:/rtems/event/val/event-constant test case.
0180  */
0181 typedef struct {
0182   /**
0183    * @brief This member contains a copy of the corresponding
0184    *   RtemsEventValEventConstant_Run() parameter.
0185    */
0186   rtems_event_set event;
0187 
0188   /**
0189    * @brief This member contains a copy of the corresponding
0190    *   RtemsEventValEventConstant_Run() parameter.
0191    */
0192   int number;
0193 } RtemsEventValEventConstant_Context;
0194 
0195 static RtemsEventValEventConstant_Context
0196   RtemsEventValEventConstant_Instance;
0197 
0198 static T_fixture RtemsEventValEventConstant_Fixture = {
0199   .setup = NULL,
0200   .stop = NULL,
0201   .teardown = NULL,
0202   .scope = NULL,
0203   .initial_context = &RtemsEventValEventConstant_Instance
0204 };
0205 
0206 /**
0207  * @brief Validate the event constant.
0208  */
0209 static void RtemsEventValEventConstant_Action_0(
0210   RtemsEventValEventConstant_Context *ctx
0211 )
0212 {
0213   /* No action */
0214 
0215   /*
0216    * Check that the event constant is equal to the event number bit in the
0217    * event set.
0218    */
0219   T_step_eq_u32(
0220     0,
0221     ctx->event,
0222     ( (rtems_event_set) 1 ) << ctx->number
0223   );
0224 
0225   /*
0226    * Check that the event number bit of the event constant is not set in
0227    * RTEMS_PENDING_EVENTS.
0228    */
0229   T_step_eq_u32( 1, ctx->event & RTEMS_PENDING_EVENTS, 0 );
0230 }
0231 
0232 /**
0233  * @brief Get all pending events of the Classic event set of the executing
0234  *   task.
0235  */
0236 static void RtemsEventValEventConstant_Action_1(
0237   RtemsEventValEventConstant_Context *ctx
0238 )
0239 {
0240   rtems_status_code sc;
0241   rtems_event_set   out;
0242 
0243   out = RTEMS_ALL_EVENTS;
0244   sc = rtems_event_receive(
0245     RTEMS_PENDING_EVENTS,
0246     RTEMS_DEFAULT_OPTIONS,
0247     0,
0248     &out
0249   );
0250 
0251   /*
0252    * Check that the directive call was successful.
0253    */
0254   T_step_rsc_success( 2, sc );
0255 
0256   /*
0257    * Check that there were no pending events.
0258    */
0259   T_step_eq_u32( 3, out, 0 );
0260 }
0261 
0262 /**
0263  * @brief Get all pending events of the system event set of the executing task.
0264  */
0265 static void RtemsEventValEventConstant_Action_2(
0266   RtemsEventValEventConstant_Context *ctx
0267 )
0268 {
0269   rtems_status_code sc;
0270   rtems_event_set   out;
0271 
0272   out = RTEMS_ALL_EVENTS;
0273   sc = rtems_event_system_receive(
0274     RTEMS_PENDING_EVENTS,
0275     RTEMS_DEFAULT_OPTIONS,
0276     0,
0277     &out
0278   );
0279 
0280   /*
0281    * Check that the directive call was successful.
0282    */
0283   T_step_rsc_success( 4, sc );
0284 
0285   /*
0286    * Check that there were no pending events.
0287    */
0288   T_step_eq_u32( 5, out, 0 );
0289 }
0290 
0291 /**
0292  * @brief Receive all pending events of the Classic event set of the executing
0293  *   task.
0294  */
0295 static void RtemsEventValEventConstant_Action_3(
0296   RtemsEventValEventConstant_Context *ctx
0297 )
0298 {
0299   rtems_status_code sc;
0300   rtems_event_set   out;
0301 
0302   out = RTEMS_ALL_EVENTS;
0303   sc = rtems_event_receive(
0304     RTEMS_ALL_EVENTS,
0305     RTEMS_NO_WAIT | RTEMS_EVENT_ANY,
0306     0,
0307     &out
0308   );
0309 
0310   /*
0311    * Check that the directive call was unsatisfied.
0312    */
0313   T_step_rsc( 6, sc, RTEMS_UNSATISFIED );
0314 
0315   /*
0316    * Check that there were no events received.
0317    */
0318   T_step_eq_u32( 7, out, 0 );
0319 }
0320 
0321 /**
0322  * @brief Receive all pending events of the system event set of the executing
0323  *   task.
0324  */
0325 static void RtemsEventValEventConstant_Action_4(
0326   RtemsEventValEventConstant_Context *ctx
0327 )
0328 {
0329   rtems_status_code sc;
0330   rtems_event_set   out;
0331 
0332   out = RTEMS_ALL_EVENTS;
0333   sc = rtems_event_system_receive(
0334     RTEMS_ALL_EVENTS,
0335     RTEMS_NO_WAIT | RTEMS_EVENT_ANY,
0336     0,
0337     &out
0338   );
0339 
0340   /*
0341    * Check that the directive call was unsatisfied.
0342    */
0343   T_step_rsc( 8, sc, RTEMS_UNSATISFIED );
0344 
0345   /*
0346    * Check that there were no events received.
0347    */
0348   T_step_eq_u32( 9, out, 0 );
0349 }
0350 
0351 /**
0352  * @brief Send the event to the Classic event set of the executing task.
0353  */
0354 static void RtemsEventValEventConstant_Action_5(
0355   RtemsEventValEventConstant_Context *ctx
0356 )
0357 {
0358   rtems_status_code sc;
0359 
0360   sc = rtems_event_send( RTEMS_SELF, ctx->event );
0361 
0362   /*
0363    * Check that the directive call was successful.
0364    */
0365   T_step_rsc_success( 10, sc );
0366 }
0367 
0368 /**
0369  * @brief Get all pending events of the Classic event set of the executing
0370  *   task.
0371  */
0372 static void RtemsEventValEventConstant_Action_6(
0373   RtemsEventValEventConstant_Context *ctx
0374 )
0375 {
0376   rtems_status_code sc;
0377   rtems_event_set   out;
0378 
0379   out = RTEMS_ALL_EVENTS;
0380   sc = rtems_event_receive(
0381     RTEMS_PENDING_EVENTS,
0382     RTEMS_DEFAULT_OPTIONS,
0383     0,
0384     &out
0385   );
0386 
0387   /*
0388    * Check that the directive call was successful.
0389    */
0390   T_step_rsc_success( 11, sc );
0391 
0392   /*
0393    * Check that the pending event is equal to the event sent by a previous
0394    * action.
0395    */
0396   T_step_eq_u32( 12, out, ctx->event );
0397 }
0398 
0399 /**
0400  * @brief Get all pending events of the system event set of the executing task.
0401  */
0402 static void RtemsEventValEventConstant_Action_7(
0403   RtemsEventValEventConstant_Context *ctx
0404 )
0405 {
0406   rtems_status_code sc;
0407   rtems_event_set   out;
0408 
0409   out = RTEMS_ALL_EVENTS;
0410   sc = rtems_event_system_receive(
0411     RTEMS_PENDING_EVENTS,
0412     RTEMS_DEFAULT_OPTIONS,
0413     0,
0414     &out
0415   );
0416 
0417   /*
0418    * Check that the directive call was successful.
0419    */
0420   T_step_rsc_success( 13, sc );
0421 
0422   /*
0423    * Check that there were no pending events.
0424    */
0425   T_step_eq_u32( 14, out, 0 );
0426 }
0427 
0428 /**
0429  * @brief Receive any event of the Classic event set of the executing task.
0430  */
0431 static void RtemsEventValEventConstant_Action_8(
0432   RtemsEventValEventConstant_Context *ctx
0433 )
0434 {
0435   rtems_status_code sc;
0436   rtems_event_set   out;
0437 
0438   out = 0;
0439   sc = rtems_event_receive(
0440     RTEMS_ALL_EVENTS,
0441     RTEMS_NO_WAIT | RTEMS_EVENT_ANY,
0442     0,
0443     &out
0444   );
0445 
0446   /*
0447    * Check that the directive call was successful.
0448    */
0449   T_step_rsc_success( 15, sc );
0450 
0451   /*
0452    * Check that the received event is equal to the event sent by a previous
0453    * action.
0454    */
0455   T_step_eq_u32( 16, out, ctx->event );
0456 }
0457 
0458 /**
0459  * @brief Receive any event of the system event set of the executing task.
0460  */
0461 static void RtemsEventValEventConstant_Action_9(
0462   RtemsEventValEventConstant_Context *ctx
0463 )
0464 {
0465   rtems_status_code sc;
0466   rtems_event_set   out;
0467 
0468   out = RTEMS_ALL_EVENTS;
0469   sc = rtems_event_system_receive(
0470     RTEMS_ALL_EVENTS,
0471     RTEMS_NO_WAIT | RTEMS_EVENT_ANY,
0472     0,
0473     &out
0474   );
0475 
0476   /*
0477    * Check that the directive call was unsatisfied.
0478    */
0479   T_step_rsc( 17, sc, RTEMS_UNSATISFIED );
0480 
0481   /*
0482    * Check that the no events were received.
0483    */
0484   T_step_eq_u32( 18, out, 0 );
0485 }
0486 
0487 /**
0488  * @brief Send the event to the Classic event set of the executing task.
0489  */
0490 static void RtemsEventValEventConstant_Action_10(
0491   RtemsEventValEventConstant_Context *ctx
0492 )
0493 {
0494   rtems_status_code sc;
0495 
0496   sc = rtems_event_system_send( RTEMS_SELF, ctx->event );
0497 
0498   /*
0499    * Check that the directive call was successful.
0500    */
0501   T_step_rsc_success( 19, sc );
0502 }
0503 
0504 /**
0505  * @brief Get all pending events of the Classic event set of the executing
0506  *   task.
0507  */
0508 static void RtemsEventValEventConstant_Action_11(
0509   RtemsEventValEventConstant_Context *ctx
0510 )
0511 {
0512   rtems_status_code sc;
0513   rtems_event_set   out;
0514 
0515   out = RTEMS_ALL_EVENTS;
0516   sc = rtems_event_receive(
0517     RTEMS_PENDING_EVENTS,
0518     RTEMS_DEFAULT_OPTIONS,
0519     0,
0520     &out
0521   );
0522 
0523   /*
0524    * Check that the directive call was successful.
0525    */
0526   T_step_rsc_success( 20, sc );
0527 
0528   /*
0529    * Check that there were no pending events.
0530    */
0531   T_step_eq_u32( 21, out, 0 );
0532 }
0533 
0534 /**
0535  * @brief Get all pending events of the system event set of the executing task.
0536  */
0537 static void RtemsEventValEventConstant_Action_12(
0538   RtemsEventValEventConstant_Context *ctx
0539 )
0540 {
0541   rtems_status_code sc;
0542   rtems_event_set   out;
0543 
0544   out = RTEMS_ALL_EVENTS;
0545   sc = rtems_event_system_receive(
0546     RTEMS_PENDING_EVENTS,
0547     RTEMS_DEFAULT_OPTIONS,
0548     0,
0549     &out
0550   );
0551 
0552   /*
0553    * Check that the directive call was successful.
0554    */
0555   T_step_rsc_success( 22, sc );
0556 
0557   /*
0558    * Check that the pending event is equal to the event sent by a previous
0559    * action.
0560    */
0561   T_step_eq_u32( 23, out, ctx->event );
0562 }
0563 
0564 /**
0565  * @brief Receive any event of the Classic event set of the executing task.
0566  */
0567 static void RtemsEventValEventConstant_Action_13(
0568   RtemsEventValEventConstant_Context *ctx
0569 )
0570 {
0571   rtems_status_code sc;
0572   rtems_event_set   out;
0573 
0574   out = RTEMS_ALL_EVENTS;
0575   sc = rtems_event_receive(
0576     RTEMS_ALL_EVENTS,
0577     RTEMS_NO_WAIT | RTEMS_EVENT_ANY,
0578     0,
0579     &out
0580   );
0581 
0582   /*
0583    * Check that the directive call was unsatisfied.
0584    */
0585   T_step_rsc( 24, sc, RTEMS_UNSATISFIED );
0586 
0587   /*
0588    * Check that the no events were received.
0589    */
0590   T_step_eq_u32( 25, out, 0 );
0591 }
0592 
0593 /**
0594  * @brief Receive any event of the system event set of the executing task.
0595  */
0596 static void RtemsEventValEventConstant_Action_14(
0597   RtemsEventValEventConstant_Context *ctx
0598 )
0599 {
0600   rtems_status_code sc;
0601   rtems_event_set   out;
0602 
0603   out = 0;
0604   sc = rtems_event_system_receive(
0605     RTEMS_ALL_EVENTS,
0606     RTEMS_NO_WAIT | RTEMS_EVENT_ANY,
0607     0,
0608     &out
0609   );
0610 
0611   /*
0612    * Check that the directive call was successful.
0613    */
0614   T_step_rsc_success( 26, sc );
0615 
0616   /*
0617    * Check that the received event is equal to the event sent by a previous
0618    * action.
0619    */
0620   T_step_eq_u32( 27, out, ctx->event );
0621 }
0622 
0623 /**
0624  * @brief Get all pending events of the Classic event set of the executing
0625  *   task.
0626  */
0627 static void RtemsEventValEventConstant_Action_15(
0628   RtemsEventValEventConstant_Context *ctx
0629 )
0630 {
0631   rtems_status_code sc;
0632   rtems_event_set   out;
0633 
0634   out = RTEMS_ALL_EVENTS;
0635   sc = rtems_event_receive(
0636     RTEMS_PENDING_EVENTS,
0637     RTEMS_DEFAULT_OPTIONS,
0638     0,
0639     &out
0640   );
0641 
0642   /*
0643    * Check that the directive call was successful.
0644    */
0645   T_step_rsc_success( 28, sc );
0646 
0647   /*
0648    * Check that there were no pending events.
0649    */
0650   T_step_eq_u32( 29, out, 0 );
0651 }
0652 
0653 /**
0654  * @brief Get all pending events of the system event set of the executing task.
0655  */
0656 static void RtemsEventValEventConstant_Action_16(
0657   RtemsEventValEventConstant_Context *ctx
0658 )
0659 {
0660   rtems_status_code sc;
0661   rtems_event_set   out;
0662 
0663   out = RTEMS_ALL_EVENTS;
0664   sc = rtems_event_system_receive(
0665     RTEMS_PENDING_EVENTS,
0666     RTEMS_DEFAULT_OPTIONS,
0667     0,
0668     &out
0669   );
0670 
0671   /*
0672    * Check that the directive call was successful.
0673    */
0674   T_step_rsc_success( 30, sc );
0675 
0676   /*
0677    * Check that there were no pending events.
0678    */
0679   T_step_eq_u32( 31, out, 0 );
0680 }
0681 
0682 static T_fixture_node RtemsEventValEventConstant_Node;
0683 
0684 static T_remark RtemsEventValEventConstant_Remark = {
0685   .next = NULL,
0686   .remark = "RtemsEventValEventConstant"
0687 };
0688 
0689 void RtemsEventValEventConstant_Run( rtems_event_set event, int number )
0690 {
0691   RtemsEventValEventConstant_Context *ctx;
0692 
0693   ctx = &RtemsEventValEventConstant_Instance;
0694   ctx->event = event;
0695   ctx->number = number;
0696 
0697   ctx = T_push_fixture(
0698     &RtemsEventValEventConstant_Node,
0699     &RtemsEventValEventConstant_Fixture
0700   );
0701 
0702   T_plan( 32 );
0703 
0704   RtemsEventValEventConstant_Action_0( ctx );
0705   RtemsEventValEventConstant_Action_1( ctx );
0706   RtemsEventValEventConstant_Action_2( ctx );
0707   RtemsEventValEventConstant_Action_3( ctx );
0708   RtemsEventValEventConstant_Action_4( ctx );
0709   RtemsEventValEventConstant_Action_5( ctx );
0710   RtemsEventValEventConstant_Action_6( ctx );
0711   RtemsEventValEventConstant_Action_7( ctx );
0712   RtemsEventValEventConstant_Action_8( ctx );
0713   RtemsEventValEventConstant_Action_9( ctx );
0714   RtemsEventValEventConstant_Action_10( ctx );
0715   RtemsEventValEventConstant_Action_11( ctx );
0716   RtemsEventValEventConstant_Action_12( ctx );
0717   RtemsEventValEventConstant_Action_13( ctx );
0718   RtemsEventValEventConstant_Action_14( ctx );
0719   RtemsEventValEventConstant_Action_15( ctx );
0720   RtemsEventValEventConstant_Action_16( ctx );
0721 
0722   T_add_remark( &RtemsEventValEventConstant_Remark );
0723   T_pop_fixture();
0724 }
0725 
0726 /** @} */