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.
This commit is contained in:
Joel Sherrill
2009-07-21 15:07:26 +00:00
parent 75eaf66aa1
commit 14d3ad4fcf
8 changed files with 169 additions and 4 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -46,6 +46,7 @@ psxbarrier01/Makefile
psxcancel/Makefile
psxchroot01/Makefile
psxcleanup/Makefile
psxcond01/Makefile
psxenosys/Makefile
psxfatal01/Makefile
psxfatal02/Makefile

View File

@@ -0,0 +1,2 @@
Makefile
Makefile.in

View File

@@ -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

View File

@@ -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>

View File

@@ -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

View File

@@ -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 ***