From 6baf5a5bc318a8eac731dc538393f1093aca45ef Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Mon, 4 Oct 2010 15:53:45 +0000 Subject: 2010-10-04 Joel Sherrill * Makefile.am, configure.ac, psx07/init.c, psx07/psx07.scn, psxhdrs/Makefile.am, psxstack01/init.c: Add pthread_attr_getstack, pthread_attr_setstack, pthread_attr_getguardsize, and pthread_attr_setguardsize. * psxstack02/.cvsignore, psxstack02/Makefile.am, psxstack02/init.c, psxstack02/psxstack02.doc, psxstack02/psxstack02.scn: New files. --- testsuites/psxtests/ChangeLog | 9 +++ testsuites/psxtests/Makefile.am | 2 +- testsuites/psxtests/configure.ac | 17 +++++ testsuites/psxtests/psx07/init.c | 89 ++++++++++++++++++++++- testsuites/psxtests/psx07/psx07.scn | 31 ++++++-- testsuites/psxtests/psxhdrs/Makefile.am | 1 + testsuites/psxtests/psxstack01/init.c | 2 +- testsuites/psxtests/psxstack02/.cvsignore | 2 + testsuites/psxtests/psxstack02/Makefile.am | 25 +++++++ testsuites/psxtests/psxstack02/init.c | 100 ++++++++++++++++++++++++++ testsuites/psxtests/psxstack02/psxstack02.doc | 23 ++++++ testsuites/psxtests/psxstack02/psxstack02.scn | 7 ++ 12 files changed, 297 insertions(+), 11 deletions(-) create mode 100644 testsuites/psxtests/psxstack02/.cvsignore create mode 100644 testsuites/psxtests/psxstack02/Makefile.am create mode 100644 testsuites/psxtests/psxstack02/init.c create mode 100644 testsuites/psxtests/psxstack02/psxstack02.doc create mode 100644 testsuites/psxtests/psxstack02/psxstack02.scn (limited to 'testsuites') diff --git a/testsuites/psxtests/ChangeLog b/testsuites/psxtests/ChangeLog index 5c79b86d80..aa13068f2e 100644 --- a/testsuites/psxtests/ChangeLog +++ b/testsuites/psxtests/ChangeLog @@ -1,3 +1,12 @@ +2010-10-04 Joel Sherrill + + * Makefile.am, configure.ac, psx07/init.c, psx07/psx07.scn, + psxhdrs/Makefile.am, psxstack01/init.c: Add pthread_attr_getstack, + pthread_attr_setstack, pthread_attr_getguardsize, and + pthread_attr_setguardsize. + * psxstack02/.cvsignore, psxstack02/Makefile.am, psxstack02/init.c, + psxstack02/psxstack02.doc, psxstack02/psxstack02.scn: New files. + 2010-10-01 Ralf Corsépius * configure.ac: Check for pthread_attr_{get,set}cputime instead of diff --git a/testsuites/psxtests/Makefile.am b/testsuites/psxtests/Makefile.am index b66d4fd19b..acec97dbf9 100644 --- a/testsuites/psxtests/Makefile.am +++ b/testsuites/psxtests/Makefile.am @@ -15,7 +15,7 @@ SUBDIRS += psxhdrs psx01 psx02 psx03 psx04 psx05 psx06 psx07 psx08 psx09 \ psxmutexattr01 psxobj01 psxrwlock01 psxsem01 psxsignal01 psxsignal02 \ psxsignal03 psxsignal04 psxsignal05 psxspin01 psxspin02 psxsysconf \ psxtime psxtimer01 psxtimer02 psxualarm psxusleep psxfatal01 psxfatal02 \ - psxintrcritical01 psxstack01 + psxintrcritical01 psxstack01 psxstack02 endif ## File IO tests diff --git a/testsuites/psxtests/configure.ac b/testsuites/psxtests/configure.ac index 48790591a5..756c07365d 100644 --- a/testsuites/psxtests/configure.ac +++ b/testsuites/psxtests/configure.ac @@ -41,10 +41,26 @@ AC_CHECK_DECLS([pthread_atfork],[],[],[[#include ]]) # Likely an anachronism in RTEMS. AC_CHECK_DECLS([pthread_attr_getcputime],[],[],[[#include ]]) +# FIXME: RTEMS presumes pthread_attr_getcputime to be IEEE Std 1003.1 +# Likely an anachronism in RTEMS. +AC_CHECK_DECLS([pthread_attr_getcputime],[],[],[[#include ]]) + # FIXME: RTEMS presumes pthread_attr_setcputime to be IEEE Std 1003.1 # Likely an anachronism in RTEMS. AC_CHECK_DECLS([pthread_attr_setcputime],[],[],[[#include ]]) +# Added to pthreads after initial revision. May not be in toolset +AC_CHECK_DECLS([pthread_attr_getstack],[],[],[[#include ]]) + +# Added to pthreads after initial revision. May not be in toolset +AC_CHECK_DECLS([pthread_attr_setstack],[],[],[[#include ]]) + +# Added to pthreads after initial revision. May not be in toolset +AC_CHECK_DECLS([pthread_attr_getguardsize],[],[],[[#include ]]) + +# Added to pthreads after initial revision. May not be in toolset +AC_CHECK_DECLS([pthread_attr_setguardsize],[],[],[[#include ]]) + # FIXME: adjtime is a non-standardized BSD/Linux extension # RTEMS should not rely on adjtime AC_CHECK_DECLS([adjtime],[],[],[[#include ]]) @@ -129,6 +145,7 @@ psxsignal05/Makefile psxspin01/Makefile psxspin02/Makefile psxstack01/Makefile +psxstack02/Makefile psxstat/Makefile psxsysconf/Makefile psxtime/Makefile diff --git a/testsuites/psxtests/psx07/init.c b/testsuites/psxtests/psx07/init.c index 73719ddbba..6533f208ba 100644 --- a/testsuites/psxtests/psx07/init.c +++ b/testsuites/psxtests/psx07/init.c @@ -63,6 +63,7 @@ void *POSIX_Init( int inheritsched; int schedpolicy; size_t stacksize; + size_t guardsize; void *stackaddr; int detachstate; struct sched_param schedparam; @@ -127,10 +128,12 @@ void *POSIX_Init( status = pthread_attr_init( &attr ); posix_service_failed( status, "pthread_attr_init"); +#if HAVE_DECL_PTHREAD_ATTR_SETSTACKADDR attr.stacksize = rtems_configuration_get_work_space_size() * 10; puts( "Init - pthread_create - EAGAIN (stacksize too large)" ); status = pthread_create( &Task_id, &attr, Task_1, NULL ); fatal_directive_check_status_only( status, EAGAIN, "stacksize too large" ); +#endif status = pthread_attr_init( &attr ); posix_service_failed( status, "pthread_attr_init"); @@ -373,7 +376,6 @@ void *POSIX_Init( printf( "Init - current stack size attribute is OK\n" ); /* exercise get and set stack address */ - empty_line(); puts( "Init - pthread_attr_setstackaddr - EINVAL (NULL attr)" ); @@ -381,14 +383,14 @@ void *POSIX_Init( fatal_directive_check_status_only( status, EINVAL, "NULL attr" ); puts( "Init - pthread_attr_setstackaddr - EINVAL (not initialized attr)" ); - status = - pthread_attr_setstackaddr( &destroyed_attr, NULL ); + status = pthread_attr_setstackaddr( &destroyed_attr, NULL ); fatal_directive_check_status_only( status, EINVAL, "not initialized attr" ); puts( "Init - pthread_attr_setstackaddr - SUCCESSFUL" ); status = pthread_attr_setstackaddr( &attr, 0 ); posix_service_failed( status, ""); + /* get stack addr */ puts( "Init - pthread_attr_getstackaddr - EINVAL (NULL attr)" ); status = pthread_attr_getstackaddr( NULL, &stackaddr ); fatal_directive_check_status_only( status, EINVAL, "NULL attr" ); @@ -406,8 +408,89 @@ void *POSIX_Init( posix_service_failed( status, "pthread_attr_getstackaddr"); printf( "Init - current stack address attribute = %p\n", stackaddr ); + /* exercise get and set stack (as pair) */ + empty_line(); + +#if HAVE_DECL_PTHREAD_ATTR_SETSTACK + puts( "Init - pthread_attr_setstack- EINVAL (NULL attr)" ); + status = pthread_attr_setstack( NULL, &stackaddr, 1024 ); + fatal_directive_check_status_only( status, EINVAL, "NULL attr" ); + + puts( "Init - pthread_attr_setstack- EINVAL (destroyed attr)" ); + status = pthread_attr_setstack( &destroyed_attr, &stackaddr, 1024 ); + fatal_directive_check_status_only( status, EINVAL, "NULL attr" ); + + puts( "Init - pthread_attr_setstack- SUCCESSFUL (< min stack)" ); + status = pthread_attr_setstack( &attr, stackaddr, 0 ); + posix_service_failed( status, "OK"); + + puts( "Init - pthread_attr_setstack- SUCCESSFUL (big stack)" ); + status = pthread_attr_setstack( &attr, stackaddr, STACK_MINIMUM_SIZE * 2 ); + posix_service_failed( status, "OK"); +#endif + +#if HAVE_DECL_PTHREAD_ATTR_GETSTACK + puts( "Init - pthread_attr_getstack- EINVAL (NULL attr)" ); + status = pthread_attr_getstack( NULL, &stackaddr, &stacksize ); + fatal_directive_check_status_only( status, EINVAL, "NULL attr" ); + + puts( "Init - pthread_attr_getstack- EINVAL (destroyed attr)" ); + status = pthread_attr_getstack( &destroyed_attr, &stackaddr, &stacksize ); + fatal_directive_check_status_only( status, EINVAL, "&destroyed attr" ); + + puts( "Init - pthread_attr_getstack- EINVAL (NULL stack)" ); + status = pthread_attr_getstack( &attr, NULL, &stacksize ); + fatal_directive_check_status_only( status, EINVAL, "&NULL stack" ); + + puts( "Init - pthread_attr_getstack- EINVAL (NULL stacksize)" ); + status = pthread_attr_getstack( &attr, &stackaddr, NULL ); + fatal_directive_check_status_only( status, EINVAL, "&NULL size" ); + + puts( "Init - pthread_attr_getstack- SUCCESSFUL" ); + status = pthread_attr_getstack( &attr, &stackaddr, &stacksize ); + posix_service_failed( status, "pthread_attr_getstack"); +#endif + /* exercise get and set detach state */ + empty_line(); + +#if HAVE_DECL_PTHREAD_ATTR_SETGUARDSIZE + puts( "Init - pthread_attr_setguardsize - EINVAL (NULL attr)" ); + status = pthread_attr_setguardsize( NULL, 0 ); + fatal_directive_check_status_only( status, EINVAL, "NULL attr" ); + + puts( "Init - pthread_attr_setguardsize - EINVAL (not initialized attr)" ); + status = pthread_attr_setguardsize( &destroyed_attr, 0 ); + fatal_directive_check_status_only( status, EINVAL, "not initialized attr" ); + + puts( "Init - pthread_attr_setguardsize - SUCCESSFUL (low guardsize)" ); + status = pthread_attr_setguardsize( &attr, 0 ); + posix_service_failed( status, "pthread_attr_setguardsize"); + + puts( "Init - pthread_attr_setguardsize - SUCCESSFUL (high guardsize)" ); + status = pthread_attr_setguardsize( &attr, STACK_MINIMUM_SIZE * 2 ); + posix_service_failed( status, ""); +#endif + +#if HAVE_DECL_PTHREAD_ATTR_GETGUARDSIZE + puts( "Init - pthread_attr_getguardsize - EINVAL (NULL attr)" ); + status = pthread_attr_getguardsize( NULL, &guardsize ); + fatal_directive_check_status_only( status, EINVAL, "NULL attr" ); + puts( "Init - pthread_attr_getguardsize - EINVAL (NULL guardsize)" ); + status = pthread_attr_getguardsize( &attr, NULL ); + fatal_directive_check_status_only( status, EINVAL, "NULL guardsize" ); + + puts( "Init - pthread_attr_getguardsize - EINVAL (not initialized attr)" ); + status = pthread_attr_getguardsize( &destroyed_attr, &guardsize ); + fatal_directive_check_status_only( status, EINVAL, "not initialized attr" ); + + puts( "Init - pthread_attr_getguardsize - SUCCESSFUL" ); + status = pthread_attr_getguardsize( &attr, &guardsize ); + posix_service_failed( status, "pthread_attr_getguardsize"); +#endif + + /* exercise get and set detach state */ empty_line(); puts( "Init - pthread_attr_setdetachstate - EINVAL (NULL attr)" ); diff --git a/testsuites/psxtests/psx07/psx07.scn b/testsuites/psxtests/psx07/psx07.scn index b66a2fb612..9a21fc3204 100644 --- a/testsuites/psxtests/psx07/psx07.scn +++ b/testsuites/psxtests/psx07/psx07.scn @@ -71,6 +71,25 @@ Init - pthread_attr_getstackaddr - EINVAL (not initialized attr) Init - pthread_attr_getstackaddr - SUCCESSFUL Init - current stack address attribute = 0x0 +Init - pthread_attr_setstack- EINVAL (NULL attr) +Init - pthread_attr_setstack- EINVAL (destroyed attr) +Init - pthread_attr_setstack- SUCCESSFUL (< min stack) +Init - pthread_attr_setstack- SUCCESSFUL (big stack) +Init - pthread_attr_getstack- EINVAL (NULL attr) +Init - pthread_attr_getstack- EINVAL (destroyed attr) +Init - pthread_attr_getstack- EINVAL (NULL stack) +Init - pthread_attr_getstack- EINVAL (NULL stacksize) +Init - pthread_attr_getstack- SUCCESSFUL + +Init - pthread_attr_setguardsize - EINVAL (NULL attr) +Init - pthread_attr_setguardsize - EINVAL (not initialized attr) +Init - pthread_attr_setguardsize - SUCCESSFUL (low guardsize) +Init - pthread_attr_setguardsize - SUCCESSFUL (high guardsize) +Init - pthread_attr_getguardsize - EINVAL (NULL attr) +Init - pthread_attr_getguardsize - EINVAL (NULL guardsize) +Init - pthread_attr_getguardsize - EINVAL (not initialized attr) +Init - pthread_attr_getguardsize - SUCCESSFUL + Init - pthread_attr_setdetachstate - EINVAL (NULL attr) Init - pthread_attr_setdetachstate - EINVAL (not initialized attr) Init - pthread_attr_setdetachstate - EINVAL (invalid detachstate) @@ -83,9 +102,9 @@ Init - current detach state attribute = 1 Init - pthread_attr_getschedparam - SUCCESSFUL Init - sched priority = 2 -Init - ss_low_priority = 0 -Init - ss_replenish_period = (0, 0) -Init - ss_initial_budget = (0, 0) +Init - sched_ss_low_priority = 0 +Init - sched_ss_replenish_period = (0, 0) +Init - sched_sched_ss_initial_budget = (0, 0) Init - pthread_attr_setschedparam - EINVAL (NULL attr) Init - pthread_attr_setschedparam - EINVAL (not initialized attr) Init - pthread_attr_setschedparam - EINVAL (NULL schedparam) @@ -100,9 +119,9 @@ Init - pthread_getschedparam - ESRCH (bad thread) Init - pthread_getschedparam - SUCCESSFUL Init - policy = 1 Init - sched priority = 2 -Init - ss_low_priority = 0 -Init - ss_replenish_period = (0, 0) -Init - ss_initial_budget = (0, 0) +Init - sched_ss_low_priority = 0 +Init - sched_ss_replenish_period = (0, 0) +Init - sched_sched_ss_initial_budget = (0, 0) Init - pthread_setschedparam - EINVAL (NULL schedparam) Init - pthread_setschedparam - EINVAL (invalid priority) diff --git a/testsuites/psxtests/psxhdrs/Makefile.am b/testsuites/psxtests/psxhdrs/Makefile.am index 696fba07d9..b385a0958d 100644 --- a/testsuites/psxtests/psxhdrs/Makefile.am +++ b/testsuites/psxtests/psxhdrs/Makefile.am @@ -14,6 +14,7 @@ lib_a_SOURCES = clock01.c clock02.c clock03.c clock04.c clock05.c clock06.c \ pthread19.c pthread20.c pthread21.c pthread22.c pthread23.c pthread24.c \ pthread25.c pthread26.c pthread27.c pthread28.c pthread29.c pthread30.c \ pthread31.c pthread32.c pthread33.c pthread34.c pthread35.c pthread36.c \ + pthread37.c pthread38.c pthread39.c pthread40.c \ proc01.c proc02.c proc03.c proc04.c proc05.c proc06.c proc07.c proc08.c \ proc09.c proc10.c proc11.c proc12.c proc13.c proc14.c sched01.c \ sched02.c sched03.c sched04.c sched05.c sched06.c sched07.c sched08.c \ diff --git a/testsuites/psxtests/psxstack01/init.c b/testsuites/psxtests/psxstack01/init.c index 0e0ee3b0c5..122d8764e9 100644 --- a/testsuites/psxtests/psxstack01/init.c +++ b/testsuites/psxtests/psxstack01/init.c @@ -55,7 +55,7 @@ void *POSIX_Init( puts( "Init - Allocate stack from heap" ); Stack_Low = malloc(PTHREAD_MINIMUM_STACK_SIZE); - rtems_test_assert( Stack_Low ); + rtems_test_assert( Stack_Low ); Stack_High = Stack_Low + PTHREAD_MINIMUM_STACK_SIZE; puts( "Init - Initialize thread attribute for user provided stack" ); diff --git a/testsuites/psxtests/psxstack02/.cvsignore b/testsuites/psxtests/psxstack02/.cvsignore new file mode 100644 index 0000000000..282522db03 --- /dev/null +++ b/testsuites/psxtests/psxstack02/.cvsignore @@ -0,0 +1,2 @@ +Makefile +Makefile.in diff --git a/testsuites/psxtests/psxstack02/Makefile.am b/testsuites/psxtests/psxstack02/Makefile.am new file mode 100644 index 0000000000..07a47f28c9 --- /dev/null +++ b/testsuites/psxtests/psxstack02/Makefile.am @@ -0,0 +1,25 @@ +## +## $Id$ +## + +rtems_tests_PROGRAMS = psxstack02 +psxstack02_SOURCES = init.c + +dist_rtems_tests_DATA = psxstack02.scn +dist_rtems_tests_DATA += psxstack02.doc + +include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP@.cfg +include $(top_srcdir)/../automake/compile.am +include $(top_srcdir)/../automake/leaf.am + +AM_CPPFLAGS += -I$(top_srcdir)/include +AM_CPPFLAGS += -I$(top_srcdir)/../support/include + +LINK_OBJS = $(psxstack02_OBJECTS) $(psxstack02_LDADD) +LINK_LIBS = $(psxstack02_LDLIBS) + +psxstack02$(EXEEXT): $(psxstack02_OBJECTS) $(psxstack02_DEPENDENCIES) + @rm -f psxstack02$(EXEEXT) + $(make-exe) + +include $(top_srcdir)/../automake/local.am diff --git a/testsuites/psxtests/psxstack02/init.c b/testsuites/psxtests/psxstack02/init.c new file mode 100644 index 0000000000..a0f2173d74 --- /dev/null +++ b/testsuites/psxtests/psxstack02/init.c @@ -0,0 +1,100 @@ +/* + * 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.com/license/LICENSE. + * + * $Id$ + */ + +#define __RTEMS_VIOLATE_KERNEL_VISIBILITY__ +#include +#include "test_support.h" + +#include +#include +#include + +#include /* for PTHREAD_MINIMUM_STACK_SIZE */ + +void *Stack_Low; +void *Stack_High; + +void *Test_Thread(void *arg) +{ + #if defined(__GNUC__) + void *sp = __builtin_frame_address(0); + + #if 0 + printf( "Stack(%p - %p) and sp=%p\n", Stack_Low, Stack_High, sp ); + #endif + + if ( sp >= Stack_Low && sp <= Stack_High ) + puts( "Test_Thread - running on user provided stack - OK" ); + else { + puts( "Test_Thread - ERROR running on other stack" ); + rtems_test_exit(0); + } + #else + puts( "Test_Thread - no way to get stack pointer and verify" ); + #endif + puts( "Test_Thread - delete self" ); + return NULL; +} + +void *POSIX_Init( + rtems_task_argument argument +) +{ +#if HAVE_DECL_PTHREAD_ATTR_SETSTACK + int sc; + pthread_t id; + pthread_attr_t attr; + struct timespec delay_request; + + puts( "\n\n*** POSIX STACK ATTRIBUTE TEST 02 ***" ); + + puts( "Init - Allocate stack from heap" ); + Stack_Low = malloc(PTHREAD_MINIMUM_STACK_SIZE); + rtems_test_assert( Stack_Low ); + Stack_High = Stack_Low + PTHREAD_MINIMUM_STACK_SIZE; + + puts( "Init - Initialize thread attribute for user provided stack" ); + sc = pthread_attr_init( &attr ); + rtems_test_assert( !sc ); + + sc = pthread_attr_setstack( &attr, Stack_Low, PTHREAD_MINIMUM_STACK_SIZE ); + rtems_test_assert( !sc ); + + /* create threads */ + sc = pthread_create( &id, &attr, Test_Thread, NULL ); + rtems_test_assert( !sc ); + + puts( "Init - let other thread run" ); + delay_request.tv_sec = 0; + delay_request.tv_nsec = 5 * 100000000; + sc = nanosleep( &delay_request, NULL ); + rtems_test_assert( !sc ); +#else + puts( "pthread_set_stack not supported - SKIPPING TEST CASE" ); +#endif + + puts( "*** END OF POSIX STACK ATTRIBUTE TEST 02 ***" ); + + rtems_test_exit(0); +} + +/* configuration information */ + +#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER +#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER + +#define CONFIGURE_MAXIMUM_POSIX_THREADS 2 + +#define CONFIGURE_POSIX_INIT_THREAD_TABLE + +#define CONFIGURE_INIT +#include +/* end of file */ diff --git a/testsuites/psxtests/psxstack02/psxstack02.doc b/testsuites/psxtests/psxstack02/psxstack02.doc new file mode 100644 index 0000000000..76da6ba17a --- /dev/null +++ b/testsuites/psxtests/psxstack02/psxstack02.doc @@ -0,0 +1,23 @@ +# +# $Id$ +# +# 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.com/license/LICENSE. +# + +This file describes the directives and concepts tested by this test set. + +test set name: psxstack02 + +directives: + + pthread_attr_setstack + +concepts: + ++ This test exercises the ability to assign a user specified stack location +to a POSIX thread. diff --git a/testsuites/psxtests/psxstack02/psxstack02.scn b/testsuites/psxtests/psxstack02/psxstack02.scn new file mode 100644 index 0000000000..c25364dc51 --- /dev/null +++ b/testsuites/psxtests/psxstack02/psxstack02.scn @@ -0,0 +1,7 @@ +*** POSIX STACK ATTRIBUTE TEST 02 *** +Init - Allocate stack from heap +Init - Initialize thread attribute for user provided stack +Init - let other thread run +Test_Thread - running on user provided stack - OK +Test_Thread - delete self +*** END OF POSIX STACK ATTRIBUTE TEST 02 *** -- cgit v1.2.3