File indexing completed on 2025-05-11 08:24:36
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029 #ifdef HAVE_CONFIG_H
0030 #include "config.h"
0031 #endif
0032
0033 #define CONFIGURE_INIT
0034 #include "system.h"
0035 #include <errno.h>
0036
0037 const char rtems_test_name[] = "PSX 6";
0038
0039 extern void Key_destructor( void *key_data );
0040
0041 void Key_destructor(
0042 void *key_data
0043 )
0044 {
0045 Destructor_invoked++;
0046
0047
0048
0049
0050
0051
0052 if ( Destructor_invoked == 5 )
0053 (void) pthread_setspecific( Key_id, NULL );
0054 }
0055
0056 void *POSIX_Init(
0057 void *argument
0058 )
0059 {
0060 int status;
0061 unsigned int remaining;
0062 uint32_t *key_data;
0063
0064 TEST_BEGIN();
0065
0066
0067
0068 set_time( TM_FRIDAY, TM_MAY, 24, 96, 11, 5, 0 );
0069
0070
0071
0072 Init_id = pthread_self();
0073 printf( "Init's ID is 0x%08" PRIxpthread_t "\n", Init_id );
0074
0075
0076
0077 status = pthread_create( &Task_id, NULL, Task_1, NULL );
0078 rtems_test_assert( !status );
0079
0080 status = pthread_create( &Task2_id, NULL, Task_2, NULL );
0081 rtems_test_assert( !status );
0082
0083
0084
0085 empty_line();
0086
0087 Destructor_invoked = 0;
0088 puts( "Init: pthread_key_create - SUCCESSFUL" );
0089 status = pthread_key_create( &Key_id, Key_destructor );
0090 if ( status )
0091 printf( "status = %d\n", status );
0092 rtems_test_assert( !status );
0093
0094 printf( "Destructor invoked %d times\n", Destructor_invoked );
0095
0096 puts( "Init: pthread_key_create - EAGAIN (too many keys)" );
0097 status = pthread_key_create( &Key_id, Key_destructor );
0098 rtems_test_assert( status == EAGAIN );
0099
0100 puts( "Init: pthread_setspecific - EINVAL (invalid key)" );
0101 status = pthread_setspecific( (pthread_t) -1, &Data_array[ 0 ] );
0102 rtems_test_assert( status == EINVAL );
0103
0104 puts( "Init: pthread_getspecific - EINVAL (invalid key)" );
0105 key_data = pthread_getspecific( (pthread_t) -1 );
0106 rtems_test_assert( !key_data );
0107
0108 puts( "Init: pthread_key_delete - EINVAL (invalid key)" );
0109 status = pthread_key_delete( (pthread_t) -1 );
0110 rtems_test_assert( status == EINVAL );
0111
0112 printf( "Init: Setting the key to %d\n", 0 );
0113 status = pthread_setspecific( Key_id, &Data_array[ 0 ] );
0114 if ( status )
0115 printf( "status = %d\n", status );
0116 rtems_test_assert( !status );
0117
0118
0119
0120 key_data = pthread_getspecific( Key_id );
0121 printf( "Init: Got the key value of %ld\n",
0122 (unsigned long) ((uint32_t *)key_data - Data_array) );
0123
0124 remaining = sleep( 3 );
0125 if ( remaining )
0126 printf( "seconds remaining = %d\n", remaining );
0127 rtems_test_assert( !remaining );
0128
0129
0130
0131
0132
0133 puts( "Init: pthread_key_delete - SUCCESSFUL" );
0134 status = pthread_key_delete( Key_id );
0135 if ( status )
0136 printf( "status = %d\n", status );
0137 rtems_test_assert( !status );
0138
0139 printf( "Destructor invoked %d times\n", Destructor_invoked );
0140
0141 TEST_END();
0142 rtems_test_exit( 0 );
0143
0144 return NULL;
0145 }