]> git.ipfire.org Git - thirdparty/util-linux.git/blame - tests/ts/kill/name_to_number
tests: kill_functions.sh needs gawk (skip if sourced)
[thirdparty/util-linux.git] / tests / ts / kill / name_to_number
CommitLineData
d39182c1
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="name_to_number"
17
18. "$TS_TOPDIR/functions.sh"
19ts_init "$*"
20
21ts_check_test_command "$TS_CMD_KILL"
22ts_check_test_command "$TS_HELPER_SIGRECEIVE"
23
7a1c980c
KZ
24. "$TS_SELF/kill_functions.sh"
25
d39182c1
SK
26all_ok=true
27HELPER_SYMLINK="$TS_OUTDIR/$(mktemp -u XXXXXXXXXXXXXXX)"
28ln -s "$TS_HELPER_SIGRECEIVE" "$HELPER_SYMLINK"
29
30for SIG in $($TS_CMD_KILL -L); do
31 if [ "x${SIG//[0-9]/}" = "x" ]; then
32 EXPECTED=$SIG
33 continue
34 fi
35 if [ "x$SIG" = "xSTOP" ] || [ "x$SIG" = "xKILL" ]; then
36 continue
37 fi
38 if [ "x$SIG" = "xRTMIN" ]; then
39 SIG="$SIG+0"
40 fi
41 if [ "x$SIG" = "xRTMAX" ]; then
42 SIG="$SIG-0"
43 fi
7a1c980c 44
d39182c1
SK
45 "$HELPER_SYMLINK" >> "$TS_OUTPUT" 2>&1 &
46 TEST_PID=$!
7a1c980c
KZ
47 check_test_sigreceive $TEST_PID
48 [ $? -eq 1 ] || echo "${HELPER_SYMLINK##*/} helper did not start" >> "$TS_OUTPUT"
49
d39182c1
SK
50 "$TS_CMD_KILL" -$SIG ${HELPER_SYMLINK##*/} >> "$TS_OUTPUT" 2>&1
51 wait $TEST_PID
52 if [ $? -ne $EXPECTED ]; then
53 echo "$SIG returned $? while $EXPECTED was expected" >> "$TS_OUTPUT"
54 all_ok=false
55 fi
56done
57
58if $all_ok; then
59 echo 'all ok' >> $TS_OUTPUT
60fi
61rm -f "$HELPER_SYMLINK"
62
63ts_finalize