]> git.ipfire.org Git - thirdparty/util-linux.git/blame - tests/ts/kill/all_processes
tests: (kill) do not use shell build-in
[thirdparty/util-linux.git] / tests / ts / kill / all_processes
CommitLineData
2556c387
SK
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
15TS_TOPDIR="${0%/*}/../.."
16TS_DESC="all_processes"
17
18. "$TS_TOPDIR/functions.sh"
19ts_init "$*"
20
21ts_skip_nonroot
22
2fadcded
KZ
23# make sure we do not use shell built-in command
24if [ "$TS_USE_SYSTEM_COMMANDS" == "yes" ]; then
25 TS_CMD_KILL="/bin/kill"
26fi
27
2556c387
SK
28ts_check_test_command "$TS_CMD_KILL"
29ts_check_test_command "$TS_HELPER_SIGRECEIVE"
30
7a1c980c
KZ
31. "$TS_SELF/kill_functions.sh"
32
48f9e0b2
RM
33HELPER_SYMLINK="$(mktemp "${TS_OUTDIR}/alXXXXXXXXXXXXX")"
34ln -sf "$TS_HELPER_SIGRECEIVE" "$HELPER_SYMLINK"
2556c387
SK
35
36"$HELPER_SYMLINK" -s "$TS_TESTUSER" >> "$TS_OUTPUT" 2>&1 &
37TEST_PID=$!
38
7a1c980c
KZ
39check_test_sigreceive $TEST_PID
40[ $? -eq 1 ] || echo "${HELPER_SYMLINK##*/} helper did not start" >> "$TS_OUTPUT"
41
2556c387
SK
42echo "test 1" >> "$TS_OUTPUT"
43"$TS_CMD_KILL" ${HELPER_SYMLINK##*/} >> "$TS_OUTPUT" 2>&1
44if [ $? -ne 1 ]; then
45 echo "kill did not return 1" >> "$TS_OUTPUT"
46fi
be8d50fe 47
2556c387
SK
48echo "test 2" >> "$TS_OUTPUT"
49"$TS_CMD_KILL" -a ${HELPER_SYMLINK##*/} >> "$TS_OUTPUT" 2>&1
50if [ $? -ne 0 ]; then
51 echo "kill did not return 0" >> "$TS_OUTPUT"
52fi
be8d50fe
RM
53wait $TEST_PID
54
2556c387
SK
55echo "test 3" >> "$TS_OUTPUT"
56"$TS_CMD_KILL" -a -p ${HELPER_SYMLINK##*/} >> "$TS_OUTPUT" 2>&1
57if [ $? -ne 1 ]; then
58 echo "kill -a -p did not return 1" >> "$TS_OUTPUT"
59fi
60
61sed -i "s/${HELPER_SYMLINK##*/}/${TS_HELPER_SIGRECEIVE##*/}/" "$TS_OUTPUT"
62
48f9e0b2
RM
63rm -f "$HELPER_SYMLINK"
64
2556c387 65ts_finalize