Debian Codegraph @

tests/ts/kill/options

raw
1 #!/bin/bash
2
3 # This file is part of util-linux.
4 #
5 # This file is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
9 #
10 # This file is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
14
15 TS_TOPDIR="${0%/*}/../.."
16 TS_DESC="options"
17
18 . "$TS_TOPDIR/functions.sh"
19 ts_init "$*"
20
21 # make sure we do not use shell built-in command
22 if [ "$TS_USE_SYSTEM_COMMANDS" == "yes" ]; then
23 TS_CMD_KILL="$(which kill)"
24 fi
25
26 ts_check_test_command "$TS_CMD_KILL"
27 ts_check_test_command "$TS_HELPER_SIGRECEIVE"
28
29 . "$TS_SELF/kill_functions.sh"
30
31 all_ok=true
32
33 HELPER_SYMLINK="$(mktemp "${TS_OUTDIR}/opXXXXXXXXXXXXX")"
34 ln -sf "$TS_HELPER_SIGRECEIVE" "$HELPER_SYMLINK"
35
36 try_option()
37 {
38 "$HELPER_SYMLINK" >> $TS_OUTPUT 2>> $TS_ERRLOG &
39 TEST_PID=$!
40 check_test_sigreceive $TEST_PID
41 [ $? -eq 1 ] || echo "${HELPER_SYMLINK##*/} helper did not start" >> "$TS_OUTPUT"
42
43 "$TS_CMD_KILL" "$@" $TEST_PID >> $TS_OUTPUT 2>> $TS_ERRLOG
44 if [ $? -ne 0 ]; then
45 echo "kill $@ did not work" >> "$TS_OUTPUT"
46 all_ok=false
47 fi
48 wait $TEST_PID
49 if [ $? -ne 1 ]; then
50 echo "wait $TEST_PID for $@ did not work" >> "$TS_OUTPUT"
51 all_ok=false
52 fi
53 }
54
55 try_option -s 1
56 try_option --signal 1
57 try_option --signal HUP
58 try_option --signal SIGHUP
59 try_option -1
60 try_option -HUP
61 try_option -SIGHUP
62
63 if $all_ok; then
64 echo 'all ok' >> "$TS_OUTPUT"
65 fi
66 rm -f "$HELPER_SYMLINK"
67
68 ts_finalize