From d6467102e2c2af2c0cacd1366d0922f5f4481ac1 Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Wed, 15 Jun 2016 09:04:29 +0200 Subject: psxtests/psx12: Use one file and simplify --- testsuites/psxtests/psx12/Makefile.am | 2 +- testsuites/psxtests/psx12/init.c | 65 +++++++++++++++-------------------- testsuites/psxtests/psx12/psx12.scn | 8 ++--- testsuites/psxtests/psx12/system.h | 52 ---------------------------- testsuites/psxtests/psx12/task.c | 40 --------------------- 5 files changed, 33 insertions(+), 134 deletions(-) delete mode 100644 testsuites/psxtests/psx12/system.h delete mode 100644 testsuites/psxtests/psx12/task.c diff --git a/testsuites/psxtests/psx12/Makefile.am b/testsuites/psxtests/psx12/Makefile.am index fedd135125..c6325309e9 100644 --- a/testsuites/psxtests/psx12/Makefile.am +++ b/testsuites/psxtests/psx12/Makefile.am @@ -1,6 +1,6 @@ rtems_tests_PROGRAMS = psx12 -psx12_SOURCES = init.c task.c system.h ../include/pmacros.h +psx12_SOURCES = init.c ../include/pmacros.h dist_rtems_tests_DATA = psx12.scn diff --git a/testsuites/psxtests/psx12/init.c b/testsuites/psxtests/psx12/init.c index 410a141335..46be8183e3 100644 --- a/testsuites/psxtests/psx12/init.c +++ b/testsuites/psxtests/psx12/init.c @@ -12,45 +12,24 @@ #endif #include - -#define CONFIGURE_INIT -#include "system.h" #include -#include "pritime.h" -const char rtems_test_name[] = "PSX 12"; +#include -void print_schedparam( - char *prefix, - struct sched_param *schedparam -); +const char rtems_test_name[] = "PSX 12"; -void print_schedparam( - char *prefix, - struct sched_param *schedparam -) +static void *sporadic_server( void *argument ) { - printf( "%ssched priority = %d\n", prefix, schedparam->sched_priority ); -#if defined(_POSIX_SPORADIC_SERVER) - printf( "%ssched_ss_low_priority = %d\n", - prefix, schedparam->sched_ss_low_priority ); - printf( "%ssched_ss_repl_period = (%" PRIdtime_t ", %ld)\n", prefix, - schedparam->sched_ss_repl_period.tv_sec, - schedparam->sched_ss_repl_period.tv_nsec ); - printf( "%ssched_ss_init_budget = (%" PRIdtime_t ", %ld)\n", prefix, - schedparam->sched_ss_init_budget.tv_sec, - schedparam->sched_ss_init_budget.tv_nsec ); -#else - printf( "%s_POSIX_SPORADIC_SERVER is not defined\n", prefix ); -#endif + puts( "Sporadic Server: exitting" ); + + return NULL; } -void *POSIX_Init( - void *argument -) +static void *POSIX_Init( void *argument ) { int status; pthread_attr_t attr; + pthread_t thread; struct sched_param schedparam; TEST_BEGIN(); @@ -61,8 +40,7 @@ void *POSIX_Init( /* get id of this thread */ - Init_id = pthread_self(); - printf( "Init's ID is 0x%08" PRIxpthread_t "\n", Init_id ); + printf( "Init's ID is 0x%08" PRIxpthread_t "\n", pthread_self() ); /* invalid scheduling policy error */ @@ -75,7 +53,7 @@ void *POSIX_Init( attr.schedpolicy = -1; puts( "Init: pthread_create - EINVAL (invalid scheduling policy)" ); - status = pthread_create( &Task_id, &attr, Task_1, NULL ); + status = pthread_create( &thread, &attr, sporadic_server, NULL ); rtems_test_assert( status == EINVAL ); /* replenish period < budget error */ @@ -103,7 +81,7 @@ void *POSIX_Init( rtems_test_assert( !status ); puts( "Init: pthread_create - EINVAL (replenish < budget)" ); - status = pthread_create( &Task_id, &attr, Task_1, NULL ); + status = pthread_create( &thread, &attr, sporadic_server, NULL ); rtems_test_assert( status == EINVAL ); /* invalid sched_ss_low_priority error */ @@ -120,7 +98,7 @@ void *POSIX_Init( rtems_test_assert( !status ); puts( "Init: pthread_create - EINVAL (invalid sched_ss_low_priority)" ); - status = pthread_create( &Task_id, &attr, Task_1, NULL ); + status = pthread_create( &thread, &attr, sporadic_server, NULL ); rtems_test_assert( status == EINVAL ); /* create a thread as a sporadic server */ @@ -137,11 +115,11 @@ void *POSIX_Init( rtems_test_assert( !status ); puts( "Init: pthread_create - SUCCESSFUL" ); - status = pthread_create( &Task_id, &attr, Task_1, NULL ); + status = pthread_create( &thread, &attr, sporadic_server, NULL ); rtems_test_assert( !status ); - status = pthread_join( Task_id, NULL ); - rtems_test_assert( status ); + status = pthread_join( thread, NULL ); + rtems_test_assert( !status ); /* switch to Task_1 */ @@ -150,3 +128,16 @@ void *POSIX_Init( return NULL; /* just so the compiler thinks we returned something */ } + +#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER +#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER + +#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION + +#define CONFIGURE_MAXIMUM_POSIX_THREADS 2 + +#define CONFIGURE_POSIX_INIT_THREAD_TABLE + +#define CONFIGURE_INIT + +#include diff --git a/testsuites/psxtests/psx12/psx12.scn b/testsuites/psxtests/psx12/psx12.scn index e35bdab6ae..1e3c04660d 100644 --- a/testsuites/psxtests/psx12/psx12.scn +++ b/testsuites/psxtests/psx12/psx12.scn @@ -1,11 +1,11 @@ -*** POSIX TEST 12 *** +*** BEGIN OF TEST PSX 12 *** Init's ID is 0x0b010001 Init: pthread_attr_init - SUCCESSFUL Init: pthread_create - EINVAL (invalid scheduling policy) Init: pthread_attr_init - SUCCESSFUL Init: set scheduling parameter attributes for sporadic server Init: pthread_create - EINVAL (replenish < budget) -Init: pthread_create - EINVAL (invalid ss_low_priority) +Init: pthread_create - EINVAL (invalid sched_ss_low_priority) Init: pthread_create - SUCCESSFUL -Task_1: exitting -*** END OF POSIX TEST 12 *** +Sporadic Server: exitting +*** END OF TEST PSX 12 *** diff --git a/testsuites/psxtests/psx12/system.h b/testsuites/psxtests/psx12/system.h deleted file mode 100644 index 9aa786ebd2..0000000000 --- a/testsuites/psxtests/psx12/system.h +++ /dev/null @@ -1,52 +0,0 @@ -/* system.h - * - * This include file contains information that is included in every - * function in the test set. - * - * COPYRIGHT (c) 1989-1999. - * 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. - */ - -/* functions */ - -#include - -void *POSIX_Init( - void *argument -); - -void *Task_1( - void *argument -); - -/* configuration information */ - -#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER -#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER - -#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION - -#define CONFIGURE_MAXIMUM_POSIX_THREADS 2 -#define CONFIGURE_MAXIMUM_POSIX_KEYS 10 -#define CONFIGURE_MAXIMUM_POSIX_MUTEXES 10 - -#define CONFIGURE_POSIX_INIT_THREAD_TABLE - -#include - -/* global variables */ - -#ifdef CONFIGURE_INIT -#define TEST_EXTERN -#else -#define TEST_EXTERN extern -#endif - -TEST_EXTERN pthread_t Init_id; -TEST_EXTERN pthread_t Task_id; - -/* end of include file */ diff --git a/testsuites/psxtests/psx12/task.c b/testsuites/psxtests/psx12/task.c deleted file mode 100644 index 0a288d4afd..0000000000 --- a/testsuites/psxtests/psx12/task.c +++ /dev/null @@ -1,40 +0,0 @@ -/* Task_1 - * - * This routine serves as a test task. It verifies the basic task - * switching capabilities of the executive. - * - * Input parameters: - * argument - task argument - * - * Output parameters: NONE - * - * COPYRIGHT (c) 1989-1999. - * 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 "system.h" -#include -#include - -void *Task_1( - void *argument -) -{ - /* - * Detach ourselves so we don't wait for a join that won't happen. - */ - pthread_detach( pthread_self() ); - - puts( "Task_1: exitting" ); - pthread_exit( NULL ); - - return NULL; /* just so the compiler thinks we returned something */ -} -- cgit v1.2.3