source: rtems/testsuites/psxtests/psxalarm01/init.c @ 33c46f1

4.115
Last change on this file since 33c46f1 was 33c46f1, checked in by Joel Sherrill <joel.sherrill@…>, on 10/21/10 at 21:22:25

2010-10-21 Joel Sherrill <joel.sherrill@…>

  • psx02/init.c, psx02/task.c, psx03/init.c, psx04/init.c, psx04/task1.c, psx04/task2.c, psx04/task3.c, psx05/init.c, psx05/task.c, psx05/task2.c, psx05/task3.c, psx06/init.c, psx06/task.c, psx06/task2.c, psx07/init.c, psx08/init.c, psx08/task2.c, psx08/task3.c, psx09/init.c, psx10/init.c, psx10/task.c, psx10/task2.c, psx10/task3.c, psx11/init.c, psx11/task.c, psx12/init.c, psxalarm01/init.c, psxbarrier01/test.c, psxcancel01/init.c, psxchroot01/test.c, psxitimer/init.c, psxkey01/task.c, psxkey02/init.c, psxkey03/init.c, psxmount/test.c, psxmsgq01/init.c, psxmsgq03/init.c, psxmsgq04/init.c, psxrwlock01/test.c, psxsem01/init.c, psxsignal01/init.c, psxsignal01/task1.c, psxsignal02/init.c, psxsignal03/init.c, psxsignal05/init.c, psxspin01/test.c, psxspin02/test.c, psxstack01/init.c, psxstack02/init.c, psxualarm/init.c: Eliminate double space after parenthesis on rtems_test_assert().
  • Property mode set to 100644
File size: 2.5 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 <pmacros.h>
13
14#include <signal.h>
15#include <errno.h>
16
17volatile int Signal_occurred;
18volatile int Signal_count;
19void Signal_handler( int signo );
20void Signal_info_handler(
21  int        signo,
22  siginfo_t *info,
23  void      *context
24);
25
26void Signal_handler(
27  int signo
28)
29{
30  Signal_count++;
31  printf(
32    "Signal: %d caught by 0x%" PRIxpthread_t " (%d)\n",
33    signo,
34    pthread_self(),
35    Signal_count
36  );
37  Signal_occurred = 1;
38}
39
40void Signal_info_handler(
41  int        signo,
42  siginfo_t *info,
43  void      *context
44)
45{
46  Signal_count++;
47  printf(
48    "Signal_info: %d caught by 0x%" PRIxpthread_t " (%d) si_signo= %d si_code= %d value= %d\n",
49    signo,
50    pthread_self(),
51    Signal_count,
52    info->si_signo,
53    info->si_code,
54    info->si_value.sival_int
55  );
56  Signal_occurred = 1;
57}
58
59void *POSIX_Init(
60  void *argument
61)
62{
63  unsigned int      remaining;
64  int               sc;
65  struct sigaction  act;
66  sigset_t          mask;
67
68  puts( "\n\n*** POSIX ALARM TEST 01 ***" );
69
70  /* install a signal handler for SIGALRM and unblock it */
71
72  sc = sigemptyset( &act.sa_mask );
73  rtems_test_assert( !sc );
74
75  act.sa_handler = Signal_handler;
76  act.sa_flags   = 0;
77
78  sigaction( SIGALRM, &act, NULL );
79
80  sc = sigemptyset( &mask );
81  rtems_test_assert( !sc );
82
83  sc = sigaddset( &mask, SIGALRM );
84  rtems_test_assert( !sc );
85
86  puts( "Init: Unblock SIGALRM" );
87  sc = sigprocmask( SIG_UNBLOCK, &mask, NULL );
88  rtems_test_assert( !sc );
89
90  /* schedule the alarm */
91
92  puts( "Init: Firing alarm in 1 second" );
93  remaining = alarm( 1 );
94  printf( "Init: %d seconds left on previous alarm\n", sc );
95  rtems_test_assert( !sc );
96
97  puts( "Init: Wait for alarm" );
98  sleep( 2 );
99
100  puts( "Init: Cancel alarm" );
101  remaining = alarm( 0 );
102  printf( "Init: %d seconds left on previous alarm\n", remaining );
103  rtems_test_assert( remaining == 0 );
104
105  puts( "*** END OF POSIX ALARM TEST 01***" );
106  rtems_test_exit( 0 );
107
108  return NULL; /* just so the compiler thinks we returned something */
109}
110
111#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
112#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
113
114#define CONFIGURE_MAXIMUM_POSIX_THREADS        1
115
116#define CONFIGURE_POSIX_INIT_THREAD_TABLE
117#define CONFIGURE_POSIX_INIT_THREAD_STACK_SIZE \
118        (RTEMS_MINIMUM_STACK_SIZE * 4)
119
120#define CONFIGURE_INIT
121#include <rtems/confdefs.h>
122
Note: See TracBrowser for help on using the repository browser.