]> granicus.if.org Git - strace/blob - tests/qual_signal.test
516bec1c8f1c607c2d24a5a8a070ab9ebafe9a7e
[strace] / tests / qual_signal.test
1 #!/bin/sh
2 #
3 # Check how strace -e signal=set works.
4 #
5 # Copyright (c) 2016 Dmitry V. Levin <ldv@altlinux.org>
6 # Copyright (c) 2016-2017 The strace developers.
7 # All rights reserved.
8 #
9 # SPDX-License-Identifier: GPL-2.0-or-later
10
11 . "${srcdir=.}/init.sh"
12
13 test_one_sig()
14 {
15         local sigs
16         sigs="$1"; shift
17
18         run_prog "../$NAME" "$@" > /dev/null
19         run_strace -e trace=none -e signal="$sigs" "../$NAME" "$@" > "$EXP"
20         match_diff "$LOG" "$EXP"
21 }
22
23 test_sigs()
24 {
25         local first second sigs
26         first="$1"; shift
27         second="$1"; shift
28
29         for sigs; do
30                 test_one_sig "$sigs" 2 "$first" 15 "$second"
31         done
32 }
33
34 test_sigs '' '' \
35         none '!all' \
36         CHLD SIGCHLD ALRM SIGALRM \
37         chld sigchld alrm sigalrm \
38         CHLD,SIGALRM ALRM,SIGCHLD \
39         chld,sigalrm alrm,sigchld \
40         9 9,4 9,4,11 \
41         4,CHLD,11,ALRM,9 \
42         '!2,15' '!INT,TERM' '!SIGINT,TERM' '!INT,SIGTERM' '!SIGTERM,SIGINT' \
43         '!2,INT,TERM' '!2,SIGTERM' '!SIGINT,15' '!INT,SIGTERM,15' \
44         '!2,4,15' '!15,9,2,11,4'
45
46 test_sigs SIGINT '' \
47         2 INT SIGINT \
48         CHLD,SIGINT SIGINT,SIGALRM \
49         chld,sigint sigint,sigalrm \
50         ALRM,2,SIGCHLD \
51         '!15' '!TERM' '!SIGTERM' \
52         '!15,TERM' '!SIGTERM,15,TERM' \
53         '!SIGALRM,TERM' '!CHLD,SIGTERM' \
54         '!ALRM,15' '!SIGCHLD,ALRM,SIGTERM,KILL' \
55         '!4,15' '!15,9,11,4'
56
57 test_sigs '' SIGTERM \
58         15 TERM SIGTERM \
59         CHLD,SIGTERM SIGTERM,SIGALRM \
60         chld,sigterm sigterm,sigalrm \
61         ALRM,15,SIGCHLD \
62         '!2' '!INT' '!SIGINT' \
63         '!2,INT' '!SIGINT,2,INT' \
64         '!SIGALRM,INT' '!CHLD,SIGINT' \
65         '!ALRM,2' '!SIGCHLD,ALRM,SIGINT,KILL' \
66         '!4,2' '!2,9,11,4'
67
68 test_sigs SIGINT SIGTERM \
69         all '!none' \
70         INT,TERM SIGINT,TERM SIGTERM,INT SIGINT,SIGTERM \
71         int,term sigint,term sigterm,int sigint,sigterm \
72         2,15 2,TERM SIGTERM,2 TERM,15,SIGINT,2 \
73         '!CHLD' '!SIGCHLD' '!ALRM' '!SIGALRM' \
74         '!CHLD,SIGALRM' '!ALRM,SIGCHLD' \
75         '!9' '!9,4' '!9,4,11' '!4,CHLD,11,ALRM,9'
76
77 fail_with()
78 {
79         dump_log_and_fail_with \
80                 "strace -e signal=$* failed to handle an argument error properly"
81 }
82
83 for arg in ' ' invalid_signal_name SIG -1 256 1-1 \
84            1,2,4,8,16,32,64,128,256,512,1024 9,chdir; do
85         $STRACE -e signal="$arg" true 2> "$LOG" &&
86                 fail_with "$arg"
87         LC_ALL=C grep -F 'invalid signal' < "$LOG" > /dev/null ||
88                 fail_with "$arg"
89 done
90
91 exit 0