source: rtems/testsuites/psxtests/psxautoinit01/init.c @ 9a845e17

4.104.11
Last change on this file since 9a845e17 was 9a845e17, checked in by Joel Sherrill <joel.sherrill@…>, on Jul 7, 2009 at 2:30:12 PM

2009-07-07 Joel Sherrill <joel.sherrill@…>

  • Makefile.am, configure.ac: Add test of pthread mutex auto intialization.
  • psxautoinit01/.cvsignore, psxautoinit01/Makefile.am, psxautoinit01/init.c, psxautoinit01/psxautoinit01.scn: New files.
  • Property mode set to 100644
File size: 2.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 *  $Id$
10 */
11
12#include "tmacros.h"
13#include <pthread.h>
14#include <errno.h>
15
16void *POSIX_Init(
17  void *argument
18)
19{
20  int             sc;
21  pthread_mutex_t mutex1;
22  pthread_mutex_t mutex2;
23  int             prioceiling;
24
25  puts( "\n\n*** POSIX TEST -- AUTOMATIC INITIALIZAITON 01 ***" );
26
27  /* path using mutex get with interrupts disabled */
28  mutex1 = PTHREAD_MUTEX_INITIALIZER;
29  mutex2 = PTHREAD_MUTEX_INITIALIZER;
30  puts( "Init - pthread_mutex_lock - auto initialize - OK" );
31  sc = pthread_mutex_lock( &mutex1 );
32  fatal_posix_service_status( sc, 0, "mutex lock OK" );
33
34  puts( "Init - pthread_mutex_lock - auto initialize - EINVAL" );
35  sc = pthread_mutex_lock( &mutex2 );
36  fatal_posix_service_status( sc, EINVAL, "mutex lock EINVAL" );
37 
38  puts( "Init - pthread_mutex_unlock - OK" );
39  sc = pthread_mutex_unlock( &mutex1 );
40  fatal_posix_service_status( sc, 0, "mutex unlock OK" );
41
42  puts( "Init - pthread_mutex_destroy - OK" );
43  sc = pthread_mutex_destroy( &mutex1 );
44  fatal_posix_service_status( sc, 0, "mutex destroy OK" );
45
46  /* path using mutex get with dispatching disabled */
47  mutex1 = PTHREAD_MUTEX_INITIALIZER;
48  mutex2 = PTHREAD_MUTEX_INITIALIZER;
49  puts( "Init - pthread_mutex_getprioceiling - auto initialize - OK" );
50  sc = pthread_mutex_getprioceiling( &mutex1, &prioceiling );
51  fatal_posix_service_status( sc, 0, "mutex getprioceiling OK" );
52
53  puts( "Init - pthread_mutex_getprioceiling - auto initialize - EINVAL" );
54  sc = pthread_mutex_getprioceiling( &mutex2, &prioceiling );
55  fatal_posix_service_status( sc, EINVAL, "mutex getprioceiling EINVAL" );
56 
57  puts( "Init - pthread_mutex_destroy - OK" );
58  sc = pthread_mutex_destroy( &mutex1 );
59  fatal_posix_service_status( sc, 0, "mutex destroy OK" );
60
61  puts( "*** END OF POSIX TEST AUTOMATIC INITIALIZATION 01 ***" );
62  rtems_test_exit( 0 );
63
64  return NULL; /* just so the compiler thinks we returned something */
65}
66
67#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
68#define CONFIGURE_APPLICATION_DOES_NOT_NEED_CLOCK_DRIVER
69
70#define CONFIGURE_MAXIMUM_POSIX_THREADS 1
71#define CONFIGURE_MAXIMUM_POSIX_MUTEXES 1
72
73#define CONFIGURE_POSIX_INIT_THREAD_TABLE
74
75#define CONFIGURE_INIT
76#include <rtems/confdefs.h>
Note: See TracBrowser for help on using the repository browser.