summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>2009-07-21 15:07:26 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>2009-07-21 15:07:26 +0000
commit14d3ad4fcfbd04593482254b4371b6630ab4d6a3 (patch)
tree30844c0b61384b7730662419f3a57d86296360c3
parent2009-07-21 Joel Sherrill <joel.sherrill@oarcorp.com> (diff)
downloadrtems-14d3ad4fcfbd04593482254b4371b6630ab4d6a3.tar.bz2
2009-07-21 Joel Sherrill <joel.sherrill@oarcorp.com>
* Makefile.am, configure.ac: Add new test to exercise error case for when a task is blocked on a condition variable with one mutex and another task attempts to block on the same condition variable with another mutex. * psxcond01/.cvsignore, psxcond01/Makefile.am, psxcond01/init.c, psxcond01/psxcond01.doc, psxcond01/psxcond01.scn: New files.
-rw-r--r--testsuites/psxtests/ChangeLog9
-rw-r--r--testsuites/psxtests/Makefile.am8
-rw-r--r--testsuites/psxtests/configure.ac1
-rw-r--r--testsuites/psxtests/psxcond01/.cvsignore2
-rw-r--r--testsuites/psxtests/psxcond01/Makefile.am30
-rw-r--r--testsuites/psxtests/psxcond01/init.c81
-rw-r--r--testsuites/psxtests/psxcond01/psxcond01.doc33
-rw-r--r--testsuites/psxtests/psxcond01/psxcond01.scn9
8 files changed, 169 insertions, 4 deletions
diff --git a/testsuites/psxtests/ChangeLog b/testsuites/psxtests/ChangeLog
index d237421f62..4e57b92c16 100644
--- a/testsuites/psxtests/ChangeLog
+++ b/testsuites/psxtests/ChangeLog
@@ -1,3 +1,12 @@
+2009-07-21 Joel Sherrill <joel.sherrill@oarcorp.com>
+
+ * Makefile.am, configure.ac: Add new test to exercise error case for
+ when a task is blocked on a condition variable with one mutex and
+ another task attempts to block on the same condition variable with
+ another mutex.
+ * psxcond01/.cvsignore, psxcond01/Makefile.am, psxcond01/init.c,
+ psxcond01/psxcond01.doc, psxcond01/psxcond01.scn: New files.
+
2009-07-19 Joel Sherrill <joel.sherrill@oarcorp.com>
* Makefile.am, configure.ac: Add psxspin02 to exercise case where
diff --git a/testsuites/psxtests/Makefile.am b/testsuites/psxtests/Makefile.am
index 3e93499b3d..6e963705de 100644
--- a/testsuites/psxtests/Makefile.am
+++ b/testsuites/psxtests/Makefile.am
@@ -6,10 +6,10 @@ ACLOCAL_AMFLAGS = -I ../aclocal
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 psxspin02 psxsysconf psxtime psxtimer01 \
- psxtimer02 psxualarm
+ psxcancel psxcleanup psxcond01 psxenosys psxfatal01 psxfatal02 psxkey01 \
+ psxitimer psxmsgq01 psxmsgq02 psxmsgq03 psxmutexattr01 psxobj01 \
+ psxrwlock01 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 b00b552215..0d08507faa 100644
--- a/testsuites/psxtests/configure.ac
+++ b/testsuites/psxtests/configure.ac
@@ -46,6 +46,7 @@ psxbarrier01/Makefile
psxcancel/Makefile
psxchroot01/Makefile
psxcleanup/Makefile
+psxcond01/Makefile
psxenosys/Makefile
psxfatal01/Makefile
psxfatal02/Makefile
diff --git a/testsuites/psxtests/psxcond01/.cvsignore b/testsuites/psxtests/psxcond01/.cvsignore
new file mode 100644
index 0000000000..282522db03
--- /dev/null
+++ b/testsuites/psxtests/psxcond01/.cvsignore
@@ -0,0 +1,2 @@
+Makefile
+Makefile.in
diff --git a/testsuites/psxtests/psxcond01/Makefile.am b/testsuites/psxtests/psxcond01/Makefile.am
new file mode 100644
index 0000000000..605e67fa73
--- /dev/null
+++ b/testsuites/psxtests/psxcond01/Makefile.am
@@ -0,0 +1,30 @@
+##
+## $Id$
+##
+
+MANAGERS = all
+
+rtems_tests_PROGRAMS = psxcond01
+psxcond01_SOURCES = init.c ../include/pmacros.h
+
+dist_rtems_tests_DATA = psxcond01.scn
+dist_rtems_tests_DATA += psxcond01.doc
+
+include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP@.cfg
+include $(top_srcdir)/../automake/compile.am
+include $(top_srcdir)/../automake/leaf.am
+
+psxcond01_LDADD = $(MANAGERS_NOT_WANTED:%=$(PROJECT_LIB)/no-%.rel)
+
+AM_CPPFLAGS += -I$(top_srcdir)/include
+AM_CPPFLAGS += -I$(top_srcdir)/../support/include
+
+LINK_OBJS = $(psxcond01_OBJECTS) $(psxcond01_LDADD)
+LINK_LIBS = $(psxcond01_LDLIBS)
+
+psxcond01$(EXEEXT): $(psxcond01_OBJECTS) \
+ $(psxcond01_DEPENDENCIES)
+ @rm -f psxcond01$(EXEEXT)
+ $(make-exe)
+
+include $(top_srcdir)/../automake/local.am
diff --git a/testsuites/psxtests/psxcond01/init.c b/testsuites/psxtests/psxcond01/init.c
new file mode 100644
index 0000000000..29cd1a6e1c
--- /dev/null
+++ b/testsuites/psxtests/psxcond01/init.c
@@ -0,0 +1,81 @@
+/*
+ * 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.
+ *
+ * $Id$
+ */
+
+#include "tmacros.h"
+#include <pthread.h>
+#include <errno.h>
+
+pthread_cond_t Condition;
+pthread_mutex_t Mutex1;
+pthread_mutex_t Mutex2;
+
+void *BlockingThread(
+ void *argument
+)
+{
+ puts( "BlockingThread - pthread_cond_wait on Mutex1 - OK" );
+ (void) pthread_cond_wait( &Condition, &Mutex1 );
+
+ puts( "ERROR - BlockingThread returned from pthread_cond_wait!" );
+ rtems_test_exit( 0 );
+
+ return NULL;
+}
+
+void *POSIX_Init(
+ void *argument
+)
+{
+ int sc;
+ pthread_t Thread;
+
+ puts( "\n\n*** POSIX TEST -- CONDITION VARIABLE 01 ***" );
+
+ puts( "Init - pthread_mutex_init - Mutex1 - OK" );
+ sc = pthread_mutex_init( &Mutex1, NULL );
+ fatal_posix_service_status( sc, 0, "mutex1 create ok" );
+
+ puts( "Init - pthread_mutex_init - Mutex2 - OK" );
+ sc = pthread_mutex_init( &Mutex2, NULL );
+ fatal_posix_service_status( sc, 0, "mutex2 create ok" );
+
+ puts( "Init - pthread_cond_init - Condition - OK" );
+ sc = pthread_cond_init( &Condition, NULL );
+ fatal_posix_service_status( sc, 0, "Condition create ok" );
+
+ puts( "Init - pthread_create - OK" );
+ sc = pthread_create( &Thread, NULL, BlockingThread, NULL );
+ fatal_posix_service_status( sc, 0, "Thread create ok" );
+
+ puts( "Init - sleep to let BlockingThread run" );
+ sleep(1);
+
+ puts( "Init - pthread_cond_wait on Mutex2 - EINVAL" );
+ sc = pthread_cond_wait( &Condition, &Mutex2 );
+ fatal_posix_service_status( sc, EINVAL, "cond_wait EINVAL" );
+
+ puts( "*** END OF POSIX TEST CONDITION VARIABLE 01 ***" );
+ rtems_test_exit( 0 );
+
+ return NULL; /* just so the compiler thinks we returned something */
+}
+
+#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
+#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
+
+#define CONFIGURE_MAXIMUM_POSIX_THREADS 2
+#define CONFIGURE_MAXIMUM_POSIX_MUTEXES 2
+#define CONFIGURE_MAXIMUM_POSIX_CONDITION_VARIABLES 1
+
+#define CONFIGURE_POSIX_INIT_THREAD_TABLE
+
+#define CONFIGURE_INIT
+#include <rtems/confdefs.h>
diff --git a/testsuites/psxtests/psxcond01/psxcond01.doc b/testsuites/psxtests/psxcond01/psxcond01.doc
new file mode 100644
index 0000000000..5438cd4804
--- /dev/null
+++ b/testsuites/psxtests/psxcond01/psxcond01.doc
@@ -0,0 +1,33 @@
+#
+# $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: psxcond01
+
+directives:
+
+ pthread_mutex_init
+ pthread_cond_init
+ pthread_cond_wait
+
+concepts:
+
++ Verify that if a task is waiting on a condition variable and has
+ associated one mutex instance that it is an error for another task
+ to attempt to block on the same condition variable using a different
+ mutex.
+
++ Verify error conditions in pthread_mutexattr_settype
+
++ Verify normal paths through pthread_mutexattr_gettype
+
++ Verify normal paths through pthread_mutexattr_settype
diff --git a/testsuites/psxtests/psxcond01/psxcond01.scn b/testsuites/psxtests/psxcond01/psxcond01.scn
new file mode 100644
index 0000000000..18b434832e
--- /dev/null
+++ b/testsuites/psxtests/psxcond01/psxcond01.scn
@@ -0,0 +1,9 @@
+*** POSIX TEST -- CONDITION VARIABLE 01 ***
+Init - pthread_mutex_init - Mutex1 - OK
+Init - pthread_mutex_init - Mutex2 - OK
+Init - pthread_cond_init - Condition - OK
+Init - pthread_create - OK
+Init - sleep to let BlockingThread run
+BlockingThread - pthread_cond_wait on Mutex1 - OK
+Init - pthread_cond_wait on Mutex2 - EINVAL
+*** END OF POSIX TEST CONDITION VARIABLE 01 ***