diff options
author | Ruediger Meier | 2014-05-06 19:16:53 +0200 |
---|---|---|
committer | Ruediger Meier | 2014-05-06 19:29:13 +0200 |
commit | 48f9e0b258a3f20a82f2b976885b5ee22b8e7460 (patch) | |
tree | 89960a9b5423a53fafa0e0f61d434638c0472448 /tests/ts/kill | |
parent | tests: kill_functions.sh needs gawk (skip if sourced) (diff) | |
download | kernel-qcow2-util-linux-48f9e0b258a3f20a82f2b976885b5ee22b8e7460.tar.gz kernel-qcow2-util-linux-48f9e0b258a3f20a82f2b976885b5ee22b8e7460.tar.xz kernel-qcow2-util-linux-48f9e0b258a3f20a82f2b976885b5ee22b8e7460.zip |
tests: fix kill problems
There were several failures (missing tmp files, missing pids) on travis
build farm which I couldn't track down completely. Here we fix some
possible issues:
- mktemp -u is unsafe, maybe even in practice if there is a bad random
generator
- make sure that mktemp does not give us pure integer filnames which
would not work for "kill by-name"
- avoid using trap, could be that it removed tmp files on wrong signals
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
Diffstat (limited to 'tests/ts/kill')
-rwxr-xr-x | tests/ts/kill/all_processes | 7 | ||||
-rwxr-xr-x | tests/ts/kill/name_to_number | 7 | ||||
-rwxr-xr-x | tests/ts/kill/options | 6 | ||||
-rwxr-xr-x | tests/ts/kill/print_pid | 6 |
4 files changed, 14 insertions, 12 deletions
diff --git a/tests/ts/kill/all_processes b/tests/ts/kill/all_processes index af863d56a..93f78ad60 100755 --- a/tests/ts/kill/all_processes +++ b/tests/ts/kill/all_processes @@ -25,9 +25,8 @@ ts_check_test_command "$TS_HELPER_SIGRECEIVE" . "$TS_SELF/kill_functions.sh" -HELPER_SYMLINK="$TS_CWD/$(mktemp -u XXXXXXXXXXXXXXX)" -ln -s "$TS_HELPER_SIGRECEIVE" "$HELPER_SYMLINK" -trap "rm -f $HELPER_SYMLINK" 0 +HELPER_SYMLINK="$(mktemp "${TS_OUTDIR}/alXXXXXXXXXXXXX")" +ln -sf "$TS_HELPER_SIGRECEIVE" "$HELPER_SYMLINK" "$HELPER_SYMLINK" -s "$TS_TESTUSER" >> "$TS_OUTPUT" 2>&1 & TEST_PID=$! @@ -53,4 +52,6 @@ fi sed -i "s/${HELPER_SYMLINK##*/}/${TS_HELPER_SIGRECEIVE##*/}/" "$TS_OUTPUT" +rm -f "$HELPER_SYMLINK" + ts_finalize diff --git a/tests/ts/kill/name_to_number b/tests/ts/kill/name_to_number index a57ed852e..9a370bbcc 100755 --- a/tests/ts/kill/name_to_number +++ b/tests/ts/kill/name_to_number @@ -24,8 +24,9 @@ ts_check_test_command "$TS_HELPER_SIGRECEIVE" . "$TS_SELF/kill_functions.sh" all_ok=true -HELPER_SYMLINK="$TS_OUTDIR/$(mktemp -u XXXXXXXXXXXXXXX)" -ln -s "$TS_HELPER_SIGRECEIVE" "$HELPER_SYMLINK" + +HELPER_SYMLINK="$(mktemp "${TS_OUTDIR}/naXXXXXXXXXXXXX")" +ln -sf "$TS_HELPER_SIGRECEIVE" "$HELPER_SYMLINK" for SIG in $($TS_CMD_KILL -L); do if [ "x${SIG//[0-9]/}" = "x" ]; then @@ -56,7 +57,7 @@ for SIG in $($TS_CMD_KILL -L); do done if $all_ok; then - echo 'all ok' >> $TS_OUTPUT + echo 'all ok' >> "$TS_OUTPUT" fi rm -f "$HELPER_SYMLINK" diff --git a/tests/ts/kill/options b/tests/ts/kill/options index 413037c21..6cdaa24d4 100755 --- a/tests/ts/kill/options +++ b/tests/ts/kill/options @@ -25,9 +25,8 @@ ts_check_test_command "$TS_HELPER_SIGRECEIVE" all_ok=true -HELPER_SYMLINK="$TS_OUTDIR/$(mktemp -u XXXXXXXXXXXXXXX)" -ln -s "$TS_HELPER_SIGRECEIVE" "$HELPER_SYMLINK" -trap "rm -f $HELPER_SYMLINK" 0 +HELPER_SYMLINK="$(mktemp "${TS_OUTDIR}/opXXXXXXXXXXXXX")" +ln -sf "$TS_HELPER_SIGRECEIVE" "$HELPER_SYMLINK" try_option() { @@ -61,5 +60,6 @@ try_option -SIGHUP if $all_ok; then echo 'all ok' >> "$TS_OUTPUT" fi +rm -f "$HELPER_SYMLINK" ts_finalize diff --git a/tests/ts/kill/print_pid b/tests/ts/kill/print_pid index 4da8b4509..1b3052bb8 100755 --- a/tests/ts/kill/print_pid +++ b/tests/ts/kill/print_pid @@ -25,9 +25,8 @@ ts_check_test_command "$TS_HELPER_SIGRECEIVE" all_ok=true -HELPER_SYMLINK="$TS_OUTDIR/$(mktemp -u XXXXXXXXXXXXXXX)" -ln -s "$TS_HELPER_SIGRECEIVE" "$HELPER_SYMLINK" -trap "rm -f $HELPER_SYMLINK" 0 +HELPER_SYMLINK="$(mktemp "${TS_OUTDIR}/prXXXXXXXXXXXXX")" +ln -sf "$TS_HELPER_SIGRECEIVE" "$HELPER_SYMLINK" "$HELPER_SYMLINK" >> "$TS_OUTPUT" 2>&1 & TEST_PID=$! @@ -54,5 +53,6 @@ fi if $all_ok; then echo 'all ok' >> "$TS_OUTPUT" fi +rm -f "$HELPER_SYMLINK" ts_finalize |