| 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="queue" |
| 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 |
. "$TS_SELF/kill_functions.sh" |
| 30 |
|
| 31 |
all_ok=true |
| 32 |
|
| 33 |
HELPER_SYMLINK="$(mktemp "${TS_OUTDIR}/quXXXXXXXXXXXXX")" |
| 34 |
ln -sf "$TS_HELPER_SIGRECEIVE" "$HELPER_SYMLINK" |
| 35 |
|
| 36 |
"$HELPER_SYMLINK" >> $TS_OUTPUT 2>> $TS_ERRLOG & |
| 37 |
TEST_PID=$! |
| 38 |
check_test_sigreceive $TEST_PID |
| 39 |
[ $? -eq 1 ] || echo "${HELPER_SYMLINK##*/} helper did not start" >> "$TS_OUTPUT" |
| 40 |
|
| 41 |
"$TS_CMD_KILL" -1 --queue 42 $TEST_PID >> $TS_OUTPUT 2>> $TS_ERRLOG |
| 42 |
if [ $? -ne 0 ]; then |
| 43 |
echo "kill --queue 42 failed" >> "$TS_OUTPUT" |
| 44 |
all_ok=false |
| 45 |
fi |
| 46 |
wait $TEST_PID |
| 47 |
if [ $? -ne 42 ]; then |
| 48 |
echo "wait $TEST_PID returned $? instead of 42" >> "$TS_OUTPUT" |
| 49 |
all_ok=false |
| 50 |
fi |
| 51 |
|
| 52 |
if $all_ok; then |
| 53 |
echo 'all ok' >> "$TS_OUTPUT" |
| 54 |
fi |
| 55 |
|
| 56 |
rm -f "$HELPER_SYMLINK" |
| 57 |
|
| 58 |
ts_finalize |