Back to home page

LXR

 
 

    


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

0001 /* SPDX-License-Identifier: BSD-2-Clause */
0002 
0003 /*
0004  *  COPYRIGHT (c) 2014.
0005  *  On-Line Applications Research Corporation (OAR).
0006  *
0007  * Redistribution and use in source and binary forms, with or without
0008  * modification, are permitted provided that the following conditions
0009  * are met:
0010  * 1. Redistributions of source code must retain the above copyright
0011  *    notice, this list of conditions and the following disclaimer.
0012  * 2. Redistributions in binary form must reproduce the above copyright
0013  *    notice, this list of conditions and the following disclaimer in the
0014  *    documentation and/or other materials provided with the distribution.
0015  *
0016  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
0017  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
0018  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
0019  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
0020  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
0021  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
0022  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
0023  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
0024  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
0025  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
0026  * POSSIBILITY OF SUCH DAMAGE.
0027  */
0028 
0029 #ifdef HAVE_CONFIG_H
0030 #include "config.h"
0031 #endif
0032 
0033 #define CONFIGURE_INIT
0034 #include "system.h"
0035 
0036 const char rtems_test_name[] = "SP TASK ERROR 03";
0037 
0038 rtems_task Init(
0039   rtems_task_argument argument
0040 )
0041 {
0042   rtems_name        task_name;
0043   rtems_status_code status;
0044   bool              skipUnsatisfied; 
0045   
0046   TEST_BEGIN();
0047   
0048   Task_name[ 1 ]       =  rtems_build_name( 'T', 'A', '1', ' ' );
0049   Task_name[ 2 ]       =  rtems_build_name( 'T', 'A', '2', ' ' );
0050   Task_name[ 3 ]       =  rtems_build_name( 'T', 'A', '3', ' ' );
0051   Task_name[ 4 ]       =  rtems_build_name( 'T', 'A', '4', ' ' );
0052   Task_name[ 5 ]       =  rtems_build_name( 'T', 'A', '5', ' ' );
0053   Task_name[ 6 ]       =  rtems_build_name( 'T', 'A', '6', ' ' );
0054   Task_name[ 7 ]       =  rtems_build_name( 'T', 'A', '7', ' ' );
0055   Task_name[ 8 ]       =  rtems_build_name( 'T', 'A', '8', ' ' );
0056   Task_name[ 9 ]       =  rtems_build_name( 'T', 'A', '9', ' ' );
0057   Task_name[ 10 ]      =  rtems_build_name( 'T', 'A', 'A', ' ' );
0058 
0059   /* task create bad name */
0060   task_name = 1;
0061   status = rtems_task_create(
0062     0,
0063     1,
0064     RTEMS_MINIMUM_STACK_SIZE,
0065     RTEMS_DEFAULT_MODES,
0066     RTEMS_DEFAULT_ATTRIBUTES,
0067     &Junk_id
0068   );
0069   fatal_directive_status(
0070     status,
0071     RTEMS_INVALID_NAME,
0072     "rtems_task_create with illegal name"
0073   );
0074   puts( "TA1 - rtems_task_create - RTEMS_INVALID_NAME" );
0075 
0076   /* null ID */
0077   status = rtems_task_create(
0078     Task_name[ 1 ],
0079     4,
0080     RTEMS_MINIMUM_STACK_SIZE,
0081     RTEMS_DEFAULT_MODES,
0082     RTEMS_DEFAULT_ATTRIBUTES,
0083     NULL
0084   );
0085   fatal_directive_status(
0086     status,
0087     RTEMS_INVALID_ADDRESS,
0088     "rtems_task_create with NULL ID param"
0089   );
0090   puts( "TA1 - rtems_task_create - RTEMS_INVALID_ADDRESS" );
0091 
0092   /*
0093    * If the bsp provides its own stack allocator, then
0094    * skip the test that tries to allocate a stack that is too big.
0095    */
0096 
0097   skipUnsatisfied = false;
0098   if (rtems_configuration_get_stack_allocate_hook())
0099     skipUnsatisfied = true;
0100 
0101   if ( skipUnsatisfied ) {
0102     puts(
0103       "TA1 - rtems_task_create - stack size - RTEMS_UNSATISFIED  -- SKIPPED"
0104     );
0105   } else {
0106       status = rtems_task_create(
0107         task_name,
0108         1,
0109         rtems_configuration_get_work_space_size(),
0110         RTEMS_DEFAULT_MODES,
0111         RTEMS_DEFAULT_ATTRIBUTES,
0112         &Junk_id
0113       );
0114       fatal_directive_status(
0115         status,
0116         RTEMS_UNSATISFIED,
0117         "rtems_task_create with a stack size larger than the workspace"
0118       );
0119       puts( "TA1 - rtems_task_create - stack size - RTEMS_UNSATISFIED" );
0120   }
0121    status = rtems_task_create(
0122     Task_name[ 1 ],
0123     4,
0124     RTEMS_MINIMUM_STACK_SIZE * 3,
0125     RTEMS_DEFAULT_MODES,
0126     RTEMS_DEFAULT_ATTRIBUTES,
0127     &Task_id[ 1 ]
0128   );
0129   directive_failed( status, "rtems_task_create of TA1" );
0130 
0131   status = rtems_task_create(
0132     Task_name[ 2 ],
0133     4,
0134     RTEMS_MINIMUM_STACK_SIZE,
0135     RTEMS_DEFAULT_MODES,
0136     RTEMS_DEFAULT_ATTRIBUTES,
0137     &Task_id[ 2 ]
0138   );
0139   directive_failed( status, "rtems_task_create of TA2" );
0140   puts( "TA1 - rtems_task_create - TA2 created - RTEMS_SUCCESSFUL" );
0141 
0142   status = rtems_task_suspend( Task_id[ 2 ] );
0143   directive_failed( status, "rtems_task_suspend of TA2" );
0144   puts( "TA1 - rtems_task_suspend - suspend TA2 - RTEMS_SUCCESSFUL" );
0145 
0146   status = rtems_task_suspend( Task_id[ 2 ] );
0147   fatal_directive_status(
0148     status,
0149     RTEMS_ALREADY_SUSPENDED,
0150     "rtems_task_suspend of suspended TA2"
0151   );
0152   puts( "TA1 - rtems_task_suspend - suspend TA2 - RTEMS_ALREADY_SUSPENDED" );
0153 
0154   status = rtems_task_resume( Task_id[ 2 ] );
0155   directive_failed( status, "rtems_task_resume of TA2" );
0156   puts( "TA1 - rtems_task_resume - TA2 resumed - RTEMS_SUCCESSFUL" );
0157 
0158   status = rtems_task_create(
0159     Task_name[ 3 ],
0160     4,
0161     RTEMS_MINIMUM_STACK_SIZE,
0162     RTEMS_DEFAULT_MODES,
0163     RTEMS_DEFAULT_ATTRIBUTES,
0164     &Task_id[ 3 ]
0165   );
0166   directive_failed( status, "rtems_task_create of TA3" );
0167   puts( "TA1 - rtems_task_create - TA3 created - RTEMS_SUCCESSFUL" );
0168 
0169   status = rtems_task_create(
0170     Task_name[ 5 ],
0171     4,
0172     RTEMS_MINIMUM_STACK_SIZE,
0173     RTEMS_DEFAULT_MODES,
0174     RTEMS_DEFAULT_ATTRIBUTES,
0175     &Task_id[ 5 ]
0176   );
0177   directive_failed( status, "rtems_task_create of TA5" );
0178   puts( "TA1 - rtems_task_create - 5 created - RTEMS_SUCCESSFUL" );
0179 
0180   status = rtems_task_create(
0181     Task_name[ 6 ],
0182     4,
0183     RTEMS_MINIMUM_STACK_SIZE,
0184     RTEMS_DEFAULT_MODES,
0185     RTEMS_DEFAULT_ATTRIBUTES,
0186     &Task_id[ 6 ]
0187   );
0188   directive_failed( status, "rtems_task_create of TA6" );
0189   puts( "TA1 - rtems_task_create - 6 created - RTEMS_SUCCESSFUL" );
0190 
0191   status = rtems_task_create(
0192     Task_name[ 7 ],
0193     4,
0194     RTEMS_MINIMUM_STACK_SIZE,
0195     RTEMS_DEFAULT_MODES,
0196     RTEMS_DEFAULT_ATTRIBUTES,
0197     &Task_id[ 7 ]
0198   );
0199   directive_failed( status, "rtems_task_create of TA7" );
0200   puts( "TA1 - rtems_task_create - 7 created - RTEMS_SUCCESSFUL" );
0201 
0202   status = rtems_task_create(
0203     Task_name[ 8 ],
0204     4,
0205     RTEMS_MINIMUM_STACK_SIZE,
0206     RTEMS_DEFAULT_MODES,
0207     RTEMS_DEFAULT_ATTRIBUTES,
0208     &Task_id[ 8 ]
0209   );
0210   directive_failed( status, "rtems_task_create of TA8" );
0211   puts( "TA1 - rtems_task_create - 8 created - RTEMS_SUCCESSFUL" );
0212 
0213   status = rtems_task_create(
0214     Task_name[ 9 ],
0215     4,
0216     RTEMS_MINIMUM_STACK_SIZE,
0217     RTEMS_DEFAULT_MODES,
0218     RTEMS_DEFAULT_ATTRIBUTES,
0219     &Task_id[ 9 ]
0220   );
0221   directive_failed( status, "rtems_task_create of TA9" );
0222   puts( "TA1 - rtems_task_create - 9 created - RTEMS_SUCCESSFUL" );
0223 
0224   status = rtems_task_create(
0225     Task_name[ 10 ],
0226     4,
0227     RTEMS_MINIMUM_STACK_SIZE,
0228     RTEMS_DEFAULT_MODES,
0229     RTEMS_DEFAULT_ATTRIBUTES,
0230     &Task_id[ 10 ]
0231   );
0232   directive_failed( status, "rtems_task_create of TA10" );
0233   puts( "TA1 - rtems_task_create - 10 created - RTEMS_SUCCESSFUL" );
0234 
0235   status = rtems_task_create(
0236     task_name,
0237     4,
0238     RTEMS_MINIMUM_STACK_SIZE,
0239     RTEMS_DEFAULT_MODES,
0240     RTEMS_DEFAULT_ATTRIBUTES,
0241     &Junk_id
0242   );
0243   fatal_directive_status(
0244     status,
0245     RTEMS_TOO_MANY,
0246     "rtems_task_create for too many tasks"
0247   );
0248   puts( "TA1 - rtems_task_create - 11 - RTEMS_TOO_MANY" );
0249 
0250   TEST_END();
0251 }