From 1a48cbfa16bf54a442f9394e4c4d9c2211e82865 Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Mon, 11 Nov 2019 20:08:46 +0100 Subject: sptests: Avoid include path magic Update #3818. --- testsuites/psxtests/Makefile.am | 10 +- testsuites/psxtests/psxfatal01/init.c | 45 +++++++ testsuites/psxtests/psxfatal01/testcase.h | 37 ------ testsuites/psxtests/psxfatal02/init.c | 49 ++++++++ testsuites/psxtests/psxfatal02/testcase.h | 41 ------- testsuites/psxtests/psxfatal_support/init.c | 135 --------------------- testsuites/psxtests/psxfatal_support/psxfatal.h | 14 +++ .../psxtests/psxfatal_support/psxfatalimpl.h | 121 ++++++++++++++++++ 8 files changed, 233 insertions(+), 219 deletions(-) create mode 100644 testsuites/psxtests/psxfatal01/init.c delete mode 100644 testsuites/psxtests/psxfatal01/testcase.h create mode 100644 testsuites/psxtests/psxfatal02/init.c delete mode 100644 testsuites/psxtests/psxfatal02/testcase.h delete mode 100644 testsuites/psxtests/psxfatal_support/init.c create mode 100644 testsuites/psxtests/psxfatal_support/psxfatal.h create mode 100644 testsuites/psxtests/psxfatal_support/psxfatalimpl.h (limited to 'testsuites/psxtests') diff --git a/testsuites/psxtests/Makefile.am b/testsuites/psxtests/Makefile.am index 0d213a4437..1f9e4233ec 100755 --- a/testsuites/psxtests/Makefile.am +++ b/testsuites/psxtests/Makefile.am @@ -391,19 +391,17 @@ endif if TEST_psxfatal01 psx_tests += psxfatal01 psx_screens += psxfatal01/psxfatal01.scn -psxfatal01_SOURCES = psxfatal_support/init.c \ - psxfatal01/testcase.h +psxfatal01_SOURCES = psxfatal01/init.c psxfatal01_CPPFLAGS = $(AM_CPPFLAGS) $(TEST_FLAGS_psxfatal01) \ - $(support_includes) -I$(top_srcdir)/psxfatal01 + $(support_includes) endif if TEST_psxfatal02 psx_tests += psxfatal02 psx_screens += psxfatal02/psxfatal02.scn -psxfatal02_SOURCES = psxfatal_support/init.c \ - psxfatal02/testcase.h +psxfatal02_SOURCES = psxfatal02/init.c psxfatal02_CPPFLAGS = $(AM_CPPFLAGS) $(TEST_FLAGS_psxfatal02) \ - $(support_includes) -I$(top_srcdir)/psxfatal02 + $(support_includes) endif if TEST_psxfchx01 diff --git a/testsuites/psxtests/psxfatal01/init.c b/testsuites/psxtests/psxfatal01/init.c new file mode 100644 index 0000000000..fb0e2b24ed --- /dev/null +++ b/testsuites/psxtests/psxfatal01/init.c @@ -0,0 +1,45 @@ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "../psxfatal_support/psxfatal.h" + +/* + * Classic API Init task create failure + */ + +#include + +#include + +/* + * Way too much stack space. Should generate a fatal error + * on the init task create. + */ +#define CONFIGURE_POSIX_HAS_OWN_INIT_THREAD_TABLE +#define CONFIGURE_POSIX_INIT_THREAD_STACK_SIZE 0 +posix_initialization_threads_table POSIX_Initialization_threads[] = { + { NULL, /* bad thread entry */ + 0 + } +}; + +#define CONFIGURE_POSIX_INIT_THREAD_TABLE_NAME POSIX_Initialization_threads + +#define CONFIGURE_POSIX_INIT_THREAD_TABLE_SIZE \ + sizeof(CONFIGURE_POSIX_INIT_THREAD_TABLE_NAME) / \ + sizeof(posix_initialization_threads_table) + +#define FATAL_ERROR_TEST_NAME "1" +#define FATAL_ERROR_DESCRIPTION \ + "POSIX API Init thread create failure - NULL entry" +#define FATAL_ERROR_EXPECTED_SOURCE INTERNAL_ERROR_CORE +#define FATAL_ERROR_EXPECTED_ERROR \ + INTERNAL_ERROR_POSIX_INIT_THREAD_CREATE_FAILED + +static void force_error(void) +{ + /* we will not run this far */ +} + +#include "../psxfatal_support/psxfatalimpl.h" diff --git a/testsuites/psxtests/psxfatal01/testcase.h b/testsuites/psxtests/psxfatal01/testcase.h deleted file mode 100644 index e67f879ff6..0000000000 --- a/testsuites/psxtests/psxfatal01/testcase.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Classic API Init task create failure - */ - -#include - -#include - -/* - * Way too much stack space. Should generate a fatal error - * on the init task create. - */ -#define CONFIGURE_POSIX_HAS_OWN_INIT_THREAD_TABLE -#define CONFIGURE_POSIX_INIT_THREAD_STACK_SIZE 0 -posix_initialization_threads_table POSIX_Initialization_threads[] = { - { NULL, /* bad thread entry */ - 0 - } -}; - -#define CONFIGURE_POSIX_INIT_THREAD_TABLE_NAME POSIX_Initialization_threads - -#define CONFIGURE_POSIX_INIT_THREAD_TABLE_SIZE \ - sizeof(CONFIGURE_POSIX_INIT_THREAD_TABLE_NAME) / \ - sizeof(posix_initialization_threads_table) - -#define FATAL_ERROR_TEST_NAME "1" -#define FATAL_ERROR_DESCRIPTION \ - "POSIX API Init thread create failure - NULL entry" -#define FATAL_ERROR_EXPECTED_SOURCE INTERNAL_ERROR_CORE -#define FATAL_ERROR_EXPECTED_ERROR \ - INTERNAL_ERROR_POSIX_INIT_THREAD_CREATE_FAILED - -void force_error(void) -{ - /* we will not run this far */ -} diff --git a/testsuites/psxtests/psxfatal02/init.c b/testsuites/psxtests/psxfatal02/init.c new file mode 100644 index 0000000000..260c0aea0d --- /dev/null +++ b/testsuites/psxtests/psxfatal02/init.c @@ -0,0 +1,49 @@ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "../psxfatal_support/psxfatal.h" + +/* + * Classic API Init task create failure + */ + +#include +#include + +#include + +/* + * Way too much stack space. Should generate a fatal error + * on the init task create. + */ +#define CONFIGURE_POSIX_HAS_OWN_INIT_THREAD_TABLE +#define CONFIGURE_POSIX_INIT_THREAD_STACK_SIZE 0 +posix_initialization_threads_table POSIX_Initialization_threads[] = { + { POSIX_Init, +#if INT_MAX < (12 * 1024 * 1024) + INT_MAX +#else + 12 * 1024 * 1024 /* too much stack */ +#endif + } +}; + +#define CONFIGURE_POSIX_INIT_THREAD_TABLE_NAME POSIX_Initialization_threads + +#define CONFIGURE_POSIX_INIT_THREAD_TABLE_SIZE \ + sizeof(CONFIGURE_POSIX_INIT_THREAD_TABLE_NAME) / \ + sizeof(posix_initialization_threads_table) + +#define FATAL_ERROR_TEST_NAME "2" +#define FATAL_ERROR_DESCRIPTION \ + "POSIX API Init thread create failure -- no memory for stack" +#define FATAL_ERROR_EXPECTED_SOURCE INTERNAL_ERROR_CORE +#define FATAL_ERROR_EXPECTED_ERROR INTERNAL_ERROR_POSIX_INIT_THREAD_CREATE_FAILED + +static void force_error(void) +{ + /* we will not run this far */ +} + +#include "../psxfatal_support/psxfatalimpl.h" diff --git a/testsuites/psxtests/psxfatal02/testcase.h b/testsuites/psxtests/psxfatal02/testcase.h deleted file mode 100644 index 7f97a6769e..0000000000 --- a/testsuites/psxtests/psxfatal02/testcase.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Classic API Init task create failure - */ - -#include -#include - -#include - -/* - * Way too much stack space. Should generate a fatal error - * on the init task create. - */ -#define CONFIGURE_POSIX_HAS_OWN_INIT_THREAD_TABLE -#define CONFIGURE_POSIX_INIT_THREAD_STACK_SIZE 0 -posix_initialization_threads_table POSIX_Initialization_threads[] = { - { POSIX_Init, -#if INT_MAX < (12 * 1024 * 1024) - INT_MAX -#else - 12 * 1024 * 1024 /* too much stack */ -#endif - } -}; - -#define CONFIGURE_POSIX_INIT_THREAD_TABLE_NAME POSIX_Initialization_threads - -#define CONFIGURE_POSIX_INIT_THREAD_TABLE_SIZE \ - sizeof(CONFIGURE_POSIX_INIT_THREAD_TABLE_NAME) / \ - sizeof(posix_initialization_threads_table) - -#define FATAL_ERROR_TEST_NAME "2" -#define FATAL_ERROR_DESCRIPTION \ - "POSIX API Init thread create failure -- no memory for stack" -#define FATAL_ERROR_EXPECTED_SOURCE INTERNAL_ERROR_CORE -#define FATAL_ERROR_EXPECTED_ERROR INTERNAL_ERROR_POSIX_INIT_THREAD_CREATE_FAILED - -void force_error(void) -{ - /* we will not run this far */ -} diff --git a/testsuites/psxtests/psxfatal_support/init.c b/testsuites/psxtests/psxfatal_support/init.c deleted file mode 100644 index 2c305396d5..0000000000 --- a/testsuites/psxtests/psxfatal_support/init.c +++ /dev/null @@ -1,135 +0,0 @@ -/* - * COPYRIGHT (c) 1989-2010. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include - -#include - -void *POSIX_Init(void *argument); - -void force_error(void); - -#include "testcase.h" - -const char rtems_test_name[] = "PSXFATAL " FATAL_ERROR_TEST_NAME; - -static void print_test_begin_message(void) -{ - static bool done = false; - - if (!done) { - done = true; - TEST_BEGIN(); - } -} - -void *POSIX_Init( - void *argument -) -{ - print_test_begin_message(); - force_error(); - printk( "Fatal error (%s) NOT hit\n", FATAL_ERROR_DESCRIPTION ); - rtems_test_exit(0); -} - -static void Put_Error( rtems_fatal_source source, rtems_fatal_code error ) -{ - if ( source == INTERNAL_ERROR_CORE ) { - printk( rtems_internal_error_text( error ) ); - } - else if (source == INTERNAL_ERROR_RTEMS_API ){ - printk( "%s", rtems_status_text( error ) ); - } - else if (source == INTERNAL_ERROR_POSIX_API ) { - printk( - "SOURCE=%d ERROR=%" PRIuMAX " %s", - source, - (uintmax_t) error, - strerror( (int) error ) - ); - } -} - -static void Put_Source( rtems_fatal_source source ) -{ - printk( "%s", rtems_fatal_source_text( source ) ); -} - -static void Fatal_extension( - rtems_fatal_source source, - bool always_set_to_false, - rtems_fatal_code error -) -{ - print_test_begin_message(); - printk( "Fatal error (%s) hit\n", FATAL_ERROR_DESCRIPTION ); - - if ( source != FATAL_ERROR_EXPECTED_SOURCE ){ - printk( "ERROR==> Fatal Extension source Expected ("); - Put_Source( FATAL_ERROR_EXPECTED_SOURCE ); - printk( ") received ("); - Put_Source( source ); - printk( ")\n" ); - } - - if ( always_set_to_false ) - printk( "ERROR==> Fatal Extension is internal set to true expected false\n" ); - - if ( error != FATAL_ERROR_EXPECTED_ERROR ) { - printk( "ERROR==> Fatal Error Expected ("); - Put_Error( source, FATAL_ERROR_EXPECTED_ERROR ); - printk( ") received ("); - Put_Error( source, error ); - printk( ")\n" ); - } - - if ( - source == FATAL_ERROR_EXPECTED_SOURCE - && !always_set_to_false - && error == FATAL_ERROR_EXPECTED_ERROR - ) { - TEST_END(); - } -} - -#define CONFIGURE_INIT - -#define CONFIGURE_INITIAL_EXTENSIONS \ - { \ - NULL, /* create */ \ - NULL, /* start */ \ - NULL, /* restart */ \ - NULL, /* delete */ \ - NULL, /* switch */ \ - NULL, /* begin */ \ - NULL, /* exitted */ \ - Fatal_extension /* fatal */ \ - }, \ - RTEMS_TEST_INITIAL_EXTENSION - -/* extra parameters may be in testcase.h */ -#define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER -#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER - -/* always need an Init task, some cases need more tasks */ -#ifndef SPFATAL_TEST_CASE_EXTRA_THREADS -#define SPFATAL_TEST_CASE_EXTRA_THREADS 0 -#endif - -#define CONFIGURE_MAXIMUM_POSIX_THREADS \ - (SPFATAL_TEST_CASE_EXTRA_THREADS + 1) - -#define CONFIGURE_POSIX_INIT_THREAD_TABLE - -#include diff --git a/testsuites/psxtests/psxfatal_support/psxfatal.h b/testsuites/psxtests/psxfatal_support/psxfatal.h new file mode 100644 index 0000000000..253828bdbd --- /dev/null +++ b/testsuites/psxtests/psxfatal_support/psxfatal.h @@ -0,0 +1,14 @@ +/* + * COPYRIGHT (c) 1989-2010. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#include + +#include + +void *POSIX_Init(void *argument); diff --git a/testsuites/psxtests/psxfatal_support/psxfatalimpl.h b/testsuites/psxtests/psxfatal_support/psxfatalimpl.h new file mode 100644 index 0000000000..928b07f335 --- /dev/null +++ b/testsuites/psxtests/psxfatal_support/psxfatalimpl.h @@ -0,0 +1,121 @@ +/* + * COPYRIGHT (c) 1989-2010. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +const char rtems_test_name[] = "PSXFATAL " FATAL_ERROR_TEST_NAME; + +static void print_test_begin_message(void) +{ + static bool done = false; + + if (!done) { + done = true; + TEST_BEGIN(); + } +} + +void *POSIX_Init( + void *argument +) +{ + print_test_begin_message(); + force_error(); + printk( "Fatal error (%s) NOT hit\n", FATAL_ERROR_DESCRIPTION ); + rtems_test_exit(0); +} + +static void Put_Error( rtems_fatal_source source, rtems_fatal_code error ) +{ + if ( source == INTERNAL_ERROR_CORE ) { + printk( rtems_internal_error_text( error ) ); + } + else if (source == INTERNAL_ERROR_RTEMS_API ){ + printk( "%s", rtems_status_text( error ) ); + } + else if (source == INTERNAL_ERROR_POSIX_API ) { + printk( + "SOURCE=%d ERROR=%" PRIuMAX " %s", + source, + (uintmax_t) error, + strerror( (int) error ) + ); + } +} + +static void Put_Source( rtems_fatal_source source ) +{ + printk( "%s", rtems_fatal_source_text( source ) ); +} + +static void Fatal_extension( + rtems_fatal_source source, + bool always_set_to_false, + rtems_fatal_code error +) +{ + print_test_begin_message(); + printk( "Fatal error (%s) hit\n", FATAL_ERROR_DESCRIPTION ); + + if ( source != FATAL_ERROR_EXPECTED_SOURCE ){ + printk( "ERROR==> Fatal Extension source Expected ("); + Put_Source( FATAL_ERROR_EXPECTED_SOURCE ); + printk( ") received ("); + Put_Source( source ); + printk( ")\n" ); + } + + if ( always_set_to_false ) + printk( "ERROR==> Fatal Extension is internal set to true expected false\n" ); + + if ( error != FATAL_ERROR_EXPECTED_ERROR ) { + printk( "ERROR==> Fatal Error Expected ("); + Put_Error( source, FATAL_ERROR_EXPECTED_ERROR ); + printk( ") received ("); + Put_Error( source, error ); + printk( ")\n" ); + } + + if ( + source == FATAL_ERROR_EXPECTED_SOURCE + && !always_set_to_false + && error == FATAL_ERROR_EXPECTED_ERROR + ) { + TEST_END(); + } +} + +#define CONFIGURE_INIT + +#define CONFIGURE_INITIAL_EXTENSIONS \ + { \ + NULL, /* create */ \ + NULL, /* start */ \ + NULL, /* restart */ \ + NULL, /* delete */ \ + NULL, /* switch */ \ + NULL, /* begin */ \ + NULL, /* exitted */ \ + Fatal_extension /* fatal */ \ + }, \ + RTEMS_TEST_INITIAL_EXTENSION + +/* extra parameters may be in testcase.h */ +#define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER +#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER + +/* always need an Init task, some cases need more tasks */ +#ifndef SPFATAL_TEST_CASE_EXTRA_THREADS +#define SPFATAL_TEST_CASE_EXTRA_THREADS 0 +#endif + +#define CONFIGURE_MAXIMUM_POSIX_THREADS \ + (SPFATAL_TEST_CASE_EXTRA_THREADS + 1) + +#define CONFIGURE_POSIX_INIT_THREAD_TABLE + +#include -- cgit v1.2.3