Back to home page

LXR

 
 

    


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

0001 /* SPDX-License-Identifier: BSD-2-Clause */
0002 
0003 /*
0004  *  COPYRIGHT (c) 1989-2010.
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 const char rtems_test_name[] = "PSXFATAL " FATAL_ERROR_TEST_NAME;
0030 
0031 static void print_test_begin_message(void)
0032 {
0033   static bool done = false;
0034 
0035   if (!done) {
0036     done = true;
0037     TEST_BEGIN();
0038   }
0039 }
0040 
0041 void *POSIX_Init(
0042   void *argument
0043 )
0044 {
0045   print_test_begin_message();
0046   force_error();
0047   printk( "Fatal error (%s) NOT hit\n", FATAL_ERROR_DESCRIPTION );
0048   rtems_test_exit(0);
0049 }
0050 
0051 static void Put_Error( rtems_fatal_source source, rtems_fatal_code error )
0052 {
0053   if ( source == INTERNAL_ERROR_CORE ) {
0054     printk( rtems_internal_error_text( error ) );
0055   }
0056   else if (source == INTERNAL_ERROR_RTEMS_API ){
0057     printk( "%s", rtems_status_text( error ) );
0058   }
0059   else if (source == INTERNAL_ERROR_POSIX_API ) {
0060     printk(
0061       "SOURCE=%d ERROR=%" PRIuMAX " %s",
0062       source,
0063       (uintmax_t) error,
0064       strerror( (int) error )
0065     );
0066   }
0067 }
0068 
0069 static void Put_Source( rtems_fatal_source source )
0070 {
0071   printk( "%s", rtems_fatal_source_text( source ) );
0072 }
0073 
0074 static void Fatal_extension(
0075   rtems_fatal_source source,
0076   bool               always_set_to_false,
0077   rtems_fatal_code   error
0078 )
0079 {
0080   print_test_begin_message();
0081   printk( "Fatal error (%s) hit\n", FATAL_ERROR_DESCRIPTION );
0082 
0083   if ( source != FATAL_ERROR_EXPECTED_SOURCE ){
0084     printk( "ERROR==> Fatal Extension source Expected (");
0085     Put_Source( FATAL_ERROR_EXPECTED_SOURCE );
0086     printk( ") received (");
0087     Put_Source( source );
0088     printk( ")\n" );
0089   }
0090 
0091   if ( always_set_to_false )
0092     printk( "ERROR==> Fatal Extension is internal set to true expected false\n" );
0093 
0094   if ( error !=  FATAL_ERROR_EXPECTED_ERROR ) {
0095     printk( "ERROR==> Fatal Error Expected (");
0096     Put_Error( source, FATAL_ERROR_EXPECTED_ERROR );
0097     printk( ") received (");
0098     Put_Error( source, error );
0099     printk( ")\n" );
0100   }
0101 
0102   if (
0103     source == FATAL_ERROR_EXPECTED_SOURCE
0104       && !always_set_to_false
0105       && error == FATAL_ERROR_EXPECTED_ERROR
0106   ) {
0107     TEST_END();
0108   }
0109 }
0110 
0111 #define CONFIGURE_INIT
0112 
0113 #define CONFIGURE_INITIAL_EXTENSIONS \
0114   { \
0115     NULL,                    /* create  */ \
0116     NULL,                    /* start   */ \
0117     NULL,                    /* restart */ \
0118     NULL,                    /* delete  */ \
0119     NULL,                    /* switch  */ \
0120     NULL,                    /* begin   */ \
0121     NULL,                    /* exitted */ \
0122     Fatal_extension          /* fatal   */ \
0123   }, \
0124   RTEMS_TEST_INITIAL_EXTENSION
0125 
0126 /* extra parameters may be in testcase.h */
0127 #define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER
0128 #define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
0129 
0130 /* always need an Init task, some cases need more tasks */
0131 #ifndef SPFATAL_TEST_CASE_EXTRA_THREADS
0132 #define SPFATAL_TEST_CASE_EXTRA_THREADS 0
0133 #endif
0134 
0135 #define CONFIGURE_MAXIMUM_POSIX_THREADS \
0136   (SPFATAL_TEST_CASE_EXTRA_THREADS + 1)
0137 
0138 #define CONFIGURE_POSIX_INIT_THREAD_TABLE
0139 
0140 #include <rtems/confdefs.h>