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 AcfgValAcfg
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 <rtems/confdefs.h>
0057 #include <rtems/score/heap.h>
0058 
0059 #include "ts-config.h"
0060 #include "tx-support.h"
0061 
0062 #include <rtems/test.h>
0063 
0064 /**
0065  * @defgroup AcfgValAcfg spec:/acfg/val/acfg
0066  *
0067  * @ingroup TestsuitesValidationNoClock0
0068  *
0069  * @brief Tests the effect of application configuration options.
0070  *
0071  * This test case performs the following actions:
0072  *
0073  * - Check the effect of application configuration options.  In addition, this
0074  *   test case validates the effect of CONFIGURE_INIT.  The test case includes
0075  *   rtems/confdefs.h without defining CONFIGURE_INIT before the include.  If
0076  *   this header would define configuration data structures, then linking the
0077  *   test suite executable would result in multiple definition errors.  This
0078  *   header is included in the test suite runner translation unit while
0079  *   CONFIGURE_INIT is defined before the include.  If this would not result in
0080  *   the definition of application defined configuration data structures, then
0081  *   the checks below for non-default settings would fail.
0082  *
0083  *   - Check the default value CONFIGURE_IDLE_TASK_BODY where the optional
0084  *     BSP-provided default value is enabled.
0085  *
0086  *   - Check the configured CONFIGURE_INIT_TASK_ARGUMENTS.  This validates also
0087  *     the effect of CONFIGURE_INIT_TASK_ENTRY_POINT and
0088  *     CONFIGURE_RTEMS_INIT_TASKS_TABLE.
0089  *
0090  *   - Check the configured CONFIGURE_INIT_TASK_INITIAL_MODES.
0091  *
0092  *   - Check the configured CONFIGURE_INIT_TASK_NAME.
0093  *
0094  *   - Check the configured CONFIGURE_INIT_TASK_PRIORITY.  A priority of zero
0095  *     can only be set for system tasks.  This validates also
0096  *     CONFIGURE_INIT_TASK_ATTRIBUTES.
0097  *
0098  *   - Check that the configured
0099  *     CONFIGURE_MINIMUM_TASKS_WITH_USER_PROVIDED_STORAGE value reduced the
0100  *     stack space size.
0101  *
0102  *   - Check the configured CONFIGURE_MAXIMUM_BARRIERS value.
0103  *
0104  *   - Check the configured CONFIGURE_MAXIMUM_USER_EXTENSIONS value.
0105  *
0106  *   - Check the configured CONFIGURE_MAXIMUM_MESSAGE_QUEUES value.
0107  *
0108  *   - Check the configured CONFIGURE_MAXIMUM_PARTITIONS value.
0109  *
0110  *   - Check the configured CONFIGURE_MAXIMUM_PERIODS value.
0111  *
0112  *   - Check the default CONFIGURE_MAXIMUM_PORTS value.
0113  *
0114  *   - Check the configured CONFIGURE_MAXIMUM_PROCESSORS value.
0115  *
0116  *   - Check the default CONFIGURE_MAXIMUM_REGIONS value.
0117  *
0118  *   - Check the configured CONFIGURE_MAXIMUM_SEMAPHORES value.
0119  *
0120  *   - Check the configured CONFIGURE_MAXIMUM_TASKS value.
0121  *
0122  *   - Check the configured CONFIGURE_MAXIMUM_TIMERS value.
0123  *
0124  *   - Check the configured CONFIGURE_MICROSECONDS_PER_TICK value in
0125  *     microseconds.
0126  *
0127  *   - Check the configured CONFIGURE_MICROSECONDS_PER_TICK value in
0128  *     milliseconds.
0129  *
0130  *   - Check the configured CONFIGURE_MICROSECONDS_PER_TICK value in
0131  *     nanoseconds.
0132  *
0133  *   - Check the configured CONFIGURE_TASK_STACK_ALLOCATOR hook.  Using the
0134  *     test stack allocator validates also
0135  *     spec:/acfg/if/init-task-construct-storage-size, since the
0136  *     test_task_stack_allocate() allocate handler only supports
0137  *     CONFIGURE_MAXIMUM_TASKS minus one stacks and the validation test for
0138  *     spec:/rtems/task/req/create-errors creates for some pre-condition
0139  *     variants all tasks until RTEMS_TOO_MANY is returned.  In addition,
0140  *     test_task_stack_allocate() checks that the allocation size is greater
0141  *     than or equal to TEST_MINIMUM_STACK_SIZE which validates
0142  *     CONFIGURE_MINIMUM_TASK_STACK_SIZE.
0143  *
0144  *   - Check the configured CONFIGURE_TASK_STACK_ALLOCATOR_AVOIDS_WORK_SPACE
0145  *     value.
0146  *
0147  *   - Check the configured CONFIGURE_TASK_STACK_DEALLOCATOR hook.
0148  *
0149  *   - Check the configured CONFIGURE_TASK_STACK_ALLOCATOR_FOR_IDLE hook.
0150  *
0151  *   - Check the configured CONFIGURE_IDLE_TASK_STACK_SIZE value.
0152  *
0153  *   - Check the configured CONFIGURE_INTERRUPT_STACK_SIZE value.
0154  *
0155  *   - Check the configured CONFIGURE_TICKS_PER_TIMESLICE value.
0156  *
0157  * @{
0158  */
0159 
0160 /**
0161  * @brief Check the effect of application configuration options.  In addition,
0162  *   this test case validates the effect of CONFIGURE_INIT.  The test case
0163  *   includes rtems/confdefs.h without defining CONFIGURE_INIT before the
0164  *   include.  If this header would define configuration data structures, then
0165  *   linking the test suite executable would result in multiple definition
0166  *   errors.  This header is included in the test suite runner translation unit
0167  *   while CONFIGURE_INIT is defined before the include.  If this would not
0168  *   result in the definition of application defined configuration data
0169  *   structures, then the checks below for non-default settings would fail.
0170  */
0171 static void AcfgValAcfg_Action_0( void )
0172 {
0173   rtems_status_code sc;
0174   rtems_id          id;
0175 
0176   /*
0177    * Check the default value CONFIGURE_IDLE_TASK_BODY where the optional
0178    * BSP-provided default value is enabled.
0179    */
0180   T_eq_ptr(
0181     rtems_configuration_get_idle_task(),
0182   #if defined(BSP_IDLE_TASK_BODY)
0183     BSP_IDLE_TASK_BODY
0184   #else
0185     _CPU_Thread_Idle_body
0186   #endif
0187   );
0188 
0189   /*
0190    * Check the configured CONFIGURE_INIT_TASK_ARGUMENTS.  This validates also
0191    * the effect of CONFIGURE_INIT_TASK_ENTRY_POINT and
0192    * CONFIGURE_RTEMS_INIT_TASKS_TABLE.
0193    */
0194   T_eq_ulong( test_runner_argument, TEST_RUNNER_ARGUMENT );
0195 
0196   /*
0197    * Check the configured CONFIGURE_INIT_TASK_INITIAL_MODES.
0198    */
0199   T_eq_u32( test_runner_initial_modes, TEST_RUNNER_INITIAL_MODES );
0200 
0201   /*
0202    * Check the configured CONFIGURE_INIT_TASK_NAME.
0203    */
0204   sc = rtems_task_ident( TEST_RUNNER_NAME, RTEMS_SEARCH_LOCAL_NODE, &id );
0205   T_rsc_success( sc );
0206   T_eq_u32( id, rtems_task_self() );
0207 
0208   /*
0209    * Check the configured CONFIGURE_INIT_TASK_PRIORITY.  A priority of zero can
0210    * only be set for system tasks.  This validates also
0211    * CONFIGURE_INIT_TASK_ATTRIBUTES.
0212    */
0213   T_eq_u32( test_runner_initial_priority, 0 );
0214 
0215   /*
0216    * Check that the configured
0217    * CONFIGURE_MINIMUM_TASKS_WITH_USER_PROVIDED_STORAGE value reduced the stack
0218    * space size.
0219    */
0220   T_eq_uptr(
0221     _Stack_Space_size,
0222     RTEMS_ALIGN_UP( HEAP_BLOCK_HEADER_SIZE, CPU_HEAP_ALIGNMENT )
0223   );
0224 
0225   /*
0226    * Check the configured CONFIGURE_MAXIMUM_BARRIERS value.
0227    */
0228   T_eq_u32(
0229     rtems_configuration_get_maximum_barriers(),
0230     TEST_MAXIMUM_BARRIERS
0231   );
0232 
0233   /*
0234    * Check the configured CONFIGURE_MAXIMUM_USER_EXTENSIONS value.
0235    */
0236   T_eq_u32(
0237     rtems_configuration_get_maximum_extensions(),
0238     TEST_MAXIMUM_USER_EXTENSIONS
0239   );
0240 
0241   /*
0242    * Check the configured CONFIGURE_MAXIMUM_MESSAGE_QUEUES value.
0243    */
0244   T_eq_u32(
0245     rtems_configuration_get_maximum_message_queues(),
0246     TEST_MAXIMUM_MESSAGE_QUEUES
0247   );
0248 
0249   /*
0250    * Check the configured CONFIGURE_MAXIMUM_PARTITIONS value.
0251    */
0252   T_eq_u32(
0253     rtems_configuration_get_maximum_partitions(),
0254     TEST_MAXIMUM_PARTITIONS
0255   );
0256 
0257   /*
0258    * Check the configured CONFIGURE_MAXIMUM_PERIODS value.
0259    */
0260   T_eq_u32(
0261     rtems_configuration_get_maximum_periods(),
0262     TEST_MAXIMUM_PERIODS
0263   );
0264 
0265   /*
0266    * Check the default CONFIGURE_MAXIMUM_PORTS value.
0267    */
0268   T_eq_u32(
0269     rtems_configuration_get_maximum_ports(),
0270     0
0271   );
0272 
0273   /*
0274    * Check the configured CONFIGURE_MAXIMUM_PROCESSORS value.
0275    */
0276   T_eq_u32(
0277     rtems_configuration_get_maximum_processors(),
0278   #if defined(RTEMS_SMP)
0279     5
0280   #else
0281     1
0282   #endif
0283   );
0284 
0285   /*
0286    * Check the default CONFIGURE_MAXIMUM_REGIONS value.
0287    */
0288   T_eq_u32(
0289     rtems_configuration_get_maximum_regions(),
0290     0
0291   );
0292 
0293   /*
0294    * Check the configured CONFIGURE_MAXIMUM_SEMAPHORES value.
0295    */
0296   T_eq_u32(
0297     rtems_configuration_get_maximum_semaphores(),
0298     TEST_MAXIMUM_SEMAPHORES
0299   );
0300 
0301   /*
0302    * Check the configured CONFIGURE_MAXIMUM_TASKS value.
0303    */
0304   T_eq_u32(
0305     rtems_configuration_get_maximum_tasks(),
0306     TEST_MAXIMUM_TASKS
0307   );
0308 
0309   /*
0310    * Check the configured CONFIGURE_MAXIMUM_TIMERS value.
0311    */
0312   T_eq_u32(
0313     rtems_configuration_get_maximum_timers(),
0314     TEST_MAXIMUM_TIMERS
0315   );
0316 
0317   /*
0318    * Check the configured CONFIGURE_MICROSECONDS_PER_TICK value in
0319    * microseconds.
0320    */
0321   T_eq_u32(
0322     rtems_configuration_get_microseconds_per_tick(),
0323     TEST_MICROSECONDS_PER_TICK
0324   );
0325 
0326   /*
0327    * Check the configured CONFIGURE_MICROSECONDS_PER_TICK value in
0328    * milliseconds.
0329    */
0330   T_eq_u32(
0331     rtems_configuration_get_milliseconds_per_tick(),
0332     TEST_MICROSECONDS_PER_TICK / 1000
0333   );
0334 
0335   /*
0336    * Check the configured CONFIGURE_MICROSECONDS_PER_TICK value in nanoseconds.
0337    */
0338   T_eq_u32(
0339     rtems_configuration_get_nanoseconds_per_tick(),
0340     TEST_MICROSECONDS_PER_TICK * 1000
0341   );
0342 
0343   /*
0344    * Check the configured CONFIGURE_TASK_STACK_ALLOCATOR hook.  Using the test
0345    * stack allocator validates also
0346    * spec:/acfg/if/init-task-construct-storage-size, since the
0347    * test_task_stack_allocate() allocate handler only supports
0348    * CONFIGURE_MAXIMUM_TASKS minus one stacks and the validation test for
0349    * spec:/rtems/task/req/create-errors creates for some pre-condition variants
0350    * all tasks until RTEMS_TOO_MANY is returned.  In addition,
0351    * test_task_stack_allocate() checks that the allocation size is greater than
0352    * or equal to TEST_MINIMUM_STACK_SIZE which validates
0353    * CONFIGURE_MINIMUM_TASK_STACK_SIZE.
0354    */
0355   T_eq_ptr(
0356     rtems_configuration_get_stack_allocate_hook(),
0357     test_task_stack_allocate
0358   );
0359 
0360   /*
0361    * Check the configured CONFIGURE_TASK_STACK_ALLOCATOR_AVOIDS_WORK_SPACE
0362    * value.
0363    */
0364   T_true( rtems_configuration_get_stack_allocator_avoids_work_space() );
0365 
0366   /*
0367    * Check the configured CONFIGURE_TASK_STACK_DEALLOCATOR hook.
0368    */
0369   T_eq_ptr(
0370     rtems_configuration_get_stack_free_hook(),
0371     test_task_stack_deallocate
0372   );
0373 
0374   /*
0375    * Check the configured CONFIGURE_TASK_STACK_ALLOCATOR_FOR_IDLE hook.
0376    */
0377   T_eq_ptr(
0378     rtems_configuration_get_stack_allocate_for_idle_hook(),
0379     test_idle_task_stack_allocate
0380   );
0381 
0382   /*
0383    * Check the configured CONFIGURE_IDLE_TASK_STACK_SIZE value.
0384    */
0385   T_eq_sz(
0386     rtems_configuration_get_idle_task_stack_size(),
0387     TEST_IDLE_STACK_SIZE
0388   );
0389 
0390   /*
0391    * Check the configured CONFIGURE_INTERRUPT_STACK_SIZE value.
0392    */
0393   T_eq_sz(
0394     rtems_configuration_get_interrupt_stack_size(),
0395     TEST_INTERRUPT_STACK_SIZE
0396   );
0397 
0398   /*
0399    * Check the configured CONFIGURE_TICKS_PER_TIMESLICE value.
0400    */
0401   T_eq_u32(
0402     rtems_configuration_get_ticks_per_timeslice(),
0403     TEST_TICKS_PER_TIMESLICE
0404   );
0405 }
0406 
0407 /**
0408  * @fn void T_case_body_AcfgValAcfg( void )
0409  */
0410 T_TEST_CASE( AcfgValAcfg )
0411 {
0412   AcfgValAcfg_Action_0();
0413 }
0414 
0415 /** @} */