File indexing completed on 2025-05-11 08:24:39
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
0030 #ifdef HAVE_CONFIG_H
0031 #include "config.h"
0032 #endif
0033
0034 #include <pthread.h>
0035 #include <errno.h>
0036 #include "tmacros.h"
0037 #include "pmacros.h"
0038
0039 const char rtems_test_name[] = "PSXKEY 5";
0040
0041
0042 rtems_task Init( rtems_task_argument ignored );
0043
0044 rtems_task Init( rtems_task_argument ignored )
0045 {
0046 pthread_key_t key1, key2;
0047 int sc, *value;
0048 int Data_array[2] = {1, 2};
0049
0050 TEST_BEGIN();
0051
0052 puts( "Init - pthread key1 create - OK" );
0053 sc = pthread_key_create( &key1, NULL );
0054 rtems_test_assert( !sc );
0055
0056 puts( "Init - pthread key2 create - OK" );
0057 sc = pthread_key_create( &key2, NULL );
0058 rtems_test_assert( !sc );
0059
0060 puts( "Init - key1 pthread_setspecific - OK" );
0061 sc = pthread_setspecific( key1, &Data_array[0] );
0062 rtems_test_assert( !sc );
0063
0064 puts( "Init - key2 pthread_setspecific - OK" );
0065 sc = pthread_setspecific( key2, &Data_array[1] );
0066 rtems_test_assert( !sc );
0067
0068 puts( "Init - key1 pthread_getspecific - OK" );
0069 value = pthread_getspecific( key1 );
0070 rtems_test_assert( *value == Data_array[0] );
0071
0072 puts( "Init - key2 pthread_getspecific - OK" );
0073 value = pthread_getspecific( key2 );
0074 rtems_test_assert( *value == Data_array[1] );
0075
0076 puts( "Init - key1 pthread_setspecific - OK" );
0077 sc = pthread_setspecific( key1, &Data_array[1] );
0078 rtems_test_assert( !sc );
0079
0080 puts( "Init - key1 pthread_getspecific - OK" );
0081 value = pthread_getspecific( key1 );
0082 rtems_test_assert( *value == Data_array[1] );
0083
0084 puts( "Init - pthread key1 delete - OK" );
0085 sc = pthread_key_delete( key1 );
0086 rtems_test_assert( sc == 0 );
0087
0088 puts( "Init - pthread key2 delete - OK" );
0089 sc = pthread_key_delete( key2 );
0090 rtems_test_assert( sc == 0 );
0091
0092 TEST_END();
0093 rtems_test_exit(0);
0094 }
0095
0096
0097
0098 #define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER
0099 #define CONFIGURE_APPLICATION_DOES_NOT_NEED_CLOCK_DRIVER
0100
0101 #define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
0102
0103 #define CONFIGURE_MAXIMUM_TASKS 1
0104 #define CONFIGURE_MAXIMUM_POSIX_KEYS 2
0105
0106 #define CONFIGURE_RTEMS_INIT_TASKS_TABLE
0107
0108
0109 #define CONFIGURE_INIT
0110 #include <rtems/confdefs.h>
0111
0112