[rtems commit] psxtests/psx12: Use one file and simplify
Sebastian Huber
sebh at rtems.org
Wed Jun 15 08:45:52 UTC 2016
Module: rtems
Branch: master
Commit: d6467102e2c2af2c0cacd1366d0922f5f4481ac1
Changeset: http://git.rtems.org/rtems/commit/?id=d6467102e2c2af2c0cacd1366d0922f5f4481ac1
Author: Sebastian Huber <sebastian.huber at embedded-brains.de>
Date: Wed Jun 15 09:04:29 2016 +0200
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(-)
diff --git a/testsuites/psxtests/psx12/Makefile.am b/testsuites/psxtests/psx12/Makefile.am
index fedd135..c632530 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 410a141..46be818 100644
--- a/testsuites/psxtests/psx12/init.c
+++ b/testsuites/psxtests/psx12/init.c
@@ -12,45 +12,24 @@
#endif
#include <sched.h>
-
-#define CONFIGURE_INIT
-#include "system.h"
#include <errno.h>
-#include "pritime.h"
-const char rtems_test_name[] = "PSX 12";
+#include <pmacros.h>
-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 <rtems/confdefs.h>
diff --git a/testsuites/psxtests/psx12/psx12.scn b/testsuites/psxtests/psx12/psx12.scn
index e35bdab..1e3c046 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 9aa786e..0000000
--- 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 <pmacros.h>
-
-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 <rtems/confdefs.h>
-
-/* 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 0a288d4..0000000
--- 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 <time.h>
-#include <sched.h>
-
-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 */
-}
More information about the vc
mailing list