[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] tests: fix non POSIX constructs causing failures with dash
From: |
Pádraig Brady |
Subject: |
[PATCH] tests: fix non POSIX constructs causing failures with dash |
Date: |
Tue, 19 May 2015 12:42:44 +0100 |
* tests/cp/no-ctx.sh: Scope of `var=val func` is inconsistent
across shells, so avoid that construct with functions.
* tests/df/no-mtab-status.sh: Likewise.
* tests/tail-2/inotify-race.sh: `read` needs an argument.
* tests/tail-2/inotify-race2.sh: Likewise.
---
tests/cp/no-ctx.sh | 3 ++-
tests/df/no-mtab-status.sh | 42 +++++++++++++++++++++++-------------------
tests/tail-2/inotify-race.sh | 2 +-
tests/tail-2/inotify-race2.sh | 2 +-
4 files changed, 27 insertions(+), 22 deletions(-)
diff --git a/tests/cp/no-ctx.sh b/tests/cp/no-ctx.sh
index 19d68b8..7e7b897 100755
--- a/tests/cp/no-ctx.sh
+++ b/tests/cp/no-ctx.sh
@@ -57,7 +57,8 @@ LD_PRELOAD=./k.so cp -a file_src file_dst || fail=1
# ENODATA should give an immediate error when required to preserve ctx
# This is debatable, and maybe we should not fail when no context available?
-LD_PRELOAD=./k.so returns_ 1 cp --preserve=context file_src file_dst || fail=1
+( LD_PRELOAD=./k.so; export LD_PRELOAD;
+ returns_ 1 cp --preserve=context file_src file_dst ) || fail=1
test -e preloaded || skip_ 'LD_PRELOAD interception failed'
diff --git a/tests/df/no-mtab-status.sh b/tests/df/no-mtab-status.sh
index 58a1852..05887cd 100755
--- a/tests/df/no-mtab-status.sh
+++ b/tests/df/no-mtab-status.sh
@@ -88,34 +88,38 @@ EOF
gcc_shared_ k.c k.so \
|| framework_failure_ 'failed to build shared library'
+cleanup_() { unset LD_PRELOAD; }
+
+LD_PRELOAD=./k.so; export LD_PRELOAD
+
# Test if LD_PRELOAD works:
-LD_PRELOAD=./k.so df
+df 2>/dev/null
test -f x || skip_ "internal test failure: maybe LD_PRELOAD doesn't work?"
# These tests are supposed to succeed:
-LD_PRELOAD=./k.so df '.' || fail=1
-LD_PRELOAD=./k.so df -i '.' || fail=1
-LD_PRELOAD=./k.so df -T '.' || fail=1
-LD_PRELOAD=./k.so df -Ti '.' || fail=1
-LD_PRELOAD=./k.so df --total '.' || fail=1
+df '.' || fail=1
+df -i '.' || fail=1
+df -T '.' || fail=1
+df -Ti '.' || fail=1
+df --total '.' || fail=1
# These tests are supposed to fail:
-LD_PRELOAD=./k.so returns_ 1 df || fail=1
-LD_PRELOAD=./k.so returns_ 1 df -i || fail=1
-LD_PRELOAD=./k.so returns_ 1 df -T || fail=1
-LD_PRELOAD=./k.so returns_ 1 df -Ti || fail=1
-LD_PRELOAD=./k.so returns_ 1 df --total || fail=1
+returns_ 1 df || fail=1
+returns_ 1 df -i || fail=1
+returns_ 1 df -T || fail=1
+returns_ 1 df -Ti || fail=1
+returns_ 1 df --total || fail=1
-LD_PRELOAD=./k.so returns_ 1 df -a || fail=1
-LD_PRELOAD=./k.so returns_ 1 df -a '.' || fail=1
+returns_ 1 df -a || fail=1
+returns_ 1 df -a '.' || fail=1
-LD_PRELOAD=./k.so returns_ 1 df -l || fail=1
-LD_PRELOAD=./k.so returns_ 1 df -l '.' || fail=1
+returns_ 1 df -l || fail=1
+returns_ 1 df -l '.' || fail=1
-LD_PRELOAD=./k.so returns_ 1 df -t hello || fail=1
-LD_PRELOAD=./k.so returns_ 1 df -t hello '.' || fail=1
+returns_ 1 df -t hello || fail=1
+returns_ 1 df -t hello '.' || fail=1
-LD_PRELOAD=./k.so returns_ 1 df -x hello || fail=1
-LD_PRELOAD=./k.so returns_ 1 df -x hello '.' || fail=1
+returns_ 1 df -x hello || fail=1
+returns_ 1 df -x hello '.' || fail=1
Exit $fail
diff --git a/tests/tail-2/inotify-race.sh b/tests/tail-2/inotify-race.sh
index 6e1a7fa..4ce0508 100755
--- a/tests/tail-2/inotify-race.sh
+++ b/tests/tail-2/inotify-race.sh
@@ -83,7 +83,7 @@ gdb -nx --batch-silent \
--eval-command='quit' \
tail < /dev/null > /dev/null 2>&1 & pid=$!
-tail --pid=$pid -f tail.out | (read; kill $pid)
+tail --pid=$pid -f tail.out | (read REPLY; kill $pid)
# gdb has a bug in Debian's gdb-6.8-3 at least that causes it to not
# cleanup and exit correctly when it receives a SIGTERM, but
diff --git a/tests/tail-2/inotify-race2.sh b/tests/tail-2/inotify-race2.sh
index 6d996eb..1e01d50 100755
--- a/tests/tail-2/inotify-race2.sh
+++ b/tests/tail-2/inotify-race2.sh
@@ -88,7 +88,7 @@ gdb -nx --batch-silent \
# anything between coreutils 7.5 and 8.23 inclusive as
# The old file descriptor (still held open by tail) was being fstat().
-tail --pid=$pid -f tail.out | (read; kill $pid)
+tail --pid=$pid -f tail.out | (read REPLY; kill $pid)
# gdb has a bug in Debian's gdb-6.8-3 at least that causes it to not
# cleanup and exit correctly when it receives a SIGTERM, but
--
2.4.0
- [PATCH] tests: fix non POSIX constructs causing failures with dash,
Pádraig Brady <=