diff options
author | Joel Sherrill <joel.sherrill@OARcorp.com> | 1996-07-31 17:17:48 +0000 |
---|---|---|
committer | Joel Sherrill <joel.sherrill@OARcorp.com> | 1996-07-31 17:17:48 +0000 |
commit | c65a0cee2f5b34077b7484e46e47e6038a83f9b7 (patch) | |
tree | 79cee7d2df4f68930d0d64dfbbdf03080b3ba782 /testsuites/psxtests/psx06/init.c | |
parent | Fixed default vectors initialization, sigaction which had a redundant (diff) | |
download | rtems-c65a0cee2f5b34077b7484e46e47e6038a83f9b7.tar.bz2 |
added key test
Diffstat (limited to '')
-rw-r--r-- | testsuites/psxtests/psx06/init.c | 105 |
1 files changed, 105 insertions, 0 deletions
diff --git a/testsuites/psxtests/psx06/init.c b/testsuites/psxtests/psx06/init.c new file mode 100644 index 0000000000..84b0caecde --- /dev/null +++ b/testsuites/psxtests/psx06/init.c @@ -0,0 +1,105 @@ +/* + * COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994. + * On-Line Applications Research Corporation (OAR). + * All rights assigned to U.S. Government, 1994. + * + * This material may be reproduced by or for the U.S. Government pursuant + * to the copyright license under the clause at DFARS 252.227-7013. This + * notice must appear in all copies of this file and its derivatives. + * + * $Id$ + */ + +#define CONFIGURE_INIT +#include "system.h" +#include <errno.h> + +void Key_destructor( + void *key_data +) +{ + Destructor_invoked++; + + /* + * This checks out that we only run the destructor multiple times + * when the key data is non null. + */ + + if ( Destructor_invoked == 5 ) + (void) pthread_setspecific( Key_id, NULL ); +} + +void *POSIX_Init( + void *argument +) +{ + int status; + unsigned int remaining; + rtems_unsigned32 *key_data; + + puts( "\n\n*** POSIX TEST 6 ***" ); + + /* set the time of day, and print our buffer in multiple ways */ + + set_time( TM_FRIDAY, TM_MAY, 24, 96, 11, 5, 0 ); + + /* get id of this thread */ + + Init_id = pthread_self(); + printf( "Init's ID is 0x%08x\n", Init_id ); + + /* create a couple of threads */ + + status = pthread_create( &Task_id, NULL, Task_1, NULL ); + assert( !status ); + + status = pthread_create( &Task2_id, NULL, Task_2, NULL ); + assert( !status ); + + /* create a key */ + + empty_line(); + + Destructor_invoked = 0; + printf( "Init: Creating a key\n" ); + status = pthread_key_create( &Key_id, Key_destructor ); + if ( status ) + printf( "status = %d\n", status ); + assert( !status ); + + printf( "Destructor invoked %d times\n", Destructor_invoked ); + + printf( "Init: Setting the key to %d\n", 0 ); + status = pthread_setspecific( Key_id, &Data_array[ 0 ] ); + if ( status ) + printf( "status = %d\n", status ); + assert( !status ); + + /* switch to task 1 */ + + key_data = pthread_getspecific( Key_id ); + printf( "Init: Got the key value of %d\n", + (rtems_unsigned32 *)key_data - Data_array ); + + remaining = sleep( 3 ); + if ( remaining ) + printf( "seconds remaining = %d\n", remaining ); + assert( !remaining ); + + /* switch to task 1 */ + + /* delete the key */ + + printf( "Init: Deleting a key\n" ); + status = pthread_key_delete( Key_id ); + if ( status ) + printf( "status = %d\n", status ); + assert( !status ); + + printf( "Destructor invoked %d times\n", Destructor_invoked ); + + puts( "*** END OF POSIX TEST 6 ***" ); + exit( 0 ); + + return NULL; /* just so the compiler thinks we returned something */ +} |