From 13adea03e0766f2c659ecf2cb3a6eb252ad551d6 Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Fri, 9 Aug 1996 19:55:04 +0000 Subject: added test cases for EINVAL cases in pthread_mutexattr_destroy --- testsuites/psxtests/psx05/init.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'testsuites/psxtests/psx05') diff --git a/testsuites/psxtests/psx05/init.c b/testsuites/psxtests/psx05/init.c index a6f25fd42b..0171ed9f46 100644 --- a/testsuites/psxtests/psx05/init.c +++ b/testsuites/psxtests/psx05/init.c @@ -77,6 +77,7 @@ void *POSIX_Init( { int status; pthread_mutexattr_t attr; + pthread_mutexattr_t destroyed_attr; struct timespec times; struct sched_param param; int policy; @@ -94,7 +95,7 @@ void *POSIX_Init( Init_id = pthread_self(); printf( "Init's ID is 0x%08x\n", Init_id ); - /* basic checkout of mutex attributes */ + /* tes pthread_mutex_attr_init */ puts( "Init: pthread_mutexattr_init - EINVAL (NULL attr)" ); status = pthread_mutexattr_init( NULL ); @@ -106,6 +107,25 @@ void *POSIX_Init( Print_mutexattr( "Init: ", &attr ); + /* create an "uninitialized" attribute structure */ + + status = pthread_mutexattr_init( &destroyed_attr ); + assert( !status ); + + puts( "Init: pthread_mutexattr_destroy - SUCCESSFUL" ); + status = pthread_mutexattr_destroy( &destroyed_attr ); + assert( !status ); + + puts( "Init: pthread_mutexattr_destroy - EINVAL (NULL attr)" ); + status = pthread_mutexattr_destroy( NULL ); + assert( status == EINVAL ); + + puts( "Init: pthread_mutexattr_destroy - EINVAL (not initialized)" ); + status = pthread_mutexattr_destroy( &destroyed_attr ); + assert( status == EINVAL ); + + /* change the attributes structure */ + puts( "Init: Changing mutex attributes" ); status = pthread_mutexattr_setprotocol( &attr, PTHREAD_PRIO_INHERIT ); assert( !status ); -- cgit v1.2.3