source: rtems/testsuites/psxtests/psxspin02/test.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: 2.3 KB
Line 
1/*
2 *  This test exercises the POSIX Spinlock manager.
3 *
4 *  COPYRIGHT (c) 1989-2009.
5 *  On-Line Applications Research Corporation (OAR).
6 *
7 *  The license and distribution terms for this file may be
8 *  found in the file LICENSE in this distribution or at
9 *  http://www.rtems.com/license/LICENSE.
10 */
11
12#ifdef HAVE_CONFIG_H
13#include "config.h"
14#endif
15
16#include "tmacros.h"
17#include <stdio.h>
18#include <errno.h>
19#include <stdlib.h>
20
21#include <pthread.h>
22
23#include <rtems.h>  /* for task creation */
24
25pthread_spinlock_t Spinlock;
26
27rtems_task SpinlockThread(rtems_task_argument arg)
28{
29  int  status;
30
31  puts( "pthread_spin_trylock( &Spinlock ) -- EBUSY" );
32  status = pthread_spin_trylock( &Spinlock );
33  rtems_test_assert( status == EBUSY );
34
35  puts( "pthread_spin_unlock( &Spinlock ) -- EPERM" );
36  status = pthread_spin_unlock( &Spinlock );
37  rtems_test_assert( status == EPERM );
38
39  rtems_task_delete( RTEMS_SELF );
40}
41
42/*
43 *  main entry point to the test
44 */
45
46#if defined(__rtems__)
47int test_main(void)
48#else
49int main(
50  int    argc,
51  char **argv
52)
53#endif
54{
55  int                   status;
56  rtems_status_code     rstatus;
57  rtems_id              taskid;
58
59  puts( "\n\n*** POSIX SPINLOCK TEST 02 ***" );
60
61  /* This successfully creates one */
62  puts( "pthread_spin_init( &Spinlock, PTHREAD_PROCESS_PRIVATE ) -- OK" );
63  status = pthread_spin_init( &Spinlock, PTHREAD_PROCESS_PRIVATE );
64  rtems_test_assert( status == 0 );
65
66  /* Lock it */
67  puts( "pthread_spin_lock( &Spinlock ) -- OK" );
68  status = pthread_spin_lock( &Spinlock );
69  rtems_test_assert( status == 0 );
70
71  /*  Create a helper task */
72  rstatus = rtems_task_create(
73     rtems_build_name( 'S', 'P', 'I', 'N' ),
74     1,
75     RTEMS_MINIMUM_STACK_SIZE,
76     RTEMS_DEFAULT_MODES,
77     RTEMS_DEFAULT_ATTRIBUTES,
78     &taskid
79  );
80  rtems_test_assert( rstatus == RTEMS_SUCCESSFUL );
81
82  rstatus = rtems_task_start( taskid, SpinlockThread, 0 );
83  rtems_test_assert( rstatus == RTEMS_SUCCESSFUL );
84
85  sleep(1);
86
87  puts( "pthread_spin_unlock( &Spinlock ) -- OK" );
88  status = pthread_spin_unlock( &Spinlock );
89  rtems_test_assert( status == 0 );
90
91  puts( "pthread_spin_destroy( &Spinlock ) -- OK" );
92  status = pthread_spin_destroy( &Spinlock );
93  rtems_test_assert( status == 0 );
94
95  /*************** END OF TEST *****************/
96  puts( "*** END OF POSIX SPINLOCK TEST 02 ***" );
97  exit(0);
98}
Note: See TracBrowser for help on using the repository browser.