source: rtems/testsuites/psxtests/psxmutexattr01/init.c @ 9b4422a2

4.115
Last change on this file since 9b4422a2 was 9b4422a2, checked in by Joel Sherrill <joel.sherrill@…>, on 05/03/12 at 15:09:24

Remove All CVS Id Strings Possible Using a Script

Script does what is expected and tries to do it as
smartly as possible.

+ remove occurrences of two blank comment lines

next to each other after Id string line removed.

+ remove entire comment blocks which only exited to

contain CVS Ids

+ If the processing left a blank line at the top of

a file, it was removed.

  • Property mode set to 100644
File size: 3.4 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
10#ifdef HAVE_CONFIG_H
11#include "config.h"
12#endif
13
14#include <tmacros.h>
15#include <errno.h>
16#include <pthread.h>
17
18#if defined(_UNIX98_THREAD_MUTEX_ATTRIBUTES)
19typedef struct {
20  const char *name;
21  int type;
22  int status;
23} ToCheck_t;
24
25ToCheck_t TypesToCheck[] = {
26  { "bad type - EINVAL",             -1,                       EINVAL },
27  { "PTHREAD_MUTEX_NORMAL - OK",     PTHREAD_MUTEX_NORMAL,     0 },
28  { "PTHREAD_MUTEX_RECURSIVE - OK",  PTHREAD_MUTEX_RECURSIVE,  0 },
29  { "PTHREAD_MUTEX_ERRORCHECK - OK", PTHREAD_MUTEX_ERRORCHECK, 0 },
30  { "PTHREAD_MUTEX_DEFAULT - OK",    PTHREAD_MUTEX_DEFAULT,    0 },
31};
32
33#define TO_CHECK sizeof(TypesToCheck) / sizeof(ToCheck_t)
34#endif
35
36void *POSIX_Init(
37  void *ignored
38)
39{
40  int                 sc;
41  pthread_mutexattr_t attr;
42  int                 type;
43  int                 i;
44
45  puts( "\n\n*** POSIX MUTEX ATTRIBUTE TEST 1 ***" );
46
47#if defined(_UNIX98_THREAD_MUTEX_ATTRIBUTES)
48  puts( "Init - pthread_mutexattr_gettype - attr NULL - EINVAL" );
49  sc = pthread_mutexattr_gettype( NULL, &type );
50  rtems_test_assert( sc == EINVAL );
51
52  puts( "Init - pthread_mutexattr_gettype - type NULL - EINVAL" );
53  sc = pthread_mutexattr_gettype( &attr, NULL );
54  rtems_test_assert( sc == EINVAL );
55
56  memset( &attr, 0, sizeof(attr) );
57  puts( "Init - pthread_mutexattr_gettype - attr not initialized - EINVAL" );
58  sc = pthread_mutexattr_gettype( &attr, &type );
59  rtems_test_assert( sc == EINVAL );
60
61  puts( "Init - pthread_mutexattr_init - OK" );
62  sc = pthread_mutexattr_init( &attr );
63  rtems_test_assert( sc == 0 );
64
65  puts( "Init - pthread_mutexattr_gettype - OK" );
66  sc = pthread_mutexattr_gettype( &attr, &type );
67  rtems_test_assert( sc == 0 );
68
69  /* now do settype */
70  puts( "Init - pthread_mutexattr_settype - type NULL - EINVAL" );
71  sc = pthread_mutexattr_settype( NULL, PTHREAD_MUTEX_NORMAL );
72  rtems_test_assert( sc == EINVAL );
73
74  memset( &attr, 0, sizeof(attr) );
75  puts( "Init - pthread_mutexattr_settype - attr not initialized - EINVAL" );
76  sc = pthread_mutexattr_settype( NULL, PTHREAD_MUTEX_NORMAL );
77  rtems_test_assert( sc == EINVAL );
78
79  /* iterate over good/bad get sets */
80
81  for (i=0 ; i<TO_CHECK ; i++ ) {
82    puts( "Init - pthread_mutexattr_init - OK" );
83    sc = pthread_mutexattr_init( &attr );
84    rtems_test_assert( sc == 0 );
85
86    printf( "Init - pthread_mutexattr_settype - %s\n", TypesToCheck[i].name );
87    sc = pthread_mutexattr_settype( &attr, TypesToCheck[i].type );
88    rtems_test_assert( sc == TypesToCheck[i].status );
89
90    type = -2;
91
92    if ( TypesToCheck[i].status == 0 ) {
93      printf( "Init - pthread_mutexattr_gettype - %s\n", TypesToCheck[i].name );
94      sc = pthread_mutexattr_gettype( &attr, &type );
95      rtems_test_assert( sc == 0 );
96      rtems_test_assert( type == TypesToCheck[i].type );
97    }
98  }
99#else
100  puts( "POSIX Mutex Attribute Type Not Supported in Tools" );
101#endif
102
103  puts( "*** END OF POSIX MUTEX ATTRIBUTE TEST 1 ***" );
104  rtems_test_exit(0);
105}
106
107/* configuration information */
108
109#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
110#define CONFIGURE_APPLICATION_DOES_NOT_NEED_CLOCK_DRIVER
111
112#define CONFIGURE_MAXIMUM_POSIX_THREADS  1
113
114#define CONFIGURE_POSIX_INIT_THREAD_TABLE
115
116#define CONFIGURE_INIT
117#include <rtems/confdefs.h>
118
119/* global variables */
Note: See TracBrowser for help on using the repository browser.