]> git.ipfire.org Git - thirdparty/util-linux.git/blob - tests/ts/kill/all_processes
Merge branch 'hardlink-import' into hardlink
[thirdparty/util-linux.git] / tests / ts / kill / all_processes
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="all_processes"
17
18 . "$TS_TOPDIR/functions.sh"
19 ts_init "$*"
20
21 ts_skip_nonroot
22
23 ts_check_test_command "$TS_CMD_KILL"
24 ts_check_test_command "$TS_HELPER_SIGRECEIVE"
25
26 . "$TS_SELF/kill_functions.sh"
27
28 HELPER_SYMLINK="$(mktemp "${TS_OUTDIR}/alXXXXXXXXXXXXX")"
29 ln -sf "$TS_HELPER_SIGRECEIVE" "$HELPER_SYMLINK"
30
31 "$HELPER_SYMLINK" -s "$TS_TESTUSER" >> "$TS_OUTPUT" 2>&1 &
32 TEST_PID=$!
33
34 check_test_sigreceive $TEST_PID
35 [ $? -eq 1 ] || echo "${HELPER_SYMLINK##*/} helper did not start" >> "$TS_OUTPUT"
36
37 echo "test 1" >> "$TS_OUTPUT"
38 "$TS_CMD_KILL" ${HELPER_SYMLINK##*/} >> "$TS_OUTPUT" 2>&1
39 if [ $? -ne 1 ]; then
40 echo "kill did not return 1" >> "$TS_OUTPUT"
41 fi
42
43 echo "test 2" >> "$TS_OUTPUT"
44 "$TS_CMD_KILL" -a ${HELPER_SYMLINK##*/} >> "$TS_OUTPUT" 2>&1
45 if [ $? -ne 0 ]; then
46 echo "kill did not return 0" >> "$TS_OUTPUT"
47 fi
48 wait $TEST_PID
49
50 echo "test 3" >> "$TS_OUTPUT"
51 "$TS_CMD_KILL" -a -p ${HELPER_SYMLINK##*/} >> "$TS_OUTPUT" 2>&1
52 if [ $? -ne 1 ]; then
53 echo "kill -a -p did not return 1" >> "$TS_OUTPUT"
54 fi
55
56 sed -i "s/${HELPER_SYMLINK##*/}/${TS_HELPER_SIGRECEIVE##*/}/" "$TS_OUTPUT"
57
58 rm -f "$HELPER_SYMLINK"
59
60 ts_finalize