Back to home page

LXR

 
 

    


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

0001 /* SPDX-License-Identifier: BSD-2-Clause */
0002 
0003 /*
0004  *  COPYRIGHT (c) 1989-2009.
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 7";
0037 
0038 static void Task_harmless_extension_one(
0039   rtems_tcb *unused_one
0040 )
0041 {
0042   /* Do nothing */
0043 }
0044 
0045 static void Task_harmless_extension_two(
0046   rtems_tcb *unused_one,
0047   rtems_tcb *unused_two
0048 )
0049 {
0050   /* Do nothing */
0051 }
0052 
0053 static bool Task_harmless_extension_true_two(
0054   rtems_tcb *unused_one,
0055   rtems_tcb *unused_two
0056 )
0057 {
0058   return true;
0059 }
0060 
0061 static const rtems_extensions_table Harmless_extensions = {
0062   Task_harmless_extension_true_two,
0063   Task_harmless_extension_two,
0064   Task_harmless_extension_two,
0065   Task_harmless_extension_two,
0066   Task_harmless_extension_two,
0067   Task_harmless_extension_one,
0068   Task_harmless_extension_one,
0069   NULL
0070 };
0071 
0072 rtems_extensions_table Extensions = {
0073   Task_create_extension,     /* task create user extension */
0074   Task_start_extension,      /* task start user extension */
0075   Task_restart_extension,    /* task restart user extension */
0076   Task_delete_extension,     /* task delete user extension */
0077   NULL,                      /* task switch user extension */
0078   NULL,                      /* begin user extension */
0079   Task_exit_extension,       /* task exitted user extension */
0080   NULL                       /* fatal error extension */
0081 };
0082 
0083 rtems_task Init(
0084   rtems_task_argument argument
0085 )
0086 {
0087   rtems_status_code status;
0088   rtems_id          id;
0089 
0090   TEST_BEGIN();
0091 
0092   Extension_name[ 1 ] =  rtems_build_name( 'E', 'X', 'T', '1' );
0093   Extension_name[ 2 ] =  rtems_build_name( 'E', 'X', 'T', '2' );
0094 
0095   puts  ( "rtems_extension_create - bad table -- RTEMS_INVALID_ADDRESS" );
0096   status = rtems_extension_create( 0xa5a5a5a5, NULL, &id );
0097   fatal_directive_status(
0098     status, RTEMS_INVALID_ADDRESS, "rtems_extension_create" );
0099 
0100   puts  ( "rtems_extension_create - bad id pointer -- RTEMS_INVALID_ADDRESS" );
0101   status = rtems_extension_create( 0xa5a5a5a5, &Extensions, NULL );
0102   fatal_directive_status(
0103     status, RTEMS_INVALID_ADDRESS, "rtems_extension_create" );
0104 
0105   puts  ( "rtems_extension_create - bad name -- RTEMS_INVALID_NAME" );
0106   status = rtems_extension_create( 0, &Extensions, &id );
0107   fatal_directive_status(
0108     status, RTEMS_INVALID_NAME, "rtems_extension_create #1" );
0109 
0110   puts( "rtems_extension_create - first one -- OK" );
0111   status = rtems_extension_create(
0112     Extension_name[ 1 ],
0113     &Extensions,
0114     &Extension_id[ 1 ]
0115   );
0116   directive_failed( status, "rtems_extension_create" );
0117 
0118   puts( "rtems_extension_create - second one-- OK" );
0119   status = rtems_extension_create(
0120     Extension_name[ 2 ],
0121     &Extensions,
0122     &Extension_id[ 2 ]
0123   );
0124   directive_failed( status, "rtems_extension_create #2" );
0125 
0126   puts  ( "rtems_extension_create -- RTEMS_TOO_MANY" );
0127   status = rtems_extension_create( 0xa5a5a5a5, &Extensions, &id );
0128   fatal_directive_status( status, RTEMS_TOO_MANY, "rtems_extension_create" );
0129 
0130   puts( "rtems_extension_delete - second one -- OK" );
0131   status = rtems_extension_delete( Extension_id[ 2 ] );
0132   directive_failed( status, "rtems_extension_delete #2" );
0133 
0134   puts( "rtems_extension_delete - second one again -- RTEMS_INVALID_ID" );
0135   status = rtems_extension_delete( Extension_id[ 2 ] );
0136   fatal_directive_status(
0137     status,
0138     RTEMS_INVALID_ID,
0139     "rtems_extension_delete #2 bad"
0140   );
0141 
0142   puts  ( "rtems_extension_ident -- OK" );
0143   status = rtems_extension_ident( Extension_name[1], &id );
0144   directive_failed( status, "rtems_extension_ident" );
0145 
0146   puts  ( "rtems_extension_ident - bad name -- RTEMS_INVALID_NAME" );
0147   status = rtems_extension_ident( Extension_name[2], &id );
0148   fatal_directive_status( status, RTEMS_INVALID_NAME, "rtems_extension_ident" );
0149 
0150   puts  ( "rtems_extension_ident - bad name -- RTEMS_INVALID_ADDRESS" );
0151   status = rtems_extension_ident( Extension_name[2], NULL );
0152   fatal_directive_status(
0153     status,
0154     RTEMS_INVALID_ADDRESS,
0155     "rtems_extension_ident"
0156   );
0157 
0158   puts( "rtems_extension_create - harmless -- OK" );
0159   status = rtems_extension_create(
0160     Extension_name[ 2 ],
0161     &Harmless_extensions,
0162     &Extension_id[ 2 ]
0163   );
0164   directive_failed( status, "rtems_extension_create #3" );
0165 
0166   Task_name[ 1 ] = rtems_build_name( 'T', 'A', '1', ' ' );
0167   Task_name[ 2 ] = rtems_build_name( 'T', 'A', '2', ' ' );
0168   Task_name[ 3 ] = rtems_build_name( 'T', 'A', '3', ' ' );
0169   Task_name[ 4 ] = rtems_build_name( 'T', 'A', '4', ' ' );
0170 
0171   status = rtems_task_create(
0172     Task_name[ 1 ],
0173     4,
0174     RTEMS_MINIMUM_STACK_SIZE * 2,
0175     RTEMS_DEFAULT_MODES,
0176     RTEMS_DEFAULT_ATTRIBUTES,
0177     &Task_id[ 1 ]
0178   );
0179   directive_failed( status, "rtems_task_create of TA1" );
0180   assert_extension_counts( &Task_created[ 0 ], 0x2 );
0181 
0182   status = rtems_task_create(
0183     Task_name[ 2 ],
0184     4,
0185     RTEMS_MINIMUM_STACK_SIZE * 2,
0186     RTEMS_DEFAULT_MODES,
0187     RTEMS_DEFAULT_ATTRIBUTES,
0188     &Task_id[ 2 ]
0189   );
0190   directive_failed( status, "rtems_task_create of TA2" );
0191   assert_extension_counts( &Task_created[ 0 ], 0x2 | 0x4 );
0192 
0193 #define TA3_PRIORITY (RTEMS_MAXIMUM_PRIORITY - 4u)
0194   status = rtems_task_create(
0195     Task_name[ 3 ],
0196     TA3_PRIORITY,
0197     RTEMS_MINIMUM_STACK_SIZE * 2,
0198     RTEMS_DEFAULT_MODES,
0199     RTEMS_DEFAULT_ATTRIBUTES,
0200     &Task_id[ 3 ]
0201   );
0202   directive_failed( status, "rtems_task_create of TA3" );
0203   assert_extension_counts( &Task_created[ 0 ], 0x2 | 0x4 | 0x8 );
0204 
0205 #define TA4_PRIORITY (RTEMS_MAXIMUM_PRIORITY - 1u)
0206   status = rtems_task_create(
0207     Task_name[ 4 ],
0208     TA4_PRIORITY,
0209     RTEMS_MINIMUM_STACK_SIZE * 2,
0210     RTEMS_DEFAULT_MODES,
0211     RTEMS_DEFAULT_ATTRIBUTES,
0212     &Task_id[ 4 ]
0213   );
0214   directive_failed( status, "rtems_task_create of TA4" );
0215   assert_extension_counts( &Task_created[ 0 ], 0x2 | 0x4 | 0x8 | 0x10 );
0216 
0217   status = rtems_task_start( Task_id[ 1 ], Task_1, 0 );
0218   directive_failed( status, "rtems_task_start of TA1" );
0219   assert_extension_counts( &Task_started[ 0 ], 0x2 );
0220 
0221   status = rtems_task_start( Task_id[ 2 ], Task_2, 0 );
0222   directive_failed( status, "rtems_task_start of TA2" );
0223   assert_extension_counts( &Task_started[ 0 ], 0x2 | 0x4 );
0224 
0225   status = rtems_task_start( Task_id[ 3 ], Task_3, 0 );
0226   directive_failed( status, "rtems_task_start of TA3" );
0227   assert_extension_counts( &Task_started[ 0 ], 0x2 | 0x4 | 0x8 );
0228 
0229   status = rtems_task_start( Task_id[ 4 ], Task_4, 0 );
0230   directive_failed( status, "rtems_task_start of TA4" );
0231   assert_extension_counts( &Task_started[ 0 ], 0x2 | 0x4 | 0x8 | 0x10 );
0232 
0233   status = rtems_task_restart( Task_id[ 2 ], 0 );
0234   directive_failed( status, "rtems_task_restart of TA3" );
0235   assert_extension_counts( &Task_restarted[ 0 ], 0x0 );
0236 
0237   rtems_task_exit();
0238 }