diff options
author | Joel Sherrill <joel.sherrill@OARcorp.com> | 2009-07-20 01:12:25 +0000 |
---|---|---|
committer | Joel Sherrill <joel.sherrill@OARcorp.com> | 2009-07-20 01:12:25 +0000 |
commit | 1938cc07dfb66d4192083ad0c91a9ae57c3b4a6c (patch) | |
tree | e65f002c53708aa203ef85c140eb5f5bacee9aef /testsuites | |
parent | 2009-07-19 Joel Sherrill <joel.sherrill@oarcorp.com> (diff) | |
download | rtems-1938cc07dfb66d4192083ad0c91a9ae57c3b4a6c.tar.bz2 |
2009-07-19 Joel Sherrill <joel.sherrill@oarcorp.com>
* Makefile.am, configure.ac: Add psxspin02 to exercise case where
trylock is unable to obtain the spinlock and that attempting to
unlock a spinlock from a thread which did not lock it works as
expected.
* psxspin02/.cvsignore, psxspin02/Makefile.am, psxspin02/main.c,
psxspin02/psxspin02.doc, psxspin02/psxspin02.scn, psxspin02/test.c:
New files.
Diffstat (limited to 'testsuites')
-rw-r--r-- | testsuites/psxtests/ChangeLog | 10 | ||||
-rw-r--r-- | testsuites/psxtests/Makefile.am | 4 | ||||
-rw-r--r-- | testsuites/psxtests/configure.ac | 1 | ||||
-rw-r--r-- | testsuites/psxtests/psxspin02/.cvsignore | 2 | ||||
-rw-r--r-- | testsuites/psxtests/psxspin02/Makefile.am | 30 | ||||
-rw-r--r-- | testsuites/psxtests/psxspin02/main.c | 49 | ||||
-rw-r--r-- | testsuites/psxtests/psxspin02/psxspin02.doc | 28 | ||||
-rw-r--r-- | testsuites/psxtests/psxspin02/psxspin02.scn | 8 | ||||
-rw-r--r-- | testsuites/psxtests/psxspin02/test.c | 101 |
9 files changed, 231 insertions, 2 deletions
diff --git a/testsuites/psxtests/ChangeLog b/testsuites/psxtests/ChangeLog index 34ef9215b5..d237421f62 100644 --- a/testsuites/psxtests/ChangeLog +++ b/testsuites/psxtests/ChangeLog @@ -1,5 +1,15 @@ 2009-07-19 Joel Sherrill <joel.sherrill@oarcorp.com> + * Makefile.am, configure.ac: Add psxspin02 to exercise case where + trylock is unable to obtain the spinlock and that attempting to + unlock a spinlock from a thread which did not lock it works as + expected. + * psxspin02/.cvsignore, psxspin02/Makefile.am, psxspin02/main.c, + psxspin02/psxspin02.doc, psxspin02/psxspin02.scn, psxspin02/test.c: + New files. + +2009-07-19 Joel Sherrill <joel.sherrill@oarcorp.com> + * psxspin01/test.c: Remove unnecessary defines. 2009-07-19 Joel Sherrill <joel.sherrill@oarcorp.com> diff --git a/testsuites/psxtests/Makefile.am b/testsuites/psxtests/Makefile.am index 2c94e8e264..3e93499b3d 100644 --- a/testsuites/psxtests/Makefile.am +++ b/testsuites/psxtests/Makefile.am @@ -8,8 +8,8 @@ SUBDIRS = psxhdrs psx01 psx02 psx03 psx04 psx05 psx06 psx07 psx08 psx09 \ psx10 psx11 psx12 psx13 psx14 psxautoinit01 psxautoinit02 psxbarrier01 \ psxcancel psxcleanup psxenosys psxfatal01 psxfatal02 psxkey01 psxitimer \ psxmsgq01 psxmsgq02 psxmsgq03 psxmutexattr01 psxobj01 psxrwlock01 \ - psxsem01 psxsignal01 psxspin01 psxsysconf psxtime psxtimer01 psxtimer02 \ - psxualarm + psxsem01 psxsignal01 psxspin01 psxspin02 psxsysconf psxtime psxtimer01 \ + psxtimer02 psxualarm ## File IO tests SUBDIRS += psxfile01 psxreaddir psxstat psxmount psx13 psxchroot01 diff --git a/testsuites/psxtests/configure.ac b/testsuites/psxtests/configure.ac index a0515e4908..b00b552215 100644 --- a/testsuites/psxtests/configure.ac +++ b/testsuites/psxtests/configure.ac @@ -65,6 +65,7 @@ psxrwlock01/Makefile psxsem01/Makefile psxsignal01/Makefile psxspin01/Makefile +psxspin02/Makefile psxstat/Makefile psxsysconf/Makefile psxtime/Makefile diff --git a/testsuites/psxtests/psxspin02/.cvsignore b/testsuites/psxtests/psxspin02/.cvsignore new file mode 100644 index 0000000000..282522db03 --- /dev/null +++ b/testsuites/psxtests/psxspin02/.cvsignore @@ -0,0 +1,2 @@ +Makefile +Makefile.in diff --git a/testsuites/psxtests/psxspin02/Makefile.am b/testsuites/psxtests/psxspin02/Makefile.am new file mode 100644 index 0000000000..4eeae611d5 --- /dev/null +++ b/testsuites/psxtests/psxspin02/Makefile.am @@ -0,0 +1,30 @@ +## +## $Id$ +## + +MANAGERS = all + +rtems_tests_PROGRAMS = psxspin02 +psxspin02_SOURCES = main.c test.c ../include/pmacros.h + +scndir = $(rtems_testsdir) +dist_scn_DATA = psxspin02.scn + +include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP@.cfg +include $(top_srcdir)/../automake/compile.am +include $(top_srcdir)/../automake/leaf.am + +psxspin02_LDADD = $(MANAGERS_NOT_WANTED:%=$(PROJECT_LIB)/no-%.rel) + +AM_CPPFLAGS += -I$(top_srcdir)/include +AM_CPPFLAGS += -I$(top_srcdir)/../support/include + +LINK_OBJS = $(psxspin02_OBJECTS) $(psxspin02_LDADD) +LINK_LIBS = $(psxspin02_LDLIBS) + +psxspin02$(EXEEXT): $(psxspin02_OBJECTS) \ + $(psxspin02_DEPENDENCIES) + @rm -f psxspin02$(EXEEXT) + $(make-exe) + +include $(top_srcdir)/../automake/local.am diff --git a/testsuites/psxtests/psxspin02/main.c b/testsuites/psxtests/psxspin02/main.c new file mode 100644 index 0000000000..cf5498a413 --- /dev/null +++ b/testsuites/psxtests/psxspin02/main.c @@ -0,0 +1,49 @@ +/* + * Simple test program wrapper for Spinlocks + * + * COPYRIGHT (c) 1989-2008. + * 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 CONFIGURE_INIT + +#include <bsp.h> +#include <pmacros.h> + +void test_main( void ); + +rtems_task Init( + rtems_task_argument ignored +) +{ + test_main(); + rtems_test_exit( 0 ); +} + +/* configuration information */ + +#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER +#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER + +#define CONFIGURE_MAXIMUM_TASKS 2 + +#define CONFIGURE_MAXIMUM_POSIX_SPINLOCKS 1 + +#define CONFIGURE_RTEMS_INIT_TASKS_TABLE +#define CONFIGURE_INIT_TASK_STACK_SIZE (RTEMS_MINIMUM_STACK_SIZE * 2) +#define CONFIGURE_INIT_TASK_PRIORITY 2 +#define CONFIGURE_INIT_TASK_INITIAL_MODES RTEMS_PREEMPT + +#define CONFIGURE_EXTRA_TASK_STACKS RTEMS_MINIMUM_STACK_SIZE + +#define CONFIGURE_INIT + +#include <rtems/confdefs.h> + +/* end of file */ diff --git a/testsuites/psxtests/psxspin02/psxspin02.doc b/testsuites/psxtests/psxspin02/psxspin02.doc new file mode 100644 index 0000000000..bcefba6530 --- /dev/null +++ b/testsuites/psxtests/psxspin02/psxspin02.doc @@ -0,0 +1,28 @@ +# +# $Id$ +# +# COPYRIGHT (c) 1989-2009. +# 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: psxspin02 + +directives: + + pthread_spin_lock + pthread_spin_trylock + pthread_spin_unlock + +concepts: + ++ Ensure that attempting to obtain a locked spin lock with + pthread_spin_trylock returns the correct error. + ++ Ensure that attempting to release a locked spin lock from a thread which + did not lock it returns the correct error. diff --git a/testsuites/psxtests/psxspin02/psxspin02.scn b/testsuites/psxtests/psxspin02/psxspin02.scn new file mode 100644 index 0000000000..8e71ca6e1b --- /dev/null +++ b/testsuites/psxtests/psxspin02/psxspin02.scn @@ -0,0 +1,8 @@ +*** POSIX SPINLOCK TEST 02 *** +pthread_spin_init( &Spinlock, PTHREAD_PROCESS_PRIVATE ) -- OK +pthread_spin_lock( &Spinlock ) -- OK +pthread_spin_trylock( &Spinlock ) -- EBUSY +pthread_spin_unlock( &Spinlock ) -- EPERM +pthread_spin_unlock( &Spinlock ) -- OK +pthread_spin_destroy( &Spinlock ) -- OK +*** END OF POSIX SPINLOCK TEST 02 *** diff --git a/testsuites/psxtests/psxspin02/test.c b/testsuites/psxtests/psxspin02/test.c new file mode 100644 index 0000000000..df71b8e795 --- /dev/null +++ b/testsuites/psxtests/psxspin02/test.c @@ -0,0 +1,101 @@ +/* + * This test exercises the POSIX Spinlock manager. + * + * COPYRIGHT (c) 1989-2006. + * 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$ + */ + +#include <assert.h> +#include <stdio.h> +#include <errno.h> +#include <stdlib.h> + +#include <pthread.h> + +#include <rtems.h> /* for task creation */ + +pthread_spinlock_t Spinlock; + +rtems_task SpinlockThread(rtems_task_argument arg) +{ + int status; + + puts( "pthread_spin_trylock( &Spinlock ) -- EBUSY" ); + status = pthread_spin_trylock( &Spinlock ); + assert( status == EBUSY ); + + puts( "pthread_spin_unlock( &Spinlock ) -- EPERM" ); + status = pthread_spin_unlock( &Spinlock ); + assert( status == EPERM ); + + rtems_task_delete( RTEMS_SELF ); +} + +/* + * main entry point to the test + */ + +#if defined(__rtems__) +int test_main(void) +#else +int main( + int argc, + char **argv +) +#endif +{ + pthread_spinlock_t spinlock; + pthread_spinlock_t spinlockExtra; + int status; + int p; + pthread_t thread_id; + int i; + rtems_status_code rstatus; + rtems_id taskid; + + puts( "\n\n*** POSIX SPINLOCK TEST 02 ***" ); + + /* This successfully creates one */ + puts( "pthread_spin_init( &Spinlock, PTHREAD_PROCESS_PRIVATE ) -- OK" ); + status = pthread_spin_init( &Spinlock, PTHREAD_PROCESS_PRIVATE ); + assert( status == 0 ); + + /* Lock it */ + puts( "pthread_spin_lock( &Spinlock ) -- OK" ); + status = pthread_spin_lock( &Spinlock ); + assert( status == 0 ); + + /* Create a helper task */ + rstatus = rtems_task_create( + rtems_build_name( 'S', 'P', 'I', 'N' ), + 1, + RTEMS_MINIMUM_STACK_SIZE, + RTEMS_DEFAULT_MODES, + RTEMS_DEFAULT_ATTRIBUTES, + &taskid + ); + assert( rstatus == RTEMS_SUCCESSFUL ); + + rstatus = rtems_task_start( taskid, SpinlockThread, 0 ); + assert( rstatus == RTEMS_SUCCESSFUL ); + + sleep(1); + + puts( "pthread_spin_unlock( &Spinlock ) -- OK" ); + status = pthread_spin_unlock( &Spinlock ); + assert( status == 0 ); + + puts( "pthread_spin_destroy( &Spinlock ) -- OK" ); + status = pthread_spin_destroy( &Spinlock ); + assert( status == 0 ); + + /*************** END OF TEST *****************/ + puts( "*** END OF POSIX SPINLOCK TEST 02 ***" ); + exit(0); +} |