]> git.ipfire.org Git - thirdparty/util-linux.git/blob - tests/ts/kill/name_to_number
cde55c9ed83538912d8a7ad2f6a5cc6e5b27ab4c
[thirdparty/util-linux.git] / tests / ts / kill / name_to_number
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="name_to_number"
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}/naXXXXXXXXXXXXX")"
29 ln -sf "$TS_HELPER_SIGRECEIVE" "$HELPER_SYMLINK"
30
31 for SIG in $($TS_CMD_KILL -L); do
32 if [ "x${SIG//[0-9]/}" = "x" ]; then
33 EXPECTED=$SIG
34 continue
35 fi
36 if [ -f "$ASAN_SYMBOLIZER_PATH" ] && [ "x$SIG" = "xSEGV" ]; then
37 continue
38 fi
39 if [ "x$SIG" = "xSTOP" ] || [ "x$SIG" = "xKILL" ]; then
40 continue
41 fi
42 if [ "x$SIG" = "xRTMIN" ]; then
43 SIG="$SIG+0"
44 fi
45 if [ "x$SIG" = "xRTMAX" ]; then
46 SIG="$SIG-0"
47 fi
48
49 "$HELPER_SYMLINK" >> "$TS_OUTPUT" 2>&1 &
50 TEST_PID=$!
51 check_test_sigreceive $TEST_PID
52 [ $? -eq 1 ] || echo "${HELPER_SYMLINK##*/} helper did not start" >> "$TS_OUTPUT"
53
54 "$TS_CMD_KILL" -$SIG ${HELPER_SYMLINK##*/} >> "$TS_OUTPUT" 2>&1
55 wait $TEST_PID
56 if [ $? -ne $EXPECTED ]; then
57 echo "$SIG returned $? while $EXPECTED was expected" >> "$TS_OUTPUT"
58 all_ok=false
59 fi
60 done
61
62 if $all_ok; then
63 echo 'all ok' >> "$TS_OUTPUT"
64 fi
65 rm -f "$HELPER_SYMLINK"
66
67 ts_finalize