]>
Commit | Line | Data |
---|---|---|
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 | ||
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 | all_ok=true | |
25 | HELPER_SYMLINK="$TS_OUTDIR/$(mktemp -u XXXXXXXXXXXXXXX)" | |
26 | ln -s "$TS_HELPER_SIGRECEIVE" "$HELPER_SYMLINK" | |
27 | ||
28 | for SIG in $($TS_CMD_KILL -L); do | |
29 | if [ "x${SIG//[0-9]/}" = "x" ]; then | |
30 | EXPECTED=$SIG | |
31 | continue | |
32 | fi | |
33 | if [ "x$SIG" = "xSTOP" ] || [ "x$SIG" = "xKILL" ]; then | |
34 | continue | |
35 | fi | |
36 | if [ "x$SIG" = "xRTMIN" ]; then | |
37 | SIG="$SIG+0" | |
38 | fi | |
39 | if [ "x$SIG" = "xRTMAX" ]; then | |
40 | SIG="$SIG-0" | |
41 | fi | |
42 | "$HELPER_SYMLINK" >> "$TS_OUTPUT" 2>&1 & | |
43 | TEST_PID=$! | |
44 | # test_sigreceive needs time to start up | |
45 | up=0 | |
46 | for i in 0.01 0.1 1 1 1 1; do | |
47 | awk 'BEGIN { retval=1 } | |
48 | $1 ~ /^SigCgt/ { | |
49 | lbyte = strtonum("0x" substr($2, 16, 16)) | |
50 | if (and(lbyte, 1)) { | |
51 | retval=0 | |
52 | } | |
53 | } END { | |
54 | exit retval | |
55 | }' /proc/$TEST_PID/status && | |
56 | up=1 && | |
57 | break | |
58 | sleep $i | |
59 | done | |
60 | test $up = 0 && echo "$SIG sigreceive ${HELPER_SYMLINK##*/} helper did not start" >> "$TS_OUTPUT" | |
61 | "$TS_CMD_KILL" -$SIG ${HELPER_SYMLINK##*/} >> "$TS_OUTPUT" 2>&1 | |
62 | wait $TEST_PID | |
63 | if [ $? -ne $EXPECTED ]; then | |
64 | echo "$SIG returned $? while $EXPECTED was expected" >> "$TS_OUTPUT" | |
65 | all_ok=false | |
66 | fi | |
67 | done | |
68 | ||
69 | if $all_ok; then | |
70 | echo 'all ok' >> $TS_OUTPUT | |
71 | fi | |
72 | rm -f "$HELPER_SYMLINK" | |
73 | ||
74 | ts_finalize |