]> Savannah Git Hosting - gnulib.git/commitdiff
sigabbrev_np: Add tests.
authorBruno Haible <bruno@clisp.org>
Thu, 20 Aug 2020 22:55:43 +0000 (00:55 +0200)
committerBruno Haible <bruno@clisp.org>
Thu, 20 Aug 2020 23:18:14 +0000 (01:18 +0200)
* tests/test-sigabbrev_np.c: New file.
* modules/sigabbrev_np-tests: New file.

ChangeLog
modules/sigabbrev_np-tests [new file with mode: 0644]
tests/test-sigabbrev_np.c [new file with mode: 0644]

index 8e071bf8dd117dfb60a79e56d437d0b398c99619..00ab2f5319a9595317cb796fb6c526f78a08a91a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
 2020-08-20  Bruno Haible  <bruno@clisp.org>
 
+       sigabbrev_np: Add tests.
+       * tests/test-sigabbrev_np.c: New file.
+       * modules/sigabbrev_np-tests: New file.
+
        sigabbrev_np: New module.
        * lib/string.in.h (sigabbrev_np): New declaration.
        * lib/sigabbrev_np.c: New file.
diff --git a/modules/sigabbrev_np-tests b/modules/sigabbrev_np-tests
new file mode 100644 (file)
index 0000000..04fbb68
--- /dev/null
@@ -0,0 +1,12 @@
+Files:
+tests/test-sigabbrev_np.c
+tests/signature.h
+tests/macros.h
+
+Depends-on:
+
+configure.ac:
+
+Makefile.am:
+TESTS += test-sigabbrev_np
+check_PROGRAMS += test-sigabbrev_np
diff --git a/tests/test-sigabbrev_np.c b/tests/test-sigabbrev_np.c
new file mode 100644 (file)
index 0000000..ca38813
--- /dev/null
@@ -0,0 +1,251 @@
+/* Test of sigabbrev_np() function.
+
+   Copyright (C) 2020 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 (sigabbrev_np, const char *, (int));
+
+#include <signal.h>
+
+#include "macros.h"
+
+int
+main (void)
+{
+  /* Signals specified by ISO C.  */
+  ASSERT (strcmp (sigabbrev_np (SIGABRT), "ABRT") == 0);
+  ASSERT (strcmp (sigabbrev_np (SIGFPE), "FPE") == 0);
+  ASSERT (strcmp (sigabbrev_np (SIGILL), "ILL") == 0);
+  ASSERT (strcmp (sigabbrev_np (SIGINT), "INT") == 0);
+  ASSERT (strcmp (sigabbrev_np (SIGSEGV), "SEGV") == 0);
+  ASSERT (strcmp (sigabbrev_np (SIGTERM), "TERM") == 0);
+
+  /* Signals specified by POSIX.
+     <https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/signal.h.html>  */
+  #ifdef SIGALRM
+  ASSERT (strcmp (sigabbrev_np (SIGALRM), "ALRM") == 0);
+  #endif
+  #ifdef SIGBUS
+  ASSERT (strcmp (sigabbrev_np (SIGBUS), "BUS") == 0);
+  #endif
+  #ifdef SIGCHLD
+  ASSERT (strcmp (sigabbrev_np (SIGCHLD), "CHLD") == 0);
+  #endif
+  #ifdef SIGCONT
+  ASSERT (strcmp (sigabbrev_np (SIGCONT), "CONT") == 0);
+  #endif
+  #ifdef SIGHUP
+  ASSERT (strcmp (sigabbrev_np (SIGHUP), "HUP") == 0);
+  #endif
+  #ifdef SIGKILL
+  ASSERT (strcmp (sigabbrev_np (SIGKILL), "KILL") == 0);
+  #endif
+  #ifdef SIGPIPE
+  ASSERT (strcmp (sigabbrev_np (SIGPIPE), "PIPE") == 0);
+  #endif
+  #ifdef SIGQUIT
+  ASSERT (strcmp (sigabbrev_np (SIGQUIT), "QUIT") == 0);
+  #endif
+  #ifdef SIGSTOP
+  ASSERT (strcmp (sigabbrev_np (SIGSTOP), "STOP") == 0);
+  #endif
+  #ifdef SIGTSTP
+  ASSERT (strcmp (sigabbrev_np (SIGTSTP), "TSTP") == 0);
+  #endif
+  #ifdef SIGTTIN
+  ASSERT (strcmp (sigabbrev_np (SIGTTIN), "TTIN") == 0);
+  #endif
+  #ifdef SIGTTOU
+  ASSERT (strcmp (sigabbrev_np (SIGTTOU), "TTOU") == 0);
+  #endif
+  #ifdef SIGUSR1
+  ASSERT (strcmp (sigabbrev_np (SIGUSR1), "USR1") == 0);
+  #endif
+  #ifdef SIGUSR2
+  ASSERT (strcmp (sigabbrev_np (SIGUSR2), "USR2") == 0);
+  #endif
+  #ifdef SIGPOLL
+  ASSERT (strcmp (sigabbrev_np (SIGPOLL), "POLL") == 0);
+  #endif
+  #ifdef SIGPROF
+  ASSERT (strcmp (sigabbrev_np (SIGPROF), "PROF") == 0);
+  #endif
+  #ifdef SIGSYS
+  ASSERT (strcmp (sigabbrev_np (SIGSYS), "SYS") == 0);
+  #endif
+  #ifdef SIGTRAP
+  ASSERT (strcmp (sigabbrev_np (SIGTRAP), "TRAP") == 0);
+  #endif
+  #ifdef SIGURG
+  ASSERT (strcmp (sigabbrev_np (SIGURG), "URG") == 0);
+  #endif
+  #ifdef SIGVTALRM
+  ASSERT (strcmp (sigabbrev_np (SIGVTALRM), "VTALRM") == 0);
+  #endif
+  #ifdef SIGXCPU
+  ASSERT (strcmp (sigabbrev_np (SIGXCPU), "XCPU") == 0);
+  #endif
+  #ifdef SIGXFSZ
+  ASSERT (strcmp (sigabbrev_np (SIGXFSZ), "XFSZ") == 0);
+  #endif
+
+  /* Other signals on other systems.  */
+  /* native Windows */
+  #ifdef SIGBREAK
+  ASSERT (strcmp (sigabbrev_np (SIGBREAK), "BREAK") == 0);
+  #endif
+  /* IRIX */
+  #ifdef SIGCKPT
+  ASSERT (strcmp (sigabbrev_np (SIGCKPT), "CKPT") == 0);
+  #endif
+  /* AIX */
+  #ifdef SIGCPUFAIL
+  ASSERT (strcmp (sigabbrev_np (SIGCPUFAIL), "CPUFAIL") == 0);
+  #endif
+  /* AIX */
+  #ifdef SIGDANGER
+  ASSERT (strcmp (sigabbrev_np (SIGDANGER), "DANGER") == 0);
+  #endif
+  /* Mac OS X, FreeBSD, NetBSD, OpenBSD, Minix, AIX, IRIX, Cygwin, mingw */
+  #ifdef SIGEMT
+  ASSERT (strcmp (sigabbrev_np (SIGEMT), "EMT") == 0);
+  #endif
+  /* Mac OS X, FreeBSD, NetBSD, OpenBSD, Minix */
+  #ifdef SIGINFO
+  ASSERT (strcmp (sigabbrev_np (SIGINFO), "INFO") == 0);
+  #endif
+  /* AIX */
+  #ifdef SIGKAP
+  ASSERT (strcmp (sigabbrev_np (SIGKAP), "KAP") == 0);
+  #endif
+  /* Haiku */
+  #ifdef SIGKILLTHR
+  ASSERT (strcmp (sigabbrev_np (SIGKILLTHR), "KILLTHR") == 0);
+  #endif
+  /* Minix */
+  #ifdef SIGKMEM
+  ASSERT (strcmp (sigabbrev_np (SIGKMEM), "KMEM") == 0);
+  #endif
+  /* Minix */
+  #ifdef SIGKMESS
+  ASSERT (strcmp (sigabbrev_np (SIGKMESS), "KMESS") == 0);
+  #endif
+  /* Minix */
+  #ifdef SIGKSIG
+  ASSERT (strcmp (sigabbrev_np (SIGKSIG), "KSIG") == 0);
+  #endif
+  /* Minix */
+  #ifdef SIGKSIGSM
+  ASSERT (strcmp (sigabbrev_np (SIGKSIGSM), "KSIGSM") == 0);
+  #endif
+  /* FreeBSD */
+  #ifdef SIGLIBRT
+  ASSERT (strcmp (sigabbrev_np (SIGLIBRT), "LIBRT") == 0);
+  #endif
+  /* AIX */
+  #ifdef SIGMIGRATE
+  ASSERT (strcmp (sigabbrev_np (SIGMIGRATE), "MIGRATE") == 0);
+  #endif
+  /* AIX */
+  #ifdef SIGMSG
+  ASSERT (strcmp (sigabbrev_np (SIGMSG), "MSG") == 0);
+  #endif
+  /* AIX */
+  #ifdef SIGPRE
+  ASSERT (strcmp (sigabbrev_np (SIGPRE), "PRE") == 0);
+  #endif
+  /* IRIX */
+  #ifdef SIGPTINTR
+  ASSERT (strcmp (sigabbrev_np (SIGPTINTR), "PTINTR") == 0);
+  #endif
+  /* IRIX */
+  #ifdef SIGPTRESCHED
+  ASSERT (strcmp (sigabbrev_np (SIGPTRESCHED), "PTRESCHED") == 0);
+  #endif
+  /* Linux, NetBSD, Minix, AIX, IRIX, Cygwin */
+  #ifdef SIGPWR
+  ASSERT (strcmp (sigabbrev_np (SIGPWR), "PWR") == 0);
+  #endif
+  /* AIX */
+  #ifdef SIGRECONFIG
+  ASSERT (strcmp (sigabbrev_np (SIGRECONFIG), "RECONFIG") == 0);
+  #endif
+  /* AIX */
+  #ifdef SIGRECOVERY
+  ASSERT (strcmp (sigabbrev_np (SIGRECOVERY), "RECOVERY") == 0);
+  #endif
+  /* IRIX */
+  #ifdef SIGRESTART
+  ASSERT (strcmp (sigabbrev_np (SIGRESTART), "RESTART") == 0);
+  #endif
+  /* AIX */
+  #ifdef SIGRETRACT
+  ASSERT (strcmp (sigabbrev_np (SIGRETRACT), "RETRACT") == 0);
+  #endif
+  /* AIX */
+  #ifdef SIGSAK
+  ASSERT (strcmp (sigabbrev_np (SIGSAK), "SAK") == 0);
+  #endif
+  /* Minix */
+  #ifdef SIGSNDELAY
+  ASSERT (strcmp (sigabbrev_np (SIGSNDELAY), "SNDELAY") == 0);
+  #endif
+  /* AIX */
+  #ifdef SIGSOUND
+  ASSERT (strcmp (sigabbrev_np (SIGSOUND), "SOUND") == 0);
+  #endif
+  /* Linux */
+  #ifdef SIGSTKFLT
+  ASSERT (strcmp (sigabbrev_np (SIGSTKFLT), "STKFLT") == 0);
+  #endif
+  /* AIX */
+  #ifdef SIGSYSERROR
+  ASSERT (strcmp (sigabbrev_np (SIGSYSERROR), "SYSERROR") == 0);
+  #endif
+  /* AIX */
+  #ifdef SIGTALRM
+  ASSERT (strcmp (sigabbrev_np (SIGTALRM), "TALRM") == 0);
+  #endif
+  /* FreeBSD, OpenBSD */
+  #ifdef SIGTHR
+  ASSERT (strcmp (sigabbrev_np (SIGTHR), "THR") == 0);
+  #endif
+  /* IRIX */
+  #ifdef SIGUME
+  ASSERT (strcmp (sigabbrev_np (SIGUME), "UME") == 0);
+  #endif
+  /* AIX */
+  #ifdef SIGVIRT
+  ASSERT (strcmp (sigabbrev_np (SIGVIRT), "VIRT") == 0);
+  #endif
+  /* AIX */
+  #ifdef SIGWAITING
+  ASSERT (strcmp (sigabbrev_np (SIGWAITING), "WAITING") == 0);
+  #endif
+  /* Linux, Mac OS X, FreeBSD, NetBSD, OpenBSD, Minix, AIX, IRIX, Cygwin, Haiku */
+  #ifdef SIGWINCH
+  ASSERT (strcmp (sigabbrev_np (SIGWINCH), "WINCH") == 0);
+  #endif
+
+  ASSERT (sigabbrev_np (-714) == NULL);
+
+  return 0;
+}