summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorElvira Khabirova <lineprinter0@gmail.com>2020-08-20 14:35:32 +0300
committerElvira Khabirova <lineprinter0@gmail.com>2020-08-21 19:39:53 +0300
commitda08d10fce3b249f27fe99fcaa5e3da834a72236 (patch)
tree1f4c48fa8df4cb85404872812ce098a538666283
parentec595a2381bf444fb59715f2b37fd0e0df0003eb (diff)
downloadstrace-da08d10fce3b249f27fe99fcaa5e3da834a72236.tar.gz
tests: check -n/--syscall-number option
* tests/strace-n.c: New file. * tests/gen_tests.in (strace-n): New entry. * tests/pure_executables.list: Add strace-n. * tests/.gitignore: Likewise.
-rw-r--r--tests/.gitignore1
-rw-r--r--tests/gen_tests.in1
-rwxr-xr-xtests/pure_executables.list1
-rw-r--r--tests/strace-n.c40
4 files changed, 43 insertions, 0 deletions
diff --git a/tests/.gitignore b/tests/.gitignore
index 0031d04d7..34e98320d 100644
--- a/tests/.gitignore
+++ b/tests/.gitignore
@@ -715,6 +715,7 @@ statx
strace--strings-in-hex
strace--strings-in-hex-all
strace--strings-in-hex-non-ascii
+strace-n
strace-x
strace-xx
swap
diff --git a/tests/gen_tests.in b/tests/gen_tests.in
index 6f8e1420e..76e770ba9 100644
--- a/tests/gen_tests.in
+++ b/tests/gen_tests.in
@@ -651,6 +651,7 @@ strace--timestamps-unix-s +strace-ttt.test 0 --timestamps=unix,s
strace--timestamps-unix-ms +strace-ttt.test 3 --timestamps=unix,ms
strace--timestamps-unix-us +strace-ttt.test 6 --timestamps=unix,us
strace--timestamps-unix-ns +strace-ttt.test 9 --timestamps=unix,ns
+strace-n -e trace=listen -n -qq -a 12
strace-x -e trace=chdir -x -a 12
strace-xx -e trace=chdir -xx -a 18
swap -a23 -e trace=swapon,swapoff
diff --git a/tests/pure_executables.list b/tests/pure_executables.list
index 01619fcf0..79e5b7588 100755
--- a/tests/pure_executables.list
+++ b/tests/pure_executables.list
@@ -578,6 +578,7 @@ statx
strace--strings-in-hex
strace--strings-in-hex-all
strace--strings-in-hex-non-ascii
+strace-n
strace-x
strace-xx
swap
diff --git a/tests/strace-n.c b/tests/strace-n.c
new file mode 100644
index 000000000..452bd4ca1
--- /dev/null
+++ b/tests/strace-n.c
@@ -0,0 +1,40 @@
+/*
+ * Test strace's -n option.
+ *
+ * Copyright (c) 2020 The strace developers.
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#include "tests.h"
+#include "scno.h"
+
+#include <stdio.h>
+#include <unistd.h>
+#include <errno.h>
+
+#define SC_listen 4
+
+int
+main(void)
+{
+ int rc;
+
+#if defined __NR_socketcall
+ if (syscall(__NR_socketcall, 0L, 0L, 0L, 0L, 0L) < 0
+ && EINVAL == errno)
+ {
+ const long args[] = { 0, 0 };
+ rc = syscall(__NR_socketcall, SC_listen, args);
+ printf("[%4u] listen(0, 0) = %s\n", __NR_socketcall, sprintrc(rc));
+ }
+#endif
+
+#if defined __NR_listen
+ rc = syscall(__NR_listen, 0, 0);
+ printf("[%4u] listen(0, 0) = %s\n", __NR_listen, sprintrc(rc));
+#endif
+
+ return 0;
+}