summaryrefslogtreecommitdiffstats
path: root/tests/ts/kill
diff options
context:
space:
mode:
authorSami Kerola2014-05-11 21:26:38 +0200
committerKarel Zak2014-05-12 13:02:52 +0200
commit1e29f37dde7f15183837a1542958946f9716a1fc (patch)
tree0e34b71d861b16512d92530c65bcb087d1127d37 /tests/ts/kill
parentMerge branch 'tests-features' of https://github.com/rudimeier/util-linux (diff)
downloadkernel-qcow2-util-linux-1e29f37dde7f15183837a1542958946f9716a1fc.tar.gz
kernel-qcow2-util-linux-1e29f37dde7f15183837a1542958946f9716a1fc.tar.xz
kernel-qcow2-util-linux-1e29f37dde7f15183837a1542958946f9716a1fc.zip
tests: check /proc availability, and go-around if it is incomplete
Unavailability of /proc is fatal for kill, and continuing with the test in that case does not make sense as it will only mean false positive errors. Where /proc/<pid>/status file(s) does not exist the check will perform opportunistic sleep with assumption the test_sigreceive will be ready to be killed if it has some time to init. [kzak@redhat.com: - remove dependence on gawk, just use shell - fix typo in "test /proc"] CC: Ruediger Meier <sweet_f_a@gmx.de> Reference: https://travis-ci.org/rudimeier/util-linux/jobs/24561058 Signed-off-by: Sami Kerola <kerolasa@iki.fi> Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'tests/ts/kill')
-rw-r--r--tests/ts/kill/kill_functions.sh30
1 files changed, 17 insertions, 13 deletions
diff --git a/tests/ts/kill/kill_functions.sh b/tests/ts/kill/kill_functions.sh
index 73fff053d..cc0a44065 100644
--- a/tests/ts/kill/kill_functions.sh
+++ b/tests/ts/kill/kill_functions.sh
@@ -1,6 +1,5 @@
-
-# unfortunately we are using gawk features
-type gawk >/dev/null 2>&1 || ts_skip "cannot find gawk"
+# kill tests, or command, will not when /proc is missing.
+test -d /proc || ts_skip "/proc not available"
# The test_sigreceive is ready when signal process mask contains SIGHUP
function check_test_sigreceive {
@@ -8,17 +7,22 @@ function check_test_sigreceive {
local pid=$1
for i in 0.01 0.1 1 1 1 1; do
- gawk 'BEGIN { retval=1 }
- /^SigCgt/ {
- lbyte = strtonum("0x" substr($2, 16, 16))
- if (and(lbyte, 1)) {
- retval=0
- }
- } END {
- exit retval
- }' /proc/$pid/status &&
- rc=1 &&
+ if [ ! -f /proc/$pid/status ]; then
+ # The /proc exists, but not status file. Because the
+ # process already started it is unlikely the file would
+ # appear after any amount of waiting. Try to sleep for
+ # moment and hopefully test_sigreceive is ready to be
+ # killed.
+ echo "kill_functions.sh: /proc/$pid/status: No such file or directory"
+ sleep 2
+ rc=1
+ break
+ fi
+ sigmask=$((16#$( awk '/SigCgt/ { print $2}' /proc/$pid/status) ))
+ if [ $(( $sigmask & 1 )) == 1 ]; then
+ rc=1
break
+ fi
sleep $i
done
return $rc