summaryrefslogtreecommitdiffstats
path: root/testsuites/psxtests/psxcond01
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@oarcorp.com>2013-12-10 17:56:22 -0600
committerJoel Sherrill <joel.sherrill@oarcorp.com>2013-12-10 17:56:22 -0600
commit74c15fe6960a0db29d6d0bb1e2e9b4e80d92179a (patch)
treee775f4d3ef22fb5912077426245e50df85667eca /testsuites/psxtests/psxcond01
parentalarm.c: Use _Assert() not assert() (diff)
downloadrtems-74c15fe6960a0db29d6d0bb1e2e9b4e80d92179a.tar.bz2
psxtmcond01: Fix bug where mutex not locked and add EPERM error check
This test formerly had a bug in that it attempted to wait on a condition variable with a Mutex that was not locked. This is undefined by POSIX. But a recent change to match GNU/Linux behavior resulted in finding a bug in the test.
Diffstat (limited to 'testsuites/psxtests/psxcond01')
-rw-r--r--testsuites/psxtests/psxcond01/init.c19
-rw-r--r--testsuites/psxtests/psxcond01/psxcond01.doc4
-rw-r--r--testsuites/psxtests/psxcond01/psxcond01.scn1
3 files changed, 20 insertions, 4 deletions
diff --git a/testsuites/psxtests/psxcond01/init.c b/testsuites/psxtests/psxcond01/init.c
index f87eca2236..ebf65f9694 100644
--- a/testsuites/psxtests/psxcond01/init.c
+++ b/testsuites/psxtests/psxcond01/init.c
@@ -1,5 +1,5 @@
/*
- * COPYRIGHT (c) 1989-2012.
+ * COPYRIGHT (c) 1989-2013.
* On-Line Applications Research Corporation (OAR).
*
* The license and distribution terms for this file may be
@@ -27,10 +27,23 @@ void *BlockingThread(
void *argument
)
{
+ int sc;
+
+ puts( "BlockingThread - pthread_cond_wait with mutex not locked - EPERM" );
+ sc = pthread_cond_wait( &Condition, &Mutex1 );
+ fatal_posix_service_status( sc, EPERM, "mutex1 not locked" );
+
+ sc = pthread_mutex_lock( &Mutex1 );
+ fatal_posix_service_status( sc, 0, "mutex1 lock" );
+
puts( "BlockingThread - pthread_cond_wait on Mutex1 - OK" );
- (void) pthread_cond_wait( &Condition, &Mutex1 );
+ sc = pthread_cond_wait( &Condition, &Mutex1 );
- puts( "ERROR - BlockingThread returned from pthread_cond_wait!" );
+ printf(
+ "ERROR - BlockingThread returned from pthread_cond_wait! (rc=%d/%s)\n",
+ sc,
+ strerror(sc)
+ );
rtems_test_exit( 0 );
return NULL;
diff --git a/testsuites/psxtests/psxcond01/psxcond01.doc b/testsuites/psxtests/psxcond01/psxcond01.doc
index 04c1847678..36642780ee 100644
--- a/testsuites/psxtests/psxcond01/psxcond01.doc
+++ b/testsuites/psxtests/psxcond01/psxcond01.doc
@@ -1,4 +1,4 @@
-# COPYRIGHT (c) 1989-2009.
+# COPYRIGHT (c) 1989-2013.
# On-Line Applications Research Corporation (OAR).
#
# The license and distribution terms for this file may be
@@ -23,6 +23,8 @@ concepts:
to attempt to block on the same condition variable using a different
mutex.
++ Verify EPERM is returned on pthread_cond_wait when mutex is not locked
+
+ Verify error conditions in pthread_mutexattr_settype
+ Verify normal paths through pthread_mutexattr_gettype
diff --git a/testsuites/psxtests/psxcond01/psxcond01.scn b/testsuites/psxtests/psxcond01/psxcond01.scn
index 18b434832e..9e306ccb64 100644
--- a/testsuites/psxtests/psxcond01/psxcond01.scn
+++ b/testsuites/psxtests/psxcond01/psxcond01.scn
@@ -1,6 +1,7 @@
*** POSIX TEST -- CONDITION VARIABLE 01 ***
Init - pthread_mutex_init - Mutex1 - OK
Init - pthread_mutex_init - Mutex2 - OK
+BlockingThread - pthread_cond_wait with mutex not locked - EPERM
Init - pthread_cond_init - Condition - OK
Init - pthread_create - OK
Init - sleep to let BlockingThread run