source: rtems/testsuites/psxtests/psx06/init.c @ 2317457

4.104.115
Last change on this file since 2317457 was 2317457, checked in by Joel Sherrill <joel.sherrill@…>, on 12/08/09 at 17:52:53

2009-12-08 Joel Sherrill <joel.sherrill@…>

  • include/pmacros.h, psx01/task.c, psx02/init.c, psx02/task.c, psx03/init.c, psx03/task.c, psx04/init.c, psx04/task1.c, psx04/task2.c, psx04/task3.c, psx05/init.c, psx05/task.c, psx05/task2.c, psx05/task3.c, psx06/init.c, psx06/task.c, psx06/task2.c, psx07/init.c, psx08/init.c, psx08/task2.c, psx08/task3.c, psx09/init.c, psx10/init.c, psx10/task.c, psx10/task2.c, psx10/task3.c, psx11/init.c, psx11/task.c, psx12/init.c, psxalarm01/init.c, psxbarrier01/test.c, psxcancel01/init.c, psxchroot01/test.c, psxclock/init.c, psxfile01/test.c, psxfile01/test_cat.c, psxfile01/test_extend.c, psxfile01/test_write.c, psxitimer/init.c, psxkey01/task.c, psxkey02/init.c, psxkey03/init.c, psxmount/test.c, psxmsgq01/init.c, psxmsgq03/init.c, psxmsgq04/init.c, psxreaddir/test.c, psxrwlock01/test.c, psxsem01/init.c, psxsignal01/init.c, psxsignal01/task1.c, psxsignal02/init.c, psxsignal03/init.c, psxsignal05/init.c, psxspin01/test.c, psxspin02/test.c, psxstack01/init.c, psxstat/test.c, psxtime/test.c, psxualarm/init.c: Use rtems_test_assert() consistently instead of system assert(). rtems_test_assert() is designed to integrate into the RTEMS test suite infrastructure.
  • Property mode set to 100644
File size: 3.1 KB
Line 
1/*
2 *  COPYRIGHT (c) 1989-2009.
3 *  On-Line Applications Research Corporation (OAR).
4 *
5 *  The license and distribution terms for this file may be
6 *  found in the file LICENSE in this distribution or at
7 *  http://www.rtems.com/license/LICENSE.
8 *
9 *  $Id$
10 */
11
12#define CONFIGURE_INIT
13#include "system.h"
14#include <errno.h>
15
16extern void Key_destructor( void *key_data );
17
18void Key_destructor(
19 void *key_data
20)
21{
22  Destructor_invoked++;
23
24  /*
25   *  This checks out that we only run the destructor multiple times
26   *  when the key data is non null.
27   */
28
29  if ( Destructor_invoked == 5 )
30     (void) pthread_setspecific( Key_id, NULL );
31}
32
33void *POSIX_Init(
34  void *argument
35)
36{
37  int               status;
38  unsigned int      remaining;
39  uint32_t   *key_data;
40
41  puts( "\n\n*** POSIX TEST 6 ***" );
42
43  /* set the time of day, and print our buffer in multiple ways */
44
45  set_time( TM_FRIDAY, TM_MAY, 24, 96, 11, 5, 0 );
46
47  /* get id of this thread */
48
49  Init_id = pthread_self();
50  printf( "Init's ID is 0x%08" PRIxpthread_t "\n", Init_id );
51
52  /* create a couple of threads */
53
54  status = pthread_create( &Task_id, NULL, Task_1, NULL );
55  rtems_test_assert(  !status );
56
57  status = pthread_create( &Task2_id, NULL, Task_2, NULL );
58  rtems_test_assert(  !status );
59
60  /* create a key */
61
62  empty_line();
63
64  Destructor_invoked = 0;
65  puts( "Init: pthread_key_create - SUCCESSFUL" );
66  status = pthread_key_create( &Key_id, Key_destructor );
67  if ( status )
68    printf( "status = %d\n", status );
69  rtems_test_assert(  !status );
70
71  printf( "Destructor invoked %d times\n", Destructor_invoked );
72
73  puts( "Init: pthread_key_create - EAGAIN (too many keys)" );
74  status = pthread_key_create( &Key_id, Key_destructor );
75  rtems_test_assert(  status == EAGAIN );
76
77  puts( "Init: pthread_setspecific - EINVAL (invalid key)" );
78  status = pthread_setspecific( (pthread_t) -1, &Data_array[ 0 ] );
79  rtems_test_assert(  status == EINVAL );
80
81  puts( "Init: pthread_getspecific - EINVAL (invalid key)" );
82  key_data = pthread_getspecific( (pthread_t) -1 );
83  rtems_test_assert(  !key_data );
84
85  puts( "Init: pthread_key_delete - EINVAL (invalid key)" );
86  status = pthread_key_delete( (pthread_t) -1 );
87  rtems_test_assert(  status == EINVAL );
88
89  printf( "Init: Setting the key to %d\n", 0 );
90  status = pthread_setspecific( Key_id, &Data_array[ 0 ] );
91  if ( status )
92    printf( "status = %d\n", status );
93  rtems_test_assert(  !status );
94
95     /* switch to task 1 */
96
97  key_data = pthread_getspecific( Key_id );
98  printf( "Init: Got the key value of %ld\n",
99          (unsigned long) ((uint32_t   *)key_data - Data_array) );
100
101  remaining = sleep( 3 );
102  if ( remaining )
103     printf( "seconds remaining = %d\n", remaining );
104  rtems_test_assert(  !remaining );
105
106     /* switch to task 1 */
107
108  /* delete the key */
109
110  puts( "Init: pthread_key_delete - SUCCESSFUL" );
111  status = pthread_key_delete( Key_id );
112  if ( status )
113    printf( "status = %d\n", status );
114  rtems_test_assert(  !status );
115
116  printf( "Destructor invoked %d times\n", Destructor_invoked );
117
118  puts( "*** END OF POSIX TEST 6 ***" );
119  rtems_test_exit( 0 );
120
121  return NULL; /* just so the compiler thinks we returned something */
122}
Note: See TracBrowser for help on using the repository browser.