]> granicus.if.org Git - strace/commitdiff
tests: check that printsignal handles xlat styles properly
authorShankara Pailoor <shankarapailoor@gmail.com>
Thu, 20 Dec 2018 13:27:40 +0000 (05:27 -0800)
committerDmitry V. Levin <ldv@altlinux.org>
Mon, 17 Dec 2018 19:19:23 +0000 (19:19 +0000)
* tests/printsignal.c: New file.
* tests/Makefile.am (EXTRA_DIST): Add it.
* tests/printsignal-Xabbrev.c: New file.
* tests/printsignal-Xraw.c: Likewise.
* tests/printsignal-Xverbose.c: Likewise.
* tests/gen_tests.in (printsignal-Xabbrev, printsignal-Xraw,
printsignal-Xverbose): New tests.
* tests/pure_executables.list: Add printsignal-Xabbrev,
* printsignal-Xraw, and printsignal-Xverbose.
* tests/.gitignore: Likewise.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
tests/.gitignore
tests/Makefile.am
tests/gen_tests.in
tests/printsignal-Xabbrev.c [new file with mode: 0644]
tests/printsignal-Xraw.c [new file with mode: 0644]
tests/printsignal-Xverbose.c [new file with mode: 0644]
tests/printsignal.c [new file with mode: 0644]
tests/pure_executables.list

index 918b95be0dd1e9f7dd2ba0d987b6d0a6829d2045..d5bc1bd67294645386dc894ce7d477db5414017d 100644 (file)
@@ -391,6 +391,9 @@ print_maxfd
 printpath-umovestr
 printpath-umovestr-peekdata
 printpath-umovestr-undumpable
+printsignal-Xabbrev
+printsignal-Xraw
+printsignal-Xverbose
 printstr
 printstrn-umoven
 printstrn-umoven-peekdata
index 1f0e5a9c2e1a13605a4d78e49cf6e7219a06a2ba..825c989bb7855ab028513f55dee6901117c80aa4 100644 (file)
@@ -391,6 +391,7 @@ EXTRA_DIST = \
        nlattr_ifla.h \
        pipe.expected \
        print_user_desc.c \
+       printsignal.c \
        process_vm_readv_writev.c \
        pure_executables.list \
        qual_fault-exit_group.expected \
index 9f7e605c706a055cb9fe1cc4e7a511a15f5f888e..037116d39319bf33a57d2559b01eed60be83997c 100644 (file)
@@ -324,6 +324,9 @@ printstr    -e trace=writev
 printpath-umovestr     -a11 -e signal=none -e trace=chdir
 printpath-umovestr-peekdata    -a11 -e signal=none -e trace=chdir
 printpath-umovestr-undumpable  -a11 -e signal=none -e trace=chdir
+printsignal-Xabbrev    -a11 -Xabbrev -e signal=none -e trace=kill
+printsignal-Xraw       -a11 -Xraw -e signal=none -e trace=kill
+printsignal-Xverbose   -a11 -Xverbose -e signal=none -e trace=kill
 printstrn-umoven       -s4096 -e signal=none -e trace=add_key
 printstrn-umoven-peekdata      -e signal=none -e trace=add_key
 printstrn-umoven-undumpable    -e signal=none -e trace=add_key
diff --git a/tests/printsignal-Xabbrev.c b/tests/printsignal-Xabbrev.c
new file mode 100644 (file)
index 0000000..dfd93ee
--- /dev/null
@@ -0,0 +1 @@
+#include "printsignal.c"
diff --git a/tests/printsignal-Xraw.c b/tests/printsignal-Xraw.c
new file mode 100644 (file)
index 0000000..47d75b7
--- /dev/null
@@ -0,0 +1,2 @@
+#define XLAT_RAW 1
+#include "printsignal.c"
diff --git a/tests/printsignal-Xverbose.c b/tests/printsignal-Xverbose.c
new file mode 100644 (file)
index 0000000..4bb1330
--- /dev/null
@@ -0,0 +1,2 @@
+#define XLAT_VERBOSE 1
+#include "printsignal.c"
diff --git a/tests/printsignal.c b/tests/printsignal.c
new file mode 100644 (file)
index 0000000..4f5f986
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2014-2018 The strace developers.
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+#include "tests.h"
+#include <signal.h>
+#include <stdio.h>
+#include <unistd.h>
+
+int
+main(void)
+{
+       const pid_t pid = getpid();
+       int rc = kill(pid, SIGCONT);
+#if XLAT_RAW
+       printf("kill(%d, %d) = %s\n", pid, SIGCONT, sprintrc(rc));
+#elif XLAT_VERBOSE
+       printf("kill(%d, %d /* SIGCONT */) = %s\n", pid, SIGCONT, sprintrc(rc));
+#else /* XLAT_ABBREV */
+       printf("kill(%d, SIGCONT) = %s\n", pid, sprintrc(rc));
+#endif
+
+       static const int sigs[] = { 0, 256, -1 };
+       for (unsigned int i = 0; i < ARRAY_SIZE(sigs); ++i) {
+               rc = kill(pid, sigs[i]);
+               printf("kill(%d, %d) = %s\n", pid, sigs[i], sprintrc(rc));
+       }
+
+       printf("+++ exited with 0 +++\n");
+       return 0;
+}
index b8120f2b41277929c2462be0035eea2aa4636218..d7c8ae00432878551f0f169871f23f413b36c55f 100755 (executable)
@@ -327,6 +327,9 @@ preadv2-pwritev2
 printpath-umovestr
 printpath-umovestr-peekdata
 printpath-umovestr-undumpable
+printsignal-Xabbrev
+printsignal-Xraw
+printsignal-Xverbose
 printstr
 printstrn-umoven
 printstrn-umoven-peekdata