1 /* Test of strsignal() function.
2 Copyright (C) 2008, 2009 Free Software Foundation, Inc.
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 3, or (at your option)
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software Foundation,
16 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
18 /* Written by Colin Watson <cjwatson@debian.org>, 2008. */
24 #include "signature.h"
25 SIGNATURE_CHECK (strsignal, char *, (int));
31 #define ASSERT(expr) \
36 fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \
43 #if HAVE_DECL_SYS_SIGLIST
44 # define ASSERT_DESCRIPTION(got, expect)
46 /* In this case, we can guarantee some signal descriptions. */
47 # define ASSERT_DESCRIPTION(got, expect) ASSERT (!strcmp (got, expect))
53 /* Work around bug in cygwin 1.5.25 <string.h> by declaring str as
54 const char *, even though strsignal is supposed to return char *.
55 At any rate, this doesn't hurt, since POSIX 200x states that "The
56 string pointed to shall not be modified by the application." */
59 /* We try a couple of signals, since not all signals are supported
60 everywhere. Notwithstanding the #ifdef for neatness, SIGINT should in
61 fact be available on all platforms. */
64 str = strsignal (SIGHUP);
67 ASSERT_DESCRIPTION (str, "Hangup");
71 str = strsignal (SIGINT);
74 ASSERT_DESCRIPTION (str, "Interrupt");
77 /* Test that for out-of-range signal numbers the result is usable. */
81 ASSERT (str != (char *) -1);
82 ASSERT (strlen (str));
84 str = strsignal (9249234);
86 ASSERT (str != (char *) -1);
87 ASSERT (strlen (str));