Debian Codegraph @

tests/ts/kill/name_to_number

raw
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 # make sure we do not use shell built-in command
22 if [ "$TS_USE_SYSTEM_COMMANDS" == "yes" ]; then
23 TS_CMD_KILL="$(which kill)"
24 fi
25
26 ts_check_test_command "$TS_CMD_KILL"
27 ts_check_test_command "$TS_HELPER_SIGRECEIVE"
28
29 # SIGRTMAX-0 and SIGRTMAX-1 are not usable under QEMU
30 ts_skip_qemu_user
31
32 . "$TS_SELF/kill_functions.sh"
33
34 all_ok=true
35
36 HELPER_SYMLINK="$(mktemp "${TS_OUTDIR}/naXXXXXXXXXXXXX")"
37 ln -sf "$TS_HELPER_SIGRECEIVE" "$HELPER_SYMLINK"
38
39 for SIG in $($TS_CMD_KILL -L); do
40 if [ "x${SIG//[0-9]/}" = "x" ]; then
41 EXPECTED=$SIG
42 continue
43 fi
44 if [ "$TS_ENABLE_ASAN" == "yes" ] && [ "x$SIG" = "xSEGV" ]; then
45 continue
46 fi
47 if [ "x$SIG" = "xSTOP" ] || [ "x$SIG" = "xKILL" ]; then
48 continue
49 fi
50 if [ "x$SIG" = "xRTMIN" ]; then
51 SIG="$SIG+0"
52 fi
53 if [ "x$SIG" = "xRTMAX" ]; then
54 SIG="$SIG-0"
55 fi
56
57 "$HELPER_SYMLINK" >> $TS_OUTPUT 2>> $TS_ERRLOG &
58 TEST_PID=$!
59 check_test_sigreceive $TEST_PID
60 [ $? -eq 1 ] || echo "${HELPER_SYMLINK##*/} helper did not start" >> "$TS_OUTPUT"
61
62 "$TS_CMD_KILL" -$SIG ${HELPER_SYMLINK##*/} >> $TS_OUTPUT 2>> $TS_ERRLOG
63 wait $TEST_PID
64 if [ $? -ne $EXPECTED ]; then
65 echo "$SIG returned $? while $EXPECTED was expected" >> "$TS_OUTPUT"
66 all_ok=false
67 fi
68 done
69
70 if $all_ok; then
71 echo 'all ok' >> "$TS_OUTPUT"
72 fi
73 rm -f "$HELPER_SYMLINK"
74
75 ts_finalize