]> git.ipfire.org Git - thirdparty/util-linux.git/blob - tests/ts/kill/options
2c82bbccc5da4babae728628fb8a2acb3610616e
[thirdparty/util-linux.git] / tests / ts / kill / options
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 ts_check_test_command "$TS_CMD_KILL"
22 ts_check_test_command "$TS_HELPER_SIGRECEIVE"
23
24 . "$TS_SELF/kill_functions.sh"
25
26 all_ok=true
27
28 HELPER_SYMLINK="$(mktemp "${TS_OUTDIR}/opXXXXXXXXXXXXX")"
29 ln -sf "$TS_HELPER_SIGRECEIVE" "$HELPER_SYMLINK"
30
31 try_option()
32 {
33 "$HELPER_SYMLINK" >> "$TS_OUTPUT" 2>&1 &
34 TEST_PID=$!
35 check_test_sigreceive $TEST_PID
36 [ $? -eq 1 ] || echo "${HELPER_SYMLINK##*/} helper did not start" >> "$TS_OUTPUT"
37
38 "$TS_CMD_KILL" "$@" $TEST_PID >> "$TS_OUTPUT" 2>&1
39 if [ $? -ne 0 ]; then
40 echo "kill $@ did not work" >> "$TS_OUTPUT"
41 all_ok=false
42 fi
43 wait $TEST_PID
44 if [ $? -ne 1 ]; then
45 echo "wait $TEST_PID for $@ did not work" >> "$TS_OUTPUT"
46 all_ok=false
47 fi
48 }
49
50 try_option -s 1
51 try_option --signal 1
52 try_option --signal HUP
53 try_option --signal SIGHUP
54 try_option -1
55 try_option -HUP
56 try_option -SIGHUP
57
58 if $all_ok; then
59 echo 'all ok' >> "$TS_OUTPUT"
60 fi
61 rm -f "$HELPER_SYMLINK"
62
63 ts_finalize