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 AcfgValDefault
0007  */
0008 
0009 /*
0010  * Copyright (C) 2021 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 <bsp.h>
0056 #include <string.h>
0057 #include <rtems/score/userextdata.h>
0058 
0059 #include "tx-support.h"
0060 
0061 #include <rtems/test.h>
0062 
0063 /**
0064  * @defgroup AcfgValDefault spec:/acfg/val/default
0065  *
0066  * @ingroup TestsuitesValidationAcfg0
0067  *
0068  * @brief Tests the default values of application configuration options.
0069  *
0070  * This test case performs the following actions:
0071  *
0072  * - Check the effect of application configuration options with optional
0073  *   BSP-provided settings.
0074  *
0075  *   - Check the configured CONFIGURE_IDLE_TASK_BODY.
0076  *
0077  *   - Check the default value of CONFIGURE_IDLE_TASK_STACK_SIZE where the
0078  *     optional BSP-provided default value is enabled.
0079  *
0080  *   - Check the default value of CONFIGURE_INTERRUPT_STACK_SIZE where the
0081  *     optional BSP-provided default value is enabled.
0082  *
0083  *   - Check the BSP-provided initial extension is registered.
0084  *
0085  * - Try to create a barrier.
0086  *
0087  *   - Check that the returned status code is RTEMS_TOO_MANY.
0088  *
0089  * - Try to construct a message queue.
0090  *
0091  *   - Check that the returned status code is RTEMS_TOO_MANY.
0092  *
0093  * - Try to create a partition.
0094  *
0095  *   - Check that the returned status code is RTEMS_TOO_MANY.
0096  *
0097  * - Try to create a period.
0098  *
0099  *   - Check that the returned status code is RTEMS_TOO_MANY.
0100  *
0101  * - Check that the processor maximum is one.
0102  *
0103  * - Try to create a semaphore.
0104  *
0105  *   - Check that the returned status code is RTEMS_TOO_MANY.
0106  *
0107  * - Try to construct a task.
0108  *
0109  *   - Check that the returned status code is RTEMS_TOO_MANY.
0110  *
0111  *   - Check the default CONFIGURE_MAXIMUM_TASKS value.  A maximum Classic API
0112  *     task value of zero is only configurable if
0113  *     CONFIGURE_IDLE_TASK_INITIALIZES_APPLICATION is defined or
0114  *     CONFIGURE_MAXIMUM_POSIX_THREADS is set to a positive value.  The default
0115  *     value of zero for CONFIGURE_MAXIMUM_POSIX_THREADS is used by the test
0116  *     suite containing the test case.  The test suite defines
0117  *     CONFIGURE_IDLE_TASK_INITIALIZES_APPLICATION.
0118  *
0119  * - Try to create a timer.
0120  *
0121  *   - Check that the returned status code is RTEMS_TOO_MANY.
0122  *
0123  * - Try to create a user extension set.
0124  *
0125  *   - Check that the returned status code is RTEMS_TOO_MANY.
0126  *
0127  * @{
0128  */
0129 
0130 #define NAME rtems_build_name( 'N', 'A', 'M', 'E' )
0131 
0132 RTEMS_ALIGNED(RTEMS_TASK_STORAGE_ALIGNMENT) static char task_storage[
0133   RTEMS_TASK_STORAGE_SIZE(
0134     RTEMS_MINIMUM_STACK_SIZE,
0135     RTEMS_DEFAULT_ATTRIBUTES
0136   )
0137 ];
0138 
0139 static const rtems_task_config task_config = {
0140   .name = NAME,
0141   .initial_priority = 1,
0142   .storage_area = task_storage,
0143   .storage_size = sizeof( task_storage ),
0144   .maximum_thread_local_storage_size = 0,
0145   .initial_modes = RTEMS_DEFAULT_MODES,
0146   .attributes = RTEMS_DEFAULT_ATTRIBUTES
0147 };
0148 
0149 /**
0150  * @brief Check the effect of application configuration options with optional
0151  *   BSP-provided settings.
0152  */
0153 static void AcfgValDefault_Action_0( void )
0154 {
0155   rtems_extensions_table bsp = BSP_INITIAL_EXTENSION;
0156 
0157   /*
0158    * Check the configured CONFIGURE_IDLE_TASK_BODY.
0159    */
0160   T_step_eq_ptr( 0, rtems_configuration_get_idle_task(), IdleBody );
0161 
0162   /*
0163    * Check the default value of CONFIGURE_IDLE_TASK_STACK_SIZE where the
0164    * optional BSP-provided default value is enabled.
0165    */
0166   T_step_eq_sz(
0167     1,
0168     rtems_configuration_get_idle_task_stack_size(),
0169   #if defined(BSP_IDLE_TASK_STACK_SIZE)
0170     BSP_IDLE_TASK_STACK_SIZE
0171   #else
0172     CPU_STACK_MINIMUM_SIZE
0173   #endif
0174   );
0175 
0176   /*
0177    * Check the default value of CONFIGURE_INTERRUPT_STACK_SIZE where the
0178    * optional BSP-provided default value is enabled.
0179    */
0180   T_step_eq_sz(
0181     2,
0182     rtems_configuration_get_interrupt_stack_size(),
0183   #if defined(BSP_INTERRUPT_STACK_SIZE)
0184     BSP_INTERRUPT_STACK_SIZE
0185   #else
0186     CPU_STACK_MINIMUM_SIZE
0187   #endif
0188   );
0189 
0190   /*
0191    * Check the BSP-provided initial extension is registered.
0192    */
0193   T_step_eq_sz( 3, _User_extensions_Initial_count, 1 );
0194   T_step_eq_ptr(
0195     4,
0196     _User_extensions_Initial_extensions[ 0 ].fatal,
0197     bsp.fatal
0198   );
0199 }
0200 
0201 /**
0202  * @brief Try to create a barrier.
0203  */
0204 static void AcfgValDefault_Action_1( void )
0205 {
0206   rtems_status_code sc;
0207   rtems_id          id;
0208 
0209   sc = rtems_barrier_create(
0210     NAME,
0211     RTEMS_DEFAULT_ATTRIBUTES,
0212     1,
0213     &id
0214   );
0215 
0216   /*
0217    * Check that the returned status code is RTEMS_TOO_MANY.
0218    */
0219   T_step_rsc( 5, sc, RTEMS_TOO_MANY );
0220 }
0221 
0222 /**
0223  * @brief Try to construct a message queue.
0224  */
0225 static void AcfgValDefault_Action_2( void )
0226 {
0227   rtems_message_queue_config      config;
0228   RTEMS_MESSAGE_QUEUE_BUFFER( 1 ) buffers[ 1 ];
0229   rtems_status_code               sc;
0230   rtems_id                        id;
0231 
0232   memset( &config, 0, sizeof( config ) );
0233   config.name = NAME;
0234   config.maximum_pending_messages = 1;
0235   config.maximum_message_size = 1;
0236   config.storage_size = sizeof( buffers );
0237   config.storage_area = buffers;
0238   config.attributes = RTEMS_DEFAULT_ATTRIBUTES;
0239 
0240   sc = rtems_message_queue_construct( &config, &id );
0241 
0242   /*
0243    * Check that the returned status code is RTEMS_TOO_MANY.
0244    */
0245   T_step_rsc( 6, sc, RTEMS_TOO_MANY );
0246 }
0247 
0248 /**
0249  * @brief Try to create a partition.
0250  */
0251 static void AcfgValDefault_Action_3( void )
0252 {
0253   RTEMS_ALIGNED( RTEMS_PARTITION_ALIGNMENT ) uint8_t buffers[ 1 ][ 32 ];
0254   rtems_status_code                                  sc;
0255   rtems_id                                           id;
0256 
0257   sc = rtems_partition_create(
0258     NAME,
0259     buffers,
0260     sizeof( buffers ),
0261     sizeof( buffers[ 0 ] ),
0262     RTEMS_DEFAULT_ATTRIBUTES,
0263     &id
0264   );
0265 
0266   /*
0267    * Check that the returned status code is RTEMS_TOO_MANY.
0268    */
0269   T_step_rsc( 7, sc, RTEMS_TOO_MANY );
0270 }
0271 
0272 /**
0273  * @brief Try to create a period.
0274  */
0275 static void AcfgValDefault_Action_4( void )
0276 {
0277   rtems_status_code sc;
0278   rtems_id          id;
0279 
0280   sc = rtems_rate_monotonic_create( NAME, &id );
0281 
0282   /*
0283    * Check that the returned status code is RTEMS_TOO_MANY.
0284    */
0285   T_step_rsc( 8, sc, RTEMS_TOO_MANY );
0286 }
0287 
0288 /**
0289  * @brief Check that the processor maximum is one.
0290  */
0291 static void AcfgValDefault_Action_5( void )
0292 {
0293   T_step_eq_u32( 9, rtems_scheduler_get_processor_maximum(), 1 );
0294 }
0295 
0296 /**
0297  * @brief Try to create a semaphore.
0298  */
0299 static void AcfgValDefault_Action_6( void )
0300 {
0301   rtems_status_code sc;
0302   rtems_id          id;
0303 
0304   sc = rtems_semaphore_create(
0305     NAME,
0306     0,
0307     RTEMS_DEFAULT_ATTRIBUTES,
0308     0,
0309     &id
0310   );
0311 
0312   /*
0313    * Check that the returned status code is RTEMS_TOO_MANY.
0314    */
0315   T_step_rsc( 10, sc, RTEMS_TOO_MANY );
0316 }
0317 
0318 /**
0319  * @brief Try to construct a task.
0320  */
0321 static void AcfgValDefault_Action_7( void )
0322 {
0323   rtems_status_code sc;
0324   rtems_id          id;
0325 
0326   sc = rtems_task_construct( &task_config, &id );
0327 
0328   /*
0329    * Check that the returned status code is RTEMS_TOO_MANY.
0330    */
0331   T_step_rsc( 11, sc, RTEMS_TOO_MANY );
0332 
0333   /*
0334    * Check the default CONFIGURE_MAXIMUM_TASKS value.  A maximum Classic API
0335    * task value of zero is only configurable if
0336    * CONFIGURE_IDLE_TASK_INITIALIZES_APPLICATION is defined or
0337    * CONFIGURE_MAXIMUM_POSIX_THREADS is set to a positive value.  The default
0338    * value of zero for CONFIGURE_MAXIMUM_POSIX_THREADS is used by the test
0339    * suite containing the test case.  The test suite defines
0340    * CONFIGURE_IDLE_TASK_INITIALIZES_APPLICATION.
0341    */
0342   T_step_eq_u32( 12, rtems_configuration_get_maximum_tasks(), 0 );
0343 }
0344 
0345 /**
0346  * @brief Try to create a timer.
0347  */
0348 static void AcfgValDefault_Action_8( void )
0349 {
0350   rtems_status_code sc;
0351   rtems_id          id;
0352 
0353   sc = rtems_timer_create( NAME, &id );
0354 
0355   /*
0356    * Check that the returned status code is RTEMS_TOO_MANY.
0357    */
0358   T_step_rsc( 13, sc, RTEMS_TOO_MANY );
0359 }
0360 
0361 /**
0362  * @brief Try to create a user extension set.
0363  */
0364 static void AcfgValDefault_Action_9( void )
0365 {
0366   rtems_extensions_table table;
0367   rtems_status_code      sc;
0368   rtems_id               id;
0369 
0370   memset( &table, 0, sizeof( table ) );
0371   sc = rtems_extension_create( NAME, &table, &id );
0372 
0373   /*
0374    * Check that the returned status code is RTEMS_TOO_MANY.
0375    */
0376   T_step_rsc( 14, sc, RTEMS_TOO_MANY );
0377 }
0378 
0379 /**
0380  * @fn void T_case_body_AcfgValDefault( void )
0381  */
0382 T_TEST_CASE( AcfgValDefault )
0383 {
0384   T_plan( 15 );
0385 
0386   AcfgValDefault_Action_0();
0387   AcfgValDefault_Action_1();
0388   AcfgValDefault_Action_2();
0389   AcfgValDefault_Action_3();
0390   AcfgValDefault_Action_4();
0391   AcfgValDefault_Action_5();
0392   AcfgValDefault_Action_6();
0393   AcfgValDefault_Action_7();
0394   AcfgValDefault_Action_8();
0395   AcfgValDefault_Action_9();
0396 }
0397 
0398 /** @} */