source: rtems/testsuites/psxtests/psxautoinit02/init.c @ 5222488

5
Last change on this file since 5222488 was 5222488, checked in by Sebastian Huber <sebastian.huber@…>, on 09/26/17 at 05:49:17

posix: Implement self-contained POSIX condvar

POSIX condition variables are now available in all configurations and no
longer depend on --enable-posix.

Update #2514.
Update #3113.

  • Property mode set to 100644
File size: 3.3 KB
Line 
1/*
2 *  COPYRIGHT (c) 1989-2012.
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.org/license/LICENSE.
8 */
9
10#ifdef HAVE_CONFIG_H
11#include "config.h"
12#endif
13
14#include "tmacros.h"
15#include <pthread.h>
16#include <errno.h>
17
18const char rtems_test_name[] = "PSXAUTOINIT 2";
19
20/* forward declarations to avoid warnings */
21void *POSIX_Init(void *argument);
22
23void *POSIX_Init(
24  void *argument
25)
26{
27  int            sc;
28  pthread_cond_t cond1 = PTHREAD_COND_INITIALIZER;
29  pthread_cond_t cond2 = PTHREAD_COND_INITIALIZER;
30  pthread_cond_t cond3 = PTHREAD_COND_INITIALIZER;
31  pthread_cond_t cond4 = PTHREAD_COND_INITIALIZER;
32  pthread_cond_t cond5 = PTHREAD_COND_INITIALIZER;
33  pthread_mutex_t mtx = PTHREAD_MUTEX_INITIALIZER;
34  struct timespec to;
35
36  TEST_BEGIN();
37
38  puts( "Init - pthread_cond_broadcast - auto initialize - OK" );
39  sc = pthread_cond_broadcast( &cond1 );
40  fatal_posix_service_status( sc, 0, "cond broadcast OK" );
41
42  puts( "Init - pthread_cond_signal - auto initialize - OK" );
43  sc = pthread_cond_signal( &cond2 );
44  fatal_posix_service_status( sc, 0, "cond signal OK" );
45
46  puts( "Init - pthread_cond_init - auto initialize - OK" );
47  sc = pthread_cond_init( &cond3, NULL );
48  fatal_posix_service_status( sc, 0, "cond init OK" );
49
50  puts( "Init - pthread_mutex_lock - OK" );
51  sc = pthread_mutex_lock( &mtx );
52  fatal_posix_service_status( sc, 0, "mtx lock OK" );
53
54  puts( "Init - pthread_cond_timedwait - auto initialize - OK" );
55  to.tv_sec = 1;
56  to.tv_nsec = 1;
57  sc = pthread_cond_timedwait( &cond4, &mtx, &to );
58  fatal_posix_service_status( sc, ETIMEDOUT, "cond timedwait OK" );
59
60  puts( "Init - pthread_mutex_unlock - OK" );
61  sc = pthread_mutex_unlock( &mtx );
62  fatal_posix_service_status( sc, 0, "mtx unlock OK" );
63
64  puts( "Init - pthread_mutex_destroy - OK" );
65  sc = pthread_mutex_destroy( &mtx );
66  fatal_posix_service_status( sc, 0, "mtx destroy OK" );
67
68  puts( "Init - pthread_cond_destroy - OK" );
69  sc = pthread_cond_destroy( &cond5 );
70  fatal_posix_service_status( sc, 0, "cond destroy OK" );
71
72  puts( "Init - pthread_cond_destroy - EINVAL" );
73  sc = pthread_cond_destroy( &cond5 );
74  fatal_posix_service_status( sc, EINVAL, "cond destroy EINVAL" );
75
76  puts( "Init - pthread_cond_destroy - OK" );
77  sc = pthread_cond_destroy( &cond4 );
78  fatal_posix_service_status( sc, 0, "cond destroy OK" );
79
80  puts( "Init - pthread_cond_destroy - OK" );
81  sc = pthread_cond_destroy( &cond3 );
82  fatal_posix_service_status( sc, 0, "cond destroy OK" );
83
84  puts( "Init - pthread_cond_destroy - OK" );
85  sc = pthread_cond_destroy( &cond2 );
86  fatal_posix_service_status( sc, 0, "cond destroy OK" );
87
88  puts( "Init - pthread_cond_destroy - OK" );
89  sc = pthread_cond_destroy( &cond1 );
90  fatal_posix_service_status( sc, 0, "cond destroy OK" );
91
92  TEST_END();
93  rtems_test_exit( 0 );
94
95  return NULL; /* just so the compiler thinks we returned something */
96}
97
98#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
99#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
100
101#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
102
103#define CONFIGURE_MAXIMUM_POSIX_THREADS 1
104#define CONFIGURE_MAXIMUM_POSIX_MUTEXES 1
105
106#define CONFIGURE_POSIX_INIT_THREAD_TABLE
107
108#define CONFIGURE_INIT
109#include <rtems/confdefs.h>
Note: See TracBrowser for help on using the repository browser.