summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry V. Levin <ldv@altlinux.org>2020-08-01 08:00:00 +0000
committerDmitry V. Levin <ldv@altlinux.org>2020-08-01 08:00:00 +0000
commit26df9a6ad7096d3acaa9107cea603aed7067650b (patch)
treedc65351f5dbfdd324fcf043399de31f0b68defd6
parent591a0ef3278489736850c76b2f691a309b8b03b9 (diff)
downloadstrace-26df9a6ad7096d3acaa9107cea603aed7067650b.tar.gz
tests: check decoding of tkill syscall
* tests/tkill.c: New file. * tests/gen_tests.in (tkill): New entry. * tests/pure_executables.list: Add tkill. * 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/tkill.c60
4 files changed, 63 insertions, 0 deletions
diff --git a/tests/.gitignore b/tests/.gitignore
index 0896b258e..e5d059a78 100644
--- a/tests/.gitignore
+++ b/tests/.gitignore
@@ -740,6 +740,7 @@ timer_xettime
timerfd_xettime
times
times-fail
+tkill
tracer_ppid_pgid_sid
truncate
truncate64
diff --git a/tests/gen_tests.in b/tests/gen_tests.in
index 540ba61b5..2879d6bfe 100644
--- a/tests/gen_tests.in
+++ b/tests/gen_tests.in
@@ -673,6 +673,7 @@ timer_xettime -e trace=timer_create,timer_settime,timer_gettime
timerfd_xettime -e trace=timerfd_create,timerfd_settime,timerfd_gettime
times -esignal=none
times-fail -a12 -e trace=times
+tkill -a12 --signal='!cont'
trace_clock test_trace_expr 'clock_nanosleep|times' -e%clock
trace_creds test_trace_expr '([gs]et[^p]*([gu]id|groups)|caps|prctl|[fl]?chown|print(path-umovestr|strn-umoven)-undumpable|ptrace|quotactl|rt_sigtimedwait|rt_(tg)?sigqueueinfo).*' -e%creds
trace_fstat test_trace_expr '' -e%fstat -v -P stat.sample -P /dev/full
diff --git a/tests/pure_executables.list b/tests/pure_executables.list
index 3bd3d73f5..d709ac62f 100755
--- a/tests/pure_executables.list
+++ b/tests/pure_executables.list
@@ -596,6 +596,7 @@ timer_xettime
timerfd_xettime
times
times-fail
+tkill
truncate
truncate64
ugetrlimit
diff --git a/tests/tkill.c b/tests/tkill.c
new file mode 100644
index 000000000..5f67c9f5e
--- /dev/null
+++ b/tests/tkill.c
@@ -0,0 +1,60 @@
+/*
+ * Check decoding of tkill syscall.
+ *
+ * Copyright (c) 2020 Dmitry V. Levin <ldv@altlinux.org>
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#include "tests.h"
+#include "scno.h"
+
+#ifdef __NR_tkill
+
+# include <signal.h>
+# include <stdio.h>
+# include <unistd.h>
+
+static const char *errstr;
+
+static long
+k_tkill(const unsigned int tid, const unsigned int sig)
+{
+ const kernel_ulong_t fill = (kernel_ulong_t) 0xdefaced00000000ULL;
+ const kernel_ulong_t bad = (kernel_ulong_t) 0xbadc0dedbadc0dedULL;
+ const kernel_ulong_t arg1 = fill | tid;
+ const kernel_ulong_t arg2 = fill | sig;
+ const long rc = syscall(__NR_tkill, arg1, arg2, bad, bad, bad, bad);
+ errstr = sprintrc(rc);
+ return rc;
+}
+
+int
+main(void)
+{
+ const int pid = getpid();
+ const int bad_pid = -1;
+ const int bad_sig = 0xface;
+
+ k_tkill(pid, 0);
+ printf("tkill(%d, 0) = %s\n", pid, errstr);
+
+ k_tkill(pid, SIGCONT);
+ printf("tkill(%d, SIGCONT) = %s\n", pid, errstr);
+
+ k_tkill(bad_pid, bad_sig);
+ printf("tkill(%d, %d) = %s\n", bad_pid, bad_sig, errstr);
+
+ k_tkill(bad_pid, -bad_sig);
+ printf("tkill(%d, %d) = %s\n", bad_pid, -bad_sig, errstr);
+
+ puts("+++ exited with 0 +++");
+ return 0;
+}
+
+#else
+
+SKIP_MAIN_UNDEFINED("__NR_tkill")
+
+#endif