Browse Source

tests: enhance termination signal forwarding check

Check that termination signal forwarding works properly when strace
is invoked with the corresponding termination signal blocked.

* tests/block_reset_run.c: New file.
* tests/Makefile.am (check_PROGRAMS): Add block_reset_run.
* tests/.gitignore: Likewise.
* tests/termsig.test: Extend the check to cover the case when
strace is invoked with the termination signal blocked.
Dmitry V. Levin 1 month ago
parent
commit
83826933ca
4 changed files with 44 additions and 1 deletions
  1. 1
    0
      tests/.gitignore
  2. 1
    0
      tests/Makefile.am
  3. 33
    0
      tests/block_reset_run.c
  4. 9
    1
      tests/termsig.test

+ 1
- 0
tests/.gitignore View File

@@ -20,6 +20,7 @@ attach-f-p-cmd
20 20
 attach-p-cmd-cmd
21 21
 attach-p-cmd-p
22 22
 block_reset_raise_run
23
+block_reset_run
23 24
 bpf
24 25
 bpf-obj_get_info_by_fd
25 26
 bpf-obj_get_info_by_fd-prog

+ 1
- 0
tests/Makefile.am View File

@@ -77,6 +77,7 @@ check_PROGRAMS = $(PURE_EXECUTABLES) \
77 77
 	attach-p-cmd-cmd \
78 78
 	attach-p-cmd-p \
79 79
 	block_reset_raise_run \
80
+	block_reset_run \
80 81
 	bpf-obj_get_info_by_fd \
81 82
 	bpf-obj_get_info_by_fd-prog \
82 83
 	bpf-obj_get_info_by_fd-prog-v \

+ 33
- 0
tests/block_reset_run.c View File

@@ -0,0 +1,33 @@
1
+/*
2
+ * Execute the specified command with a blocked default signal handler.
3
+ *
4
+ * Copyright (c) 2017-2019 Dmitry V. Levin <ldv@altlinux.org>
5
+ * All rights reserved.
6
+ *
7
+ * SPDX-License-Identifier: GPL-2.0-or-later
8
+ */
9
+
10
+#include "tests.h"
11
+#include <signal.h>
12
+#include <stdlib.h>
13
+#include <unistd.h>
14
+
15
+int
16
+main(int ac, char **av)
17
+{
18
+	if (ac < 3)
19
+		error_msg_and_fail("usage: block_reset_run signo path...");
20
+
21
+	sigset_t mask;
22
+	sigemptyset(&mask);
23
+	const int signo = atoi(av[1]);
24
+	if (sigaddset(&mask, signo))
25
+		perror_msg_and_fail("sigaddset: %s", av[1]);
26
+	if (sigprocmask(SIG_BLOCK, &mask, NULL))
27
+		perror_msg_and_fail("sigprocmask");
28
+	if (signal(signo, SIG_DFL) == SIG_ERR)
29
+		perror_msg_and_fail("signal: %s", av[1]);
30
+
31
+	execvp(av[2], av + 2);
32
+	perror_msg_and_fail("execvp: %s", av[2]);
33
+}

+ 9
- 1
tests/termsig.test View File

@@ -11,10 +11,18 @@
11 11
 
12 12
 run_expect_termsig="../run_expect_termsig 15"
13 13
 unblock_reset_raise="../unblock_reset_raise 15"
14
+block_reset_run="../block_reset_run 15"
15
+orig_STRACE="$STRACE"
14 16
 
17
+run_prog $run_expect_termsig $block_reset_run $unblock_reset_raise
15 18
 run_prog $run_expect_termsig $unblock_reset_raise
16
-STRACE="$run_expect_termsig $STRACE"
17 19
 
20
+STRACE="$run_expect_termsig $orig_STRACE"
21
+for i in 1 2 3 4; do
22
+	run_strace -I$i -enone -esignal=none $unblock_reset_raise
23
+done
24
+
25
+STRACE="$run_expect_termsig $block_reset_run $orig_STRACE"
18 26
 for i in 1 2 3 4; do
19 27
 	run_strace -I$i -enone -esignal=none $unblock_reset_raise
20 28
 done

Loading…
Cancel
Save