sigprocmask: Fix configuration failure on Solaris 10 (regr. 2020-07-25).
[gnulib.git] / tests / test-sigdescr_np.c
blob292d373ddce3db03c37d9c811aaf279fbc7e5da7
1 /* Test of sigdescr_np() function.
3 Copyright (C) 2020 Free Software Foundation, Inc.
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3, or (at your option)
8 any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, see <https://www.gnu.org/licenses/>. */
18 #include <config.h>
20 /* Specification. */
21 #include <string.h>
23 #include "signature.h"
24 SIGNATURE_CHECK (sigdescr_np, const char *, (int));
26 #include <signal.h>
28 #include "macros.h"
30 int
31 main (void)
33 /* Signals specified by ISO C. */
34 ASSERT (strcmp (sigdescr_np (SIGABRT), "Aborted") == 0);
35 ASSERT (strcmp (sigdescr_np (SIGFPE), "Floating point exception") == 0
36 || strcmp (sigdescr_np (SIGFPE), "Arithmetic exception") == 0);
37 ASSERT (strcmp (sigdescr_np (SIGILL), "Illegal instruction") == 0);
38 ASSERT (strcmp (sigdescr_np (SIGINT), "Interrupt") == 0);
39 ASSERT (strcmp (sigdescr_np (SIGSEGV), "Segmentation fault") == 0);
40 ASSERT (strcmp (sigdescr_np (SIGTERM), "Terminated") == 0);
42 /* Signals specified by POSIX.
43 <https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/signal.h.html> */
44 #ifdef SIGALRM
45 ASSERT (strcmp (sigdescr_np (SIGALRM), "Alarm clock") == 0);
46 #endif
47 #ifdef SIGBUS
48 ASSERT (strcmp (sigdescr_np (SIGBUS), "Bus error") == 0);
49 #endif
50 #ifdef SIGCHLD
51 ASSERT (strcmp (sigdescr_np (SIGCHLD), "Child exited") == 0 /* glibc */
52 || strcmp (sigdescr_np (SIGCHLD), "Child stopped or exited") == 0);
53 #endif
54 #ifdef SIGCONT
55 ASSERT (strcmp (sigdescr_np (SIGCONT), "Continued") == 0);
56 #endif
57 #ifdef SIGHUP
58 ASSERT (strcmp (sigdescr_np (SIGHUP), "Hangup") == 0);
59 #endif
60 #ifdef SIGKILL
61 ASSERT (strcmp (sigdescr_np (SIGKILL), "Killed") == 0);
62 #endif
63 #ifdef SIGPIPE
64 ASSERT (strcmp (sigdescr_np (SIGPIPE), "Broken pipe") == 0);
65 #endif
66 #ifdef SIGQUIT
67 ASSERT (strcmp (sigdescr_np (SIGQUIT), "Quit") == 0);
68 #endif
69 #ifdef SIGSTOP
70 ASSERT (strcmp (sigdescr_np (SIGSTOP), "Stopped (signal)") == 0);
71 #endif
72 #ifdef SIGTSTP
73 ASSERT (strcmp (sigdescr_np (SIGTSTP), "Stopped") == 0);
74 #endif
75 #ifdef SIGTTIN
76 ASSERT (strcmp (sigdescr_np (SIGTTIN), "Stopped (tty input)") == 0);
77 #endif
78 #ifdef SIGTTOU
79 ASSERT (strcmp (sigdescr_np (SIGTTOU), "Stopped (tty output)") == 0);
80 #endif
81 #ifdef SIGUSR1
82 ASSERT (strcmp (sigdescr_np (SIGUSR1), "User defined signal 1") == 0);
83 #endif
84 #ifdef SIGUSR2
85 ASSERT (strcmp (sigdescr_np (SIGUSR2), "User defined signal 2") == 0);
86 #endif
87 #ifdef SIGPOLL
88 ASSERT (strcmp (sigdescr_np (SIGPOLL), "I/O possible") == 0);
89 #endif
90 #ifdef SIGPROF
91 ASSERT (strcmp (sigdescr_np (SIGPROF), "Profiling timer expired") == 0);
92 #endif
93 #ifdef SIGSYS
94 ASSERT (strcmp (sigdescr_np (SIGSYS), "Bad system call") == 0);
95 #endif
96 #ifdef SIGTRAP
97 ASSERT (strcmp (sigdescr_np (SIGTRAP), "Trace/breakpoint trap") == 0);
98 #endif
99 #ifdef SIGURG
100 ASSERT (strcmp (sigdescr_np (SIGURG), "Urgent I/O condition") == 0);
101 #endif
102 #ifdef SIGVTALRM
103 ASSERT (strcmp (sigdescr_np (SIGVTALRM), "Virtual timer expired") == 0);
104 #endif
105 #ifdef SIGXCPU
106 ASSERT (strcmp (sigdescr_np (SIGXCPU), "CPU time limit exceeded") == 0);
107 #endif
108 #ifdef SIGXFSZ
109 ASSERT (strcmp (sigdescr_np (SIGXFSZ), "File size limit exceeded") == 0);
110 #endif
112 /* Other signals on other systems. */
113 /* native Windows */
114 #ifdef SIGBREAK
115 ASSERT (strcmp (sigdescr_np (SIGBREAK), "Ctrl-Break") == 0);
116 #endif
117 /* IRIX */
118 #ifdef SIGCKPT
119 ASSERT (strcmp (sigdescr_np (SIGCKPT), "Checkpoint") == 0);
120 #endif
121 /* AIX */
122 #ifdef SIGCPUFAIL
123 ASSERT (strcmp (sigdescr_np (SIGCPUFAIL), "CPU going down") == 0);
124 #endif
125 /* AIX */
126 #ifdef SIGDANGER
127 ASSERT (strcmp (sigdescr_np (SIGDANGER), "Swap space nearly exhausted") == 0);
128 #endif
129 /* Mac OS X, FreeBSD, NetBSD, OpenBSD, Minix, AIX, IRIX, Cygwin, mingw */
130 #ifdef SIGEMT
131 ASSERT (strcmp (sigdescr_np (SIGEMT), "Instruction emulation needed") == 0);
132 #endif
133 /* Mac OS X, FreeBSD, NetBSD, OpenBSD, Minix */
134 #ifdef SIGINFO
135 ASSERT (strcmp (sigdescr_np (SIGINFO), "Information request") == 0);
136 #endif
137 /* AIX */
138 #ifdef SIGKAP
139 ASSERT (strcmp (sigdescr_np (SIGKAP), "Keep Alive Poll") == 0);
140 #endif
141 /* Haiku */
142 #ifdef SIGKILLTHR
143 ASSERT (strcmp (sigdescr_np (SIGKILLTHR), "Kill thread") == 0);
144 #endif
145 /* Minix */
146 #ifdef SIGKMEM
147 ASSERT (strcmp (sigdescr_np (SIGKMEM), "Kernel memory request") == 0);
148 #endif
149 /* Minix */
150 #ifdef SIGKMESS
151 ASSERT (strcmp (sigdescr_np (SIGKMESS), "Kernel message") == 0);
152 #endif
153 /* Minix */
154 #ifdef SIGKSIG
155 ASSERT (strcmp (sigdescr_np (SIGKSIG), "Kernel signal") == 0);
156 #endif
157 /* Minix */
158 #ifdef SIGKSIGSM
159 ASSERT (strcmp (sigdescr_np (SIGKSIGSM), "Kernel signal for signal manager") == 0);
160 #endif
161 /* FreeBSD */
162 #ifdef SIGLIBRT
163 ASSERT (strcmp (sigdescr_np (SIGLIBRT), "Real-time library interrupt") == 0);
164 #endif
165 /* AIX */
166 #ifdef SIGMIGRATE
167 ASSERT (strcmp (sigdescr_np (SIGMIGRATE), "Process migration") == 0);
168 #endif
169 /* AIX */
170 #ifdef SIGMSG
171 ASSERT (strcmp (sigdescr_np (SIGMSG), "Message in the ring") == 0);
172 #endif
173 /* AIX */
174 #ifdef SIGPRE
175 ASSERT (strcmp (sigdescr_np (SIGPRE), "Programmed exception") == 0);
176 #endif
177 /* IRIX */
178 #ifdef SIGPTINTR
179 ASSERT (strcmp (sigdescr_np (SIGPTINTR), "Pthread interrupt") == 0);
180 #endif
181 /* IRIX */
182 #ifdef SIGPTRESCHED
183 ASSERT (strcmp (sigdescr_np (SIGPTRESCHED), "Pthread rescheduling") == 0);
184 #endif
185 /* Linux, NetBSD, Minix, AIX, IRIX, Cygwin */
186 #ifdef SIGPWR
187 ASSERT (strcmp (sigdescr_np (SIGPWR), "Power failure") == 0);
188 #endif
189 /* AIX */
190 #ifdef SIGRECONFIG
191 ASSERT (strcmp (sigdescr_np (SIGRECONFIG), "Dynamic logical partitioning changed") == 0);
192 #endif
193 /* AIX */
194 #ifdef SIGRECOVERY
195 ASSERT (strcmp (sigdescr_np (SIGRECOVERY), "Kernel recovery") == 0);
196 #endif
197 /* IRIX */
198 #ifdef SIGRESTART
199 ASSERT (strcmp (sigdescr_np (SIGRESTART), "Checkpoint restart") == 0);
200 #endif
201 /* AIX */
202 #ifdef SIGRETRACT
203 ASSERT (strcmp (sigdescr_np (SIGRETRACT), "Retracting Keep Alive Poll") == 0);
204 #endif
205 /* AIX */
206 #ifdef SIGSAK
207 ASSERT (strcmp (sigdescr_np (SIGSAK), "Secure Attention Key") == 0);
208 #endif
209 /* Minix */
210 #ifdef SIGSNDELAY
211 ASSERT (strcmp (sigdescr_np (SIGSNDELAY), "Done sending message") == 0);
212 #endif
213 /* AIX */
214 #ifdef SIGSOUND
215 ASSERT (strcmp (sigdescr_np (SIGSOUND), "Sound configuration changed") == 0);
216 #endif
217 /* Linux */
218 #ifdef SIGSTKFLT
219 ASSERT (strcmp (sigdescr_np (SIGSTKFLT), "Stack fault") == 0);
220 #endif
221 /* AIX */
222 #ifdef SIGSYSERROR
223 ASSERT (strcmp (sigdescr_np (SIGSYSERROR), "Kernel error") == 0);
224 #endif
225 /* AIX */
226 #ifdef SIGTALRM
227 ASSERT (strcmp (sigdescr_np (SIGTALRM), "Thread alarm clock") == 0);
228 #endif
229 /* FreeBSD, OpenBSD */
230 #ifdef SIGTHR
231 ASSERT (strcmp (sigdescr_np (SIGTHR), "Thread library interrupt") == 0);
232 #endif
233 /* IRIX */
234 #ifdef SIGUME
235 ASSERT (strcmp (sigdescr_np (SIGUME), "Uncorrectable memory error") == 0);
236 #endif
237 /* AIX */
238 #ifdef SIGVIRT
239 ASSERT (strcmp (sigdescr_np (SIGVIRT), "Virtual time alarm clock") == 0);
240 #endif
241 /* AIX */
242 #ifdef SIGWAITING
243 ASSERT (strcmp (sigdescr_np (SIGWAITING), "Thread waiting") == 0);
244 #endif
245 /* Linux, Mac OS X, FreeBSD, NetBSD, OpenBSD, Minix, AIX, IRIX, Cygwin, Haiku */
246 #ifdef SIGWINCH
247 ASSERT (strcmp (sigdescr_np (SIGWINCH), "Window changed") == 0 /* glibc */
248 || strcmp (sigdescr_np (SIGWINCH), "Window size changed") == 0);
249 #endif
251 ASSERT (sigdescr_np (-714) == NULL);
253 return 0;