blob: cd3eb2ad2955a716292c04507cc7c87abd7757d4 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
/*
* COPYRIGHT (c) 1989-2009.
* On-Line Applications Research Corporation (OAR).
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rtems.org/license/LICENSE.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#define CONFIGURE_INIT
#include "system.h"
static pthread_once_t nesting_once = PTHREAD_ONCE_INIT;
static void Test_init_routine_nesting( void )
{
int status;
puts( "Test_init_routine_nesting: invoked" );
puts( "Test_init_routine_nesting: pthread_once - EINVAL (init_routine_nesting does not execute)" );
status = pthread_once( &nesting_once, Test_init_routine_nesting );
rtems_test_assert( status == EINVAL );
}
static int test_init_routine_call_counter = 0;
static void Test_init_routine( void )
{
puts( "Test_init_routine: invoked" );
++test_init_routine_call_counter;
}
rtems_task Init(rtems_task_argument argument)
{
int status;
pthread_once_t once = PTHREAD_ONCE_INIT;
puts( "\n\n*** TEST POSIX ONCE 01 ***" );
puts( "Init: pthread_once - EINVAL (NULL once_control)" );
status = pthread_once( NULL, Test_init_routine );
rtems_test_assert( status == EINVAL );
puts( "Init: pthread_once - EINVAL (NULL init_routine)" );
status = pthread_once( &once, NULL );
rtems_test_assert( status == EINVAL );
puts( "Init: pthread_once - SUCCESSFUL (init_routine executes)" );
status = pthread_once( &once, Test_init_routine );
rtems_test_assert( !status );
printf( "Init: call counter: %d\n", test_init_routine_call_counter );
rtems_test_assert( test_init_routine_call_counter == 1 );
puts( "Init: pthread_once - SUCCESSFUL (init_routine does not execute)" );
status = pthread_once( &once, Test_init_routine );
rtems_test_assert( !status );
printf( "Init: call counter: %d\n", test_init_routine_call_counter );
rtems_test_assert( test_init_routine_call_counter == 1 );
puts( "Init: pthread_once - SUCCESSFUL (init_routine_nesting executes)" );
status = pthread_once( &nesting_once, Test_init_routine_nesting );
rtems_test_assert( !status );
puts( "*** END OF TEST POSIX ONCE 01 ***" );
rtems_test_exit( 0 );
}
|