From ac7d5ef06a6d6e8d84abbd1f0b82162725f98326 Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Thu, 11 May 1995 17:39:37 +0000 Subject: Initial revision --- testsuites/sptests/spfatal/fatal.c | 134 +++++++++++++++++++++++++++++++++ testsuites/sptests/spfatal/init.c | 54 +++++++++++++ testsuites/sptests/spfatal/puterr.c | 68 +++++++++++++++++ testsuites/sptests/spfatal/spfatal.doc | 28 +++++++ testsuites/sptests/spfatal/spfatal.scn | 8 ++ testsuites/sptests/spfatal/system.h | 30 ++++++++ testsuites/sptests/spfatal/task1.c | 29 +++++++ 7 files changed, 351 insertions(+) create mode 100644 testsuites/sptests/spfatal/fatal.c create mode 100644 testsuites/sptests/spfatal/init.c create mode 100644 testsuites/sptests/spfatal/puterr.c create mode 100644 testsuites/sptests/spfatal/spfatal.doc create mode 100644 testsuites/sptests/spfatal/spfatal.scn create mode 100644 testsuites/sptests/spfatal/system.h create mode 100644 testsuites/sptests/spfatal/task1.c (limited to 'testsuites/sptests/spfatal') diff --git a/testsuites/sptests/spfatal/fatal.c b/testsuites/sptests/spfatal/fatal.c new file mode 100644 index 0000000000..3b2228bffd --- /dev/null +++ b/testsuites/sptests/spfatal/fatal.c @@ -0,0 +1,134 @@ +/* Fatal Error Test + * + * NOTE: + * + * This test actually modifies the Configuration table and restarts + * the executive. It is very carefully constructed to do this and + * uses the Configuration very carefully. + * + * COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994. + * On-Line Applications Research Corporation (OAR). + * All rights assigned to U.S. Government, 1994. + * + * This material may be reproduced by or for the U.S. Government pursuant + * to the copyright license under the clause at DFARS 252.227-7013. This + * notice must appear in all copies of this file and its derivatives. + * + * $Id$ + */ + +#include "system.h" + +#include + +char Workspace[ 64 * 1024 ] CPU_STRUCTURE_ALIGNMENT; + +typedef enum { + FATAL_WORKSPACE_OF_ZERO, + FATAL_NULL_WORKSPACE, + FATAL_WORKSPACE_TOO_SMALL, + FATAL_TASK_CREATE, + FATAL_TASK_START +} Fatal_errors_t; + +#define FATAL_LAST FATAL_TASK_START + +volatile Fatal_errors_t Case_in_switch; + +rtems_status_code Expected_Errors[] = { + RTEMS_UNSATISFIED, + RTEMS_INVALID_ADDRESS, + RTEMS_UNSATISFIED, + RTEMS_INVALID_PRIORITY, + RTEMS_TASK_EXITTED +}; + +rtems_status_code Error_Happened[ FATAL_LAST + 1]; + +jmp_buf Restart_Context; + +/* + * We depend on this being zeroed during initialization. This + * occurs automatically because this is part of the BSS. + */ + +rtems_unsigned32 First_Time_Through; + +void Process_case(); + +rtems_extension Fatal_extension( + rtems_unsigned32 error +) +{ + int index; + + Error_Happened[ Case_in_switch ] = error; + + if ( First_Time_Through == 0 ) { + Case_in_switch = FATAL_WORKSPACE_OF_ZERO; + First_Time_Through = 1; + setjmp( Restart_Context ); + } else if ( Case_in_switch == FATAL_LAST ) { + + /* + * Depending on the C library we use, we cannot get the + * task exitted error so do not check for it. + */ + + puts( "*** TEST FATAL ***" ); + for ( index=0 ; index< FATAL_LAST ; index++ ) + put_error( Error_Happened[ index ], Expected_Errors[ index ] ); + puts( "NOT TESTING FATAL ERROR WHEN TASK EXITS -- C LIBRARY CATCHES THIS" ); + puts( "*** END OF TEST FATAL ***" ); + + /* + * returns to the default fatal error handler instead of + * calling rtems_shutdown_executive + */ + return; + + } else { + + longjmp( Restart_Context, 1 ); + } + + Process_case(); +} + + + +void Process_case() +{ + switch ( Case_in_switch ) { + case FATAL_WORKSPACE_OF_ZERO: + New_Configuration = BSP_Configuration; + New_Configuration.work_space_start = NULL; + Case_in_switch = FATAL_NULL_WORKSPACE; + break; + + case FATAL_NULL_WORKSPACE: + New_Configuration.work_space_start = Workspace; + New_Configuration.work_space_size = 256; + Case_in_switch = FATAL_WORKSPACE_TOO_SMALL; + break; + + case FATAL_WORKSPACE_TOO_SMALL: + Initialization_tasks[ 0 ].initial_priority = RTEMS_CURRENT_PRIORITY; + New_Configuration.work_space_size = sizeof( Workspace ); + Case_in_switch = FATAL_TASK_CREATE; + break; + + case FATAL_TASK_CREATE: + Initialization_tasks[ 0 ].initial_priority = 1; + Initialization_tasks[ 0 ].entry_point = NULL; + Case_in_switch = FATAL_TASK_START; + break; + + case FATAL_TASK_START: + /* this extension exits the test */ + Initialization_tasks[ 0 ].entry_point = Init; + break; + } + rtems_initialize_executive( &New_Configuration, &Cpu_table ); +} + diff --git a/testsuites/sptests/spfatal/init.c b/testsuites/sptests/spfatal/init.c new file mode 100644 index 0000000000..a50c6101f5 --- /dev/null +++ b/testsuites/sptests/spfatal/init.c @@ -0,0 +1,54 @@ +/* Init + * + * This routine is the initialization task for this test program. + * It is a user initialization task and has the responsibility for creating + * and starting the tasks that make up the test. If the time of day + * clock is required for the test, it should also be set to a known + * value by this function. + * + * Input parameters: + * argument - task argument + * + * Output parameters: NONE + * + * COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994. + * On-Line Applications Research Corporation (OAR). + * All rights assigned to U.S. Government, 1994. + * + * This material may be reproduced by or for the U.S. Government pursuant + * to the copyright license under the clause at DFARS 252.227-7013. This + * notice must appear in all copies of this file and its derivatives. + * + * $Id$ + */ + +#include "system.h" +#undef EXTERN +#define EXTERN +#include "conftbl.h" +#include "gvar.h" + +rtems_task Init( + rtems_task_argument argument +) +{ + rtems_status_code status; + + Task_name[ 1 ] = rtems_build_name( 'T', 'A', '1', ' ' ); + + status = rtems_task_create( + Task_name[ 1 ], + 1, + 2048, + RTEMS_DEFAULT_MODES, + RTEMS_DEFAULT_ATTRIBUTES, + &Task_id[ 1 ] + ); + directive_failed( status, "rtems_task_create of TA1" ); + + status = rtems_task_start( Task_id[ 1 ], Task_1, 0 ); + directive_failed( status, "rtems_task_start of TA1" ); + + status = rtems_task_delete( RTEMS_SELF ); + directive_failed( status, "rtems_task_delete of RTEMS_SELF" ); +} diff --git a/testsuites/sptests/spfatal/puterr.c b/testsuites/sptests/spfatal/puterr.c new file mode 100644 index 0000000000..f7d79e5f34 --- /dev/null +++ b/testsuites/sptests/spfatal/puterr.c @@ -0,0 +1,68 @@ +/* put_error + * + * This routine verifies that the given error is the expected error. + * + * Input parameters: + * error - actual error code + * expected - expected error code + * + * Output parameters: NONE + * + * COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994. + * On-Line Applications Research Corporation (OAR). + * All rights assigned to U.S. Government, 1994. + * + * This material may be reproduced by or for the U.S. Government pursuant + * to the copyright license under the clause at DFARS 252.227-7013. This + * notice must appear in all copies of this file and its derivatives. + * + * $Id$ + */ + +#include "system.h" + +char *Errors[] = { + "RTEMS_SUCCESSFUL", /* successful completion */ + "RTEMS_TASK_EXITTED", /* returned from a task */ + "RTEMS_MP_NOT_CONFIGURED", /* multiprocessing not configured */ + "RTEMS_INVALID_NAME", /* invalid object name */ + "RTEMS_INVALID_ID", /* invalid object id */ + "RTEMS_TOO_MANY", /* too many */ + "RTEMS_TIMEOUT", /* timed out waiting */ + "RTEMS_OBJECT_WAS_DELETED", /* object was deleted while waiting */ + "RTEMS_INVALID_SIZE", /* specified size was invalid */ + "RTEMS_INVALID_ADDRESS", /* address specified is invalid */ + "RTEMS_INVALID_NUMBER", /* number was invalid */ + "RTEMS_NOT_DEFINED", /* item has not been initialized */ + "RTEMS_RESOURCE_IN_USE", /* resources still outstanding */ + "RTEMS_UNSATISFIED", /* request not satisfied */ + "RTEMS_INCORRECT_STATE", /* task is in wrong state */ + "RTEMS_ALREADY_SUSPENDED", /* task already in state */ + "RTEMS_ILLEGAL_ON_SELF", /* illegal operation on calling task */ + "RTEMS_ILLEGAL_ON_REMOTE_OBJECT", /* illegal operation for remote object */ + "RTEMS_CALLED_FROM_ISR", /* called from ISR */ + "RTEMS_INVALID_PRIORITY", /* invalid task priority */ + "RTEMS_INVALID_CLOCK", /* invalid date/time */ + "RTEMS_INVALID_NODE", /* invalid node id */ + "RTEMS_NOT_OWNER_OF_RESOURCE", /* not owner of resource */ + "RTEMS_NOT_CONFIGURED", /* directive not configured */ + "RTEMS_NOT_IMPLEMENTED" /* directive not implemented */ +}; + +/* Task states */ + +void put_error( + rtems_unsigned32 error, + rtems_status_code expected +) +{ + + if ( error <= RTEMS_NOT_IMPLEMENTED ) + printf( "EXPECTED FATAL - error code is correctly %s\n", Errors[ error ] ); + else + printf( "ERROR - out of range error code is %d\n", error ); + + if ( error != expected ) { + printf( "ERROR - did not get expected code of %d\n", expected ); + } +} diff --git a/testsuites/sptests/spfatal/spfatal.doc b/testsuites/sptests/spfatal/spfatal.doc new file mode 100644 index 0000000000..501f278670 --- /dev/null +++ b/testsuites/sptests/spfatal/spfatal.doc @@ -0,0 +1,28 @@ +# +# $Id$ +# +# COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994. +# On-Line Applications Research Corporation (OAR). +# All rights assigned to U.S. Government, 1994. +# +# This material may be reproduced by or for the U.S. Government pursuant +# to the copyright license under the clause at DFARS 252.227-7013. This +# notice must appear in all copies of this file and its derivatives. +# + + +This file describes the directives and concepts tested by this test set. + +test set name: testfatal + +directives: none + +concepts: + + a. Verifies that the proper error is reported by k_fatal when a task + exits. + + b. Verifies that the task exitted extension works correctly. + + c. Verifies that the fatal error extension works corectly. + diff --git a/testsuites/sptests/spfatal/spfatal.scn b/testsuites/sptests/spfatal/spfatal.scn new file mode 100644 index 0000000000..ecb9f63597 --- /dev/null +++ b/testsuites/sptests/spfatal/spfatal.scn @@ -0,0 +1,8 @@ +*** TEST FATAL *** +EXPECTED FATAL - error code is correctly RTEMS_UNSATISFIED +EXPECTED FATAL - error code is correctly RTEMS_INVALID_ADDRESS +EXPECTED FATAL - error code is correctly RTEMS_UNSATISFIED +EXPECTED FATAL - error code is correctly RTEMS_INVALID_PRIORITY +EXPECTED FATAL - error code is correctly RTEMS_TASK_EXITTED +NOT TESTING FATAL ERROR WHEN TASK EXITS -- C LIBRARY CATCHES THIS +*** END OF TEST FATAL *** diff --git a/testsuites/sptests/spfatal/system.h b/testsuites/sptests/spfatal/system.h new file mode 100644 index 0000000000..aa2c6d17e4 --- /dev/null +++ b/testsuites/sptests/spfatal/system.h @@ -0,0 +1,30 @@ +/* system.h + * + * This include file contains information that is included in every + * function in the test set. + * + * COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994. + * On-Line Applications Research Corporation (OAR). + * All rights assigned to U.S. Government, 1994. + * + * This material may be reproduced by or for the U.S. Government pursuant + * to the copyright license under the clause at DFARS 252.227-7013. This + * notice must appear in all copies of this file and its derivatives. + * + * $Id$ + */ + +#include +#include "tmacros.h" + +/* Miscellaneous */ + +#define EXTERN extern /* external definition */ + +/* macros */ + +/* structures */ + +#include "gvar.h" + +/* end of include file */ diff --git a/testsuites/sptests/spfatal/task1.c b/testsuites/sptests/spfatal/task1.c new file mode 100644 index 0000000000..d06d25e690 --- /dev/null +++ b/testsuites/sptests/spfatal/task1.c @@ -0,0 +1,29 @@ +/* Task_1 + * + * This routine serves as a test task. It verifies the task manager. + * + * Input parameters: + * argument - task argument + * + * Output parameters: NONE + * + * COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994. + * On-Line Applications Research Corporation (OAR). + * All rights assigned to U.S. Government, 1994. + * + * This material may be reproduced by or for the U.S. Government pursuant + * to the copyright license under the clause at DFARS 252.227-7013. This + * notice must appear in all copies of this file and its derivatives. + * + * $Id$ + */ + +#include "system.h" + +rtems_task Task_1( + rtems_task_argument argument +) +{ + puts( "\n\n*** TEST FATAL ***" ); + puts( "TA1 - exitting task" ); +} -- cgit v1.2.3