source: rtems/testsuites/psxtests/psxcancel01/init.c @ 0c07f69

4.104.115
Last change on this file since 0c07f69 was 0c07f69, checked in by Joel Sherrill <joel.sherrill@…>, on 09/28/09 at 23:52:46

2009-09-28 Joel Sherrill <joel.sherrill@…>

  • psxcancel/init.c, psxcancel/psxcancel.scn, psxcancel01/init.c, psxcancel01/psxcancel01.scn: Add missing pthread cancellation test cases.
  • Property mode set to 100644
File size: 2.5 KB
Line 
1/*
2 *  COPYRIGHT (c) 1989-1999.
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 <pmacros.h>
13#include <errno.h>
14
15volatile int TSR_occurred;
16volatile int TSR_status;
17
18rtems_id  timer_id;
19
20rtems_timer_service_routine Cancel_duringISR_TSR(
21  rtems_id  ignored_id,
22  void     *ignored_address
23)
24{
25  TSR_status = pthread_cancel( pthread_self() );
26  TSR_occurred = 1;
27}
28
29rtems_timer_service_routine SetState_duringISR_TSR(
30  rtems_id  ignored_id,
31  void     *ignored_address
32)
33{
34  int oldstate;
35
36  TSR_status = pthread_setcancelstate( 0, &oldstate );
37  TSR_occurred = 1;
38}
39
40rtems_timer_service_routine SetType_duringISR_TSR(
41  rtems_id  ignored_id,
42  void     *ignored_address
43)
44{
45  int oldtype;
46
47  TSR_status = pthread_setcanceltype( 0, &oldtype );
48  TSR_occurred = 1;
49}
50
51void doit(
52  rtems_timer_service_routine (*TSR)(rtems_id, void *),
53  const char                   *method
54)
55{
56  rtems_interval    start;
57  rtems_interval    end;
58  rtems_status_code status;
59
60  printf( "Init: schedule %s from a TSR\n", method );
61
62  TSR_occurred = 0;
63  TSR_status   = 0;
64
65  status = rtems_timer_fire_after( timer_id, 10, TSR, NULL );
66  assert( !status );
67
68  do {
69    end = rtems_clock_get_ticks_since_boot();
70  } while ( !TSR_occurred && ((end - start) <= 800));
71
72  if ( !TSR_occurred ) {
73    printf( "%s did not occur\n", method );
74    rtems_test_exit(0);
75  }
76  if ( TSR_status != EPROTO ) {
77    printf( "%s returned %s\n", method, strerror(TSR_status) );
78    rtems_test_exit(0);
79  }
80  printf( "%s - from ISR returns EPROTO - OK\n", method );
81
82}
83
84void *POSIX_Init(
85  void *argument
86)
87{
88  rtems_status_code status;
89
90  puts( "\n\n*** POSIX TEST CANCEL 01 ***" );
91
92  status = rtems_timer_create(
93    rtems_build_name( 'T', 'M', '1', ' ' ),
94    &timer_id
95  );
96  assert( !status );
97
98  doit( Cancel_duringISR_TSR, "pthread_cancel" );
99  doit( SetState_duringISR_TSR, "pthread_setcancelstate" );
100  doit( SetType_duringISR_TSR, "pthread_setcanceltype" );
101
102  puts( "*** END OF POSIX TEST CANCEL 01 ***" );
103  rtems_test_exit(0);
104  return NULL; /* just so the compiler thinks we returned something */
105}
106
107/* configuration information */
108
109#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
110#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
111
112#define CONFIGURE_MAXIMUM_TIMERS        1
113
114#define CONFIGURE_MAXIMUM_POSIX_THREADS        1
115#define CONFIGURE_POSIX_INIT_THREAD_TABLE
116
117#define CONFIGURE_INIT
118#include <rtems/confdefs.h>
Note: See TracBrowser for help on using the repository browser.