From 66dfd0ba6ef17f1635f33082e92dde7f20fd1b13 Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Fri, 9 Aug 1996 17:44:04 +0000 Subject: [PATCH] added test cases for invalid key ids --- c/src/tests/psxtests/psx06/init.c | 18 ++++++++++++++++-- testsuites/psxtests/psx06/init.c | 18 ++++++++++++++++-- 2 files changed, 32 insertions(+), 4 deletions(-) diff --git a/c/src/tests/psxtests/psx06/init.c b/c/src/tests/psxtests/psx06/init.c index c26d51e814..f35bcbb926 100644 --- a/c/src/tests/psxtests/psx06/init.c +++ b/c/src/tests/psxtests/psx06/init.c @@ -61,7 +61,7 @@ void *POSIX_Init( empty_line(); Destructor_invoked = 0; - puts( "Init: Creating a key" ); + puts( "Init: pthread_key_create - SUCCESSFUL" ); status = pthread_key_create( &Key_id, Key_destructor ); if ( status ) printf( "status = %d\n", status ); @@ -69,7 +69,21 @@ void *POSIX_Init( printf( "Destructor invoked %d times\n", Destructor_invoked ); + puts( "Init: pthread_key_create - EAGAIN (too many keys)" ); + status = pthread_key_create( &Key_id, Key_destructor ); + assert( status == EAGAIN ); + puts( "Init: pthread_setspecific - EINVAL (invalid key)" ); + status = pthread_setspecific( -1, &Data_array[ 0 ] ); + assert( status == EINVAL ); + + puts( "Init: pthread_getspecific - EINVAL (invalid key)" ); + key_data = pthread_getspecific( -1 ); + assert( !key_data ); + + puts( "Init: pthread_key_delete - EINVAL (invalid key)" ); + status = pthread_key_delete( -1 ); + assert( status == EINVAL ); printf( "Init: Setting the key to %d\n", 0 ); status = pthread_setspecific( Key_id, &Data_array[ 0 ] ); @@ -92,7 +106,7 @@ void *POSIX_Init( /* delete the key */ - puts( "Init: Deleting a key" ); + puts( "Init: pthread_key_delete - SUCCESSFUL" ); status = pthread_key_delete( Key_id ); if ( status ) printf( "status = %d\n", status ); diff --git a/testsuites/psxtests/psx06/init.c b/testsuites/psxtests/psx06/init.c index c26d51e814..f35bcbb926 100644 --- a/testsuites/psxtests/psx06/init.c +++ b/testsuites/psxtests/psx06/init.c @@ -61,7 +61,7 @@ void *POSIX_Init( empty_line(); Destructor_invoked = 0; - puts( "Init: Creating a key" ); + puts( "Init: pthread_key_create - SUCCESSFUL" ); status = pthread_key_create( &Key_id, Key_destructor ); if ( status ) printf( "status = %d\n", status ); @@ -69,7 +69,21 @@ void *POSIX_Init( printf( "Destructor invoked %d times\n", Destructor_invoked ); + puts( "Init: pthread_key_create - EAGAIN (too many keys)" ); + status = pthread_key_create( &Key_id, Key_destructor ); + assert( status == EAGAIN ); + puts( "Init: pthread_setspecific - EINVAL (invalid key)" ); + status = pthread_setspecific( -1, &Data_array[ 0 ] ); + assert( status == EINVAL ); + + puts( "Init: pthread_getspecific - EINVAL (invalid key)" ); + key_data = pthread_getspecific( -1 ); + assert( !key_data ); + + puts( "Init: pthread_key_delete - EINVAL (invalid key)" ); + status = pthread_key_delete( -1 ); + assert( status == EINVAL ); printf( "Init: Setting the key to %d\n", 0 ); status = pthread_setspecific( Key_id, &Data_array[ 0 ] ); @@ -92,7 +106,7 @@ void *POSIX_Init( /* delete the key */ - puts( "Init: Deleting a key" ); + puts( "Init: pthread_key_delete - SUCCESSFUL" ); status = pthread_key_delete( Key_id ); if ( status ) printf( "status = %d\n", status );