Back to home page

LXR

 
 

    


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

0001 /* SPDX-License-Identifier: BSD-2-Clause */
0002 
0003 /*  Task_1
0004  *
0005  *  This task generates all possible errors for the RTEMS executive.
0006  *
0007  *  Input parameters:
0008  *    argument - task argument
0009  *
0010  *  Output parameters:  NONE
0011  *
0012  *  COPYRIGHT (c) 1989-1999.
0013  *  On-Line Applications Research Corporation (OAR).
0014  *
0015  * Redistribution and use in source and binary forms, with or without
0016  * modification, are permitted provided that the following conditions
0017  * are met:
0018  * 1. Redistributions of source code must retain the above copyright
0019  *    notice, this list of conditions and the following disclaimer.
0020  * 2. Redistributions in binary form must reproduce the above copyright
0021  *    notice, this list of conditions and the following disclaimer in the
0022  *    documentation and/or other materials provided with the distribution.
0023  *
0024  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
0025  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
0026  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
0027  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
0028  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
0029  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
0030  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
0031  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
0032  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
0033  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
0034  * POSSIBILITY OF SUCH DAMAGE.
0035  */
0036 
0037 #ifdef HAVE_CONFIG_H
0038 #include "config.h"
0039 #endif
0040 
0041 #include "system.h"
0042 #include <rtems/rtems/tasksimpl.h>
0043 
0044 
0045 rtems_task Task_1(
0046   rtems_task_argument argument
0047 )
0048 {
0049   rtems_id            self_id;
0050   rtems_task_priority previous_priority;
0051   rtems_status_code   status;
0052 
0053   /* bad Id */
0054   status = rtems_task_is_suspended( 100 );
0055   fatal_directive_status(
0056     status,
0057     RTEMS_INVALID_ID,
0058     "rtems_task_set_priority with illegal id"
0059   );
0060   puts( "TA1 - rtems_task_is_suspended - RTEMS_INVALID_ID" );
0061 
0062   /* bad Id */
0063   status = rtems_task_delete( 100 );
0064   fatal_directive_status(
0065     status,
0066     RTEMS_INVALID_ID,
0067     "rtems_task_delete with illegal id"
0068   );
0069   puts( "TA1 - rtems_task_delete - RTEMS_INVALID_ID" );
0070 
0071   /* NULL param */
0072   status = rtems_task_ident( RTEMS_WHO_AM_I, RTEMS_SEARCH_ALL_NODES, NULL );
0073   fatal_directive_status(
0074     status,
0075     RTEMS_INVALID_ADDRESS,
0076     "rtems_task_ident NULL param"
0077   );
0078   puts( "TA1 - rtems_task_ident - RTEMS_INVALID_ADDRESS" );
0079 
0080   /* OK */
0081   status = rtems_task_ident( RTEMS_WHO_AM_I, RTEMS_SEARCH_ALL_NODES, &self_id );
0082   directive_failed( status, "rtems_task_ident of self" );
0083   if ( self_id != Task_id[ 1 ] ) {
0084     puts( "ERROR - rtems_task_ident - incorrect ID returned!" );
0085   }
0086   puts( "TA1 - rtems_task_ident - current task RTEMS_SUCCESSFUL" );
0087 
0088   status = rtems_task_ident( 100, RTEMS_SEARCH_ALL_NODES, &Junk_id );
0089   fatal_directive_status(
0090     status,
0091     RTEMS_INVALID_NAME,
0092     "rtems_task_ident with illegal name (local)"
0093   );
0094   puts( "TA1 - rtems_task_ident - global RTEMS_INVALID_NAME" );
0095 
0096   status = rtems_task_ident( 100, 1, &Junk_id );
0097   fatal_directive_status(
0098     status,
0099     RTEMS_INVALID_NAME,
0100     "rtems_task_ident with illegal name (global)"
0101   );
0102   puts( "TA1 - rtems_task_ident - local RTEMS_INVALID_NAME" );
0103 
0104   /*
0105    *  This one case is different if MP is enabled/disabled.
0106    */
0107 
0108   status = rtems_task_ident( 100, 2, &Junk_id );
0109 #if defined(RTEMS_MULTIPROCESSING)
0110   fatal_directive_status(
0111     status,
0112     RTEMS_INVALID_NODE,
0113     "rtems_task_ident with illegal node"
0114   );
0115 #else
0116   fatal_directive_status(
0117     status,
0118     RTEMS_INVALID_NAME,
0119     "rtems_task_ident with illegal node"
0120   );
0121 #endif
0122   puts( "TA1 - rtems_task_ident - RTEMS_INVALID_NODE" );
0123 
0124   status = rtems_task_restart( 100, 0 );
0125   fatal_directive_status(
0126     status,
0127     RTEMS_INVALID_ID,
0128     "rtems_task_restart with illegal id"
0129   );
0130   puts( "TA1 - rtems_task_restart - RTEMS_INVALID_ID" );
0131 
0132   status = rtems_task_resume( 100 );
0133   fatal_directive_status(
0134     status,
0135     RTEMS_INVALID_ID,
0136     "rtems_task_resume with illegal id"
0137   );
0138   puts( "TA1 - rtems_task_resume - RTEMS_INVALID_ID" );
0139 
0140   status = rtems_task_resume( RTEMS_SELF );
0141   fatal_directive_status(
0142     status,
0143     RTEMS_INCORRECT_STATE,
0144     "rtems_task_resume of ready task"
0145   );
0146   puts( "TA1 - rtems_task_resume - RTEMS_INCORRECT_STATE" );
0147 
0148   /* NULL param */
0149   status = rtems_task_set_priority( RTEMS_SELF, RTEMS_CURRENT_PRIORITY, NULL );
0150   fatal_directive_status(
0151     status,
0152     RTEMS_INVALID_ADDRESS,
0153     "rtems_task_set_priority with NULL param"
0154   );
0155   puts( "TA1 - rtems_task_set_priority - RTEMS_INVALID_ADDRESS" );
0156 
0157   /* bad priority */
0158   status = rtems_task_set_priority(
0159     RTEMS_SELF,
0160     UINT32_C(0x80000000),
0161     &previous_priority
0162   );
0163   fatal_directive_status(
0164     status,
0165     RTEMS_INVALID_PRIORITY,
0166     "rtems_task_set_priority with illegal priority"
0167   );
0168   puts( "TA1 - rtems_task_set_priority - RTEMS_INVALID_PRIORITY" );
0169 
0170   /* bad Id */
0171   status = rtems_task_set_priority( 100, 8, &previous_priority );
0172   fatal_directive_status(
0173     status,
0174     RTEMS_INVALID_ID,
0175     "rtems_task_set_priority with illegal id"
0176   );
0177   puts( "TA1 - rtems_task_set_priority - RTEMS_INVALID_ID" );
0178 
0179   status = rtems_task_start( 100, Task_1, 0 );
0180   fatal_directive_status(
0181     status,
0182     RTEMS_INVALID_ID,
0183     "rtems_task_start with illegal id"
0184   );
0185   puts( "TA1 - rtems_task_start - RTEMS_INVALID_ID" );
0186 
0187   /* NULL entry point */
0188   status = rtems_task_start( RTEMS_SELF, NULL, 0 );
0189   fatal_directive_status(
0190     status,
0191     RTEMS_INVALID_ADDRESS,
0192     "rtems_task_start with NULL entry point"
0193   );
0194   puts( "TA1 - rtems_task_start - RTEMS_INVALID_ADDRESS" );
0195 
0196   /* already started */
0197   status = rtems_task_start( RTEMS_SELF, Task_1, 0 );
0198   fatal_directive_status(
0199     status,
0200     RTEMS_INCORRECT_STATE,
0201     "rtems_task_start of ready task"
0202   );
0203   puts( "TA1 - rtems_task_start - RTEMS_INCORRECT_STATE" );
0204 
0205   /* bad Id */
0206   status = rtems_task_suspend( 100 );
0207   fatal_directive_status(
0208     status,
0209     RTEMS_INVALID_ID,
0210     "rtems_task_suspend with illegal id"
0211   );
0212   puts( "TA1 - rtems_task_suspend - RTEMS_INVALID_ID" );
0213 
0214   /* NULL param */
0215   status = rtems_task_mode( RTEMS_SELF, 0, NULL );
0216   fatal_directive_status(
0217     status,
0218     RTEMS_INVALID_ADDRESS,
0219     "rtems_task_mode with NULL param"
0220   );
0221   puts( "TA1 - rtems_task_mode - RTEMS_INVALID_ADDRESS" );
0222  
0223   TEST_END();
0224 
0225   rtems_test_exit( 0 );
0226 }