summaryrefslogtreecommitdiff
path: root/tests/test-sigdescr_np.c
blob: 741fcb3f3a2fa6ee08cdc4c08bf4df5c5718aded (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
/* Test of sigdescr_np() function.

   Copyright (C) 2020-2023 Free Software Foundation, Inc.

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation, either version 3, or (at your option)
   any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program; if not, see <https://www.gnu.org/licenses/>.  */

#include <config.h>

/* Specification.  */
#include <string.h>

#include "signature.h"
SIGNATURE_CHECK (sigdescr_np, const char *, (int));

#include <signal.h>

#include "macros.h"

int
main (void)
{
  /* Signals specified by ISO C.  */
  ASSERT (strcmp (sigdescr_np (SIGABRT), "Aborted") == 0);
  ASSERT (strcmp (sigdescr_np (SIGFPE), "Floating point exception") == 0
          || strcmp (sigdescr_np (SIGFPE), "Arithmetic exception") == 0);
  ASSERT (strcmp (sigdescr_np (SIGILL), "Illegal instruction") == 0);
  ASSERT (strcmp (sigdescr_np (SIGINT), "Interrupt") == 0);
  ASSERT (strcmp (sigdescr_np (SIGSEGV), "Segmentation fault") == 0);
  ASSERT (strcmp (sigdescr_np (SIGTERM), "Terminated") == 0);

  /* Signals specified by POSIX.
     <https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/signal.h.html>  */
  #ifdef SIGALRM
  ASSERT (strcmp (sigdescr_np (SIGALRM), "Alarm clock") == 0);
  #endif
  #ifdef SIGBUS
  ASSERT (strcmp (sigdescr_np (SIGBUS), "Bus error") == 0);
  #endif
  #ifdef SIGCHLD
  ASSERT (strcmp (sigdescr_np (SIGCHLD), "Child exited") == 0 /* glibc */
          || strcmp (sigdescr_np (SIGCHLD), "Child stopped or exited") == 0);
  #endif
  #ifdef SIGCONT
  ASSERT (strcmp (sigdescr_np (SIGCONT), "Continued") == 0);
  #endif
  #ifdef SIGHUP
  ASSERT (strcmp (sigdescr_np (SIGHUP), "Hangup") == 0);
  #endif
  #ifdef SIGKILL
  ASSERT (strcmp (sigdescr_np (SIGKILL), "Killed") == 0);
  #endif
  #ifdef SIGPIPE
  ASSERT (strcmp (sigdescr_np (SIGPIPE), "Broken pipe") == 0);
  #endif
  #ifdef SIGQUIT
  ASSERT (strcmp (sigdescr_np (SIGQUIT), "Quit") == 0);
  #endif
  #ifdef SIGSTOP
  ASSERT (strcmp (sigdescr_np (SIGSTOP), "Stopped (signal)") == 0);
  #endif
  #ifdef SIGTSTP
  ASSERT (strcmp (sigdescr_np (SIGTSTP), "Stopped") == 0);
  #endif
  #ifdef SIGTTIN
  ASSERT (strcmp (sigdescr_np (SIGTTIN), "Stopped (tty input)") == 0);
  #endif
  #ifdef SIGTTOU
  ASSERT (strcmp (sigdescr_np (SIGTTOU), "Stopped (tty output)") == 0);
  #endif
  #ifdef SIGUSR1
  ASSERT (strcmp (sigdescr_np (SIGUSR1), "User defined signal 1") == 0);
  #endif
  #ifdef SIGUSR2
  ASSERT (strcmp (sigdescr_np (SIGUSR2), "User defined signal 2") == 0);
  #endif
  #ifdef SIGPOLL
  ASSERT (strcmp (sigdescr_np (SIGPOLL), "I/O possible") == 0);
  #endif
  #ifdef SIGPROF
  ASSERT (strcmp (sigdescr_np (SIGPROF), "Profiling timer expired") == 0);
  #endif
  #ifdef SIGSYS
  ASSERT (strcmp (sigdescr_np (SIGSYS), "Bad system call") == 0);
  #endif
  #ifdef SIGTRAP
  ASSERT (strcmp (sigdescr_np (SIGTRAP), "Trace/breakpoint trap") == 0);
  #endif
  #ifdef SIGURG
  ASSERT (strcmp (sigdescr_np (SIGURG), "Urgent I/O condition") == 0);
  #endif
  #ifdef SIGVTALRM
  ASSERT (strcmp (sigdescr_np (SIGVTALRM), "Virtual timer expired") == 0);
  #endif
  #ifdef SIGXCPU
  ASSERT (strcmp (sigdescr_np (SIGXCPU), "CPU time limit exceeded") == 0);
  #endif
  #ifdef SIGXFSZ
  ASSERT (strcmp (sigdescr_np (SIGXFSZ), "File size limit exceeded") == 0);
  #endif

  /* Other signals on other systems.  */
  /* native Windows */
  #ifdef SIGBREAK
  ASSERT (strcmp (sigdescr_np (SIGBREAK), "Ctrl-Break") == 0);
  #endif
  /* IRIX */
  #ifdef SIGCKPT
  ASSERT (strcmp (sigdescr_np (SIGCKPT), "Checkpoint") == 0);
  #endif
  /* AIX */
  #ifdef SIGCPUFAIL
  ASSERT (strcmp (sigdescr_np (SIGCPUFAIL), "CPU going down") == 0);
  #endif
  /* AIX */
  #ifdef SIGDANGER
  ASSERT (strcmp (sigdescr_np (SIGDANGER), "Swap space nearly exhausted") == 0);
  #endif
  /* Mac OS X, FreeBSD, NetBSD, OpenBSD, Minix, AIX, IRIX, Cygwin, mingw */
  #ifdef SIGEMT
  ASSERT (strcmp (sigdescr_np (SIGEMT), "Instruction emulation needed") == 0);
  #endif
  /* Mac OS X, FreeBSD, NetBSD, OpenBSD, Minix */
  #if defined SIGINFO && SIGINFO != SIGPWR
  ASSERT (strcmp (sigdescr_np (SIGINFO), "Information request") == 0);
  #endif
  /* AIX */
  #ifdef SIGKAP
  ASSERT (strcmp (sigdescr_np (SIGKAP), "Keep Alive Poll") == 0);
  #endif
  /* Haiku */
  #ifdef SIGKILLTHR
  ASSERT (strcmp (sigdescr_np (SIGKILLTHR), "Kill thread") == 0);
  #endif
  /* Minix */
  #ifdef SIGKMEM
  ASSERT (strcmp (sigdescr_np (SIGKMEM), "Kernel memory request") == 0);
  #endif
  /* Minix */
  #ifdef SIGKMESS
  ASSERT (strcmp (sigdescr_np (SIGKMESS), "Kernel message") == 0);
  #endif
  /* Minix */
  #ifdef SIGKSIG
  ASSERT (strcmp (sigdescr_np (SIGKSIG), "Kernel signal") == 0);
  #endif
  /* Minix */
  #ifdef SIGKSIGSM
  ASSERT (strcmp (sigdescr_np (SIGKSIGSM), "Kernel signal for signal manager") == 0);
  #endif
  /* FreeBSD */
  #ifdef SIGLIBRT
  ASSERT (strcmp (sigdescr_np (SIGLIBRT), "Real-time library interrupt") == 0);
  #endif
  /* AIX */
  #ifdef SIGMIGRATE
  ASSERT (strcmp (sigdescr_np (SIGMIGRATE), "Process migration") == 0);
  #endif
  /* AIX */
  #ifdef SIGMSG
  ASSERT (strcmp (sigdescr_np (SIGMSG), "Message in the ring") == 0);
  #endif
  /* AIX */
  #ifdef SIGPRE
  ASSERT (strcmp (sigdescr_np (SIGPRE), "Programmed exception") == 0);
  #endif
  /* IRIX */
  #ifdef SIGPTINTR
  ASSERT (strcmp (sigdescr_np (SIGPTINTR), "Pthread interrupt") == 0);
  #endif
  /* IRIX */
  #ifdef SIGPTRESCHED
  ASSERT (strcmp (sigdescr_np (SIGPTRESCHED), "Pthread rescheduling") == 0);
  #endif
  /* Linux, NetBSD, Minix, AIX, IRIX, Cygwin */
  #ifdef SIGPWR
  ASSERT (strcmp (sigdescr_np (SIGPWR), "Power failure") == 0);
  #endif
  /* AIX */
  #ifdef SIGRECONFIG
  ASSERT (strcmp (sigdescr_np (SIGRECONFIG), "Dynamic logical partitioning changed") == 0);
  #endif
  /* AIX */
  #ifdef SIGRECOVERY
  ASSERT (strcmp (sigdescr_np (SIGRECOVERY), "Kernel recovery") == 0);
  #endif
  /* IRIX */
  #ifdef SIGRESTART
  ASSERT (strcmp (sigdescr_np (SIGRESTART), "Checkpoint restart") == 0);
  #endif
  /* AIX */
  #ifdef SIGRETRACT
  ASSERT (strcmp (sigdescr_np (SIGRETRACT), "Retracting Keep Alive Poll") == 0);
  #endif
  /* AIX */
  #ifdef SIGSAK
  ASSERT (strcmp (sigdescr_np (SIGSAK), "Secure Attention Key") == 0);
  #endif
  /* Minix */
  #ifdef SIGSNDELAY
  ASSERT (strcmp (sigdescr_np (SIGSNDELAY), "Done sending message") == 0);
  #endif
  /* AIX */
  #ifdef SIGSOUND
  ASSERT (strcmp (sigdescr_np (SIGSOUND), "Sound configuration changed") == 0);
  #endif
  /* Linux */
  #ifdef SIGSTKFLT
  ASSERT (strcmp (sigdescr_np (SIGSTKFLT), "Stack fault") == 0);
  #endif
  /* AIX */
  #ifdef SIGSYSERROR
  ASSERT (strcmp (sigdescr_np (SIGSYSERROR), "Kernel error") == 0);
  #endif
  /* AIX */
  #ifdef SIGTALRM
  ASSERT (strcmp (sigdescr_np (SIGTALRM), "Thread alarm clock") == 0);
  #endif
  /* FreeBSD, OpenBSD */
  #ifdef SIGTHR
  ASSERT (strcmp (sigdescr_np (SIGTHR), "Thread library interrupt") == 0);
  #endif
  /* IRIX */
  #ifdef SIGUME
  ASSERT (strcmp (sigdescr_np (SIGUME), "Uncorrectable memory error") == 0);
  #endif
  /* AIX */
  #ifdef SIGVIRT
  ASSERT (strcmp (sigdescr_np (SIGVIRT), "Virtual time alarm clock") == 0);
  #endif
  /* AIX */
  #ifdef SIGWAITING
  ASSERT (strcmp (sigdescr_np (SIGWAITING), "Thread waiting") == 0);
  #endif
  /* Linux, Mac OS X, FreeBSD, NetBSD, OpenBSD, Minix, AIX, IRIX, Cygwin, Haiku */
  #ifdef SIGWINCH
  ASSERT (strcmp (sigdescr_np (SIGWINCH), "Window changed") == 0 /* glibc */
          || strcmp (sigdescr_np (SIGWINCH), "Window size changed") == 0);
  #endif

  ASSERT (sigdescr_np (-714) == NULL);

  return 0;
}