summaryrefslogtreecommitdiff
path: root/tests/mv
diff options
context:
space:
mode:
Diffstat (limited to 'tests/mv')
-rwxr-xr-xtests/mv/childproof.sh8
-rwxr-xr-xtests/mv/dir-file.sh4
-rwxr-xr-xtests/mv/hardlink-case.sh2
-rwxr-xr-xtests/mv/into-self-4.sh2
-rwxr-xr-xtests/mv/mv-n.sh2
-rwxr-xr-xtests/mv/no-target-dir.sh8
-rwxr-xr-xtests/mv/part-rename.sh6
-rwxr-xr-xtests/mv/trailing-slash.sh4
8 files changed, 19 insertions, 17 deletions
diff --git a/tests/mv/childproof.sh b/tests/mv/childproof.sh
index bb7e661c3..cc879ff19 100755
--- a/tests/mv/childproof.sh
+++ b/tests/mv/childproof.sh
@@ -28,7 +28,7 @@ echo a > a/f || framework_failure_
echo b > b/f || framework_failure_
-cp a/f b/f c 2> /dev/null && fail=1
+returns_ 1 cp a/f b/f c 2> /dev/null || fail=1
test -f a/f || fail=1
test -f b/f || fail=1
test -f c/f || fail=1
@@ -43,7 +43,7 @@ test -f c/f || fail=1
test -f c/f.~1~ || fail=1
rm -f c/f*
-mv a/f b/f c 2> /dev/null && fail=1
+returns_ 1 mv a/f b/f c 2> /dev/null || fail=1
test -f a/f && fail=1
test -f b/f || fail=1
test -f c/f || fail=1
@@ -62,7 +62,7 @@ test -f c/f || fail=1
test -f c/g || fail=1
touch a/f b/f b/g
-mv a/f b/f b/g c 2> /dev/null && fail=1
+returns_ 1 mv a/f b/f b/g c 2> /dev/null || fail=1
test -f a/f && fail=1 # a/f should have been moved
test -f b/f || fail=1 # b/f should remain
test -f b/g && fail=1 # b/g should have been moved
@@ -74,7 +74,7 @@ test -f c/g || fail=1
rm -f a/f b/f c/f
echo a > a/f || fail=1
echo b > b/f || fail=1
-ln -f a/f b/f c 2> /dev/null && fail=1
+returns_ 1 ln -f a/f b/f c 2> /dev/null || fail=1
# a/f and c/f must be linked
test $(stat --format %i a/f) = $(stat --format %i c/f) || fail=1
# b/f and c/f must not be linked
diff --git a/tests/mv/dir-file.sh b/tests/mv/dir-file.sh
index 36b1a7dcf..7b798ed6f 100755
--- a/tests/mv/dir-file.sh
+++ b/tests/mv/dir-file.sh
@@ -24,7 +24,7 @@ mkdir -p dir/file || framework_failure_
# These should both fail, but until fileutils-4.0q only the second one did.
-mv dir file > /dev/null 2>&1 && fail=1
-mv file dir > /dev/null 2>&1 && fail=1
+returns_ 1 mv dir file > /dev/null 2>&1 || fail=1
+returns_ 1 mv file dir > /dev/null 2>&1 || fail=1
Exit $fail
diff --git a/tests/mv/hardlink-case.sh b/tests/mv/hardlink-case.sh
index 4a0b2a54f..3e51c38a5 100755
--- a/tests/mv/hardlink-case.sh
+++ b/tests/mv/hardlink-case.sh
@@ -31,7 +31,7 @@ mount hfs.img mnt || skip_ 'failed to mount hfs file system'
cd mnt
touch foo
ln foo whatever
-mv foo Foo && fail=1
+returns_ 1 mv foo Foo || fail=1
test -r foo || fail=1
Exit $fail
diff --git a/tests/mv/into-self-4.sh b/tests/mv/into-self-4.sh
index fe0322ea5..2ae0468fd 100755
--- a/tests/mv/into-self-4.sh
+++ b/tests/mv/into-self-4.sh
@@ -25,7 +25,7 @@ ln -s file s || framework_failure_
# This must fail.
-mv s s 2> /dev/null && fail=1
+returns_ 1 mv s s 2> /dev/null || fail=1
# But the symlink, s, must not be removed.
# Before 4.0.36, 's' would have been removed.
diff --git a/tests/mv/mv-n.sh b/tests/mv/mv-n.sh
index 97133339c..8c3fedb81 100755
--- a/tests/mv/mv-n.sh
+++ b/tests/mv/mv-n.sh
@@ -52,6 +52,6 @@ compare out5 out_empty || fail=1
# options --backup and --no-clobber are mutually exclusive
touch a || framework_failure_
-mv -bn a b 2>/dev/null && fail=1
+returns_ 1 mv -bn a b 2>/dev/null || fail=1
Exit $fail
diff --git a/tests/mv/no-target-dir.sh b/tests/mv/no-target-dir.sh
index 9f8ece0a1..d7bca59b1 100755
--- a/tests/mv/no-target-dir.sh
+++ b/tests/mv/no-target-dir.sh
@@ -20,6 +20,8 @@
. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ mv
+LS_FAILURE=2
+
mkdir -p d/sub empty src d2/sub e2 || framework_failure_
touch f || framework_failure_
@@ -35,15 +37,15 @@ mv a b ||
mv -fT d empty || fail=1
# Ensure that the source, d, is gone.
-ls -d d > /dev/null 2>&1 && fail=1
+returns_ $LS_FAILURE ls -d d > /dev/null 2>&1 || fail=1
# Ensure that the dest dir now has a subdirectory.
test -d empty/sub || fail=1
# rename must fail, since the dest is non-empty.
-mv -fT src d2 2> /dev/null && fail=1
+returns_ 1 mv -fT src d2 2> /dev/null || fail=1
# rename must fail, since the src is not a directory.
-mv -fT f e2 2> /dev/null && fail=1
+returns_ 1 mv -fT f e2 2> /dev/null || fail=1
Exit $fail
diff --git a/tests/mv/part-rename.sh b/tests/mv/part-rename.sh
index da88260a8..b84f68864 100755
--- a/tests/mv/part-rename.sh
+++ b/tests/mv/part-rename.sh
@@ -31,13 +31,13 @@ mv foo/ "$other_partition_tmpdir/bar" || fail=1
# Moving a non directory from source shouldn't replace empty dir in dest
touch bar || framework_failure_
-mv bar "$other_partition_tmpdir/" && fail=1
+returns_ 1 mv bar "$other_partition_tmpdir/" || fail=1
# Moving a directory from source shouldn't replace non directory in dest
mkdir bar2
touch "$other_partition_tmpdir/bar2"
-mv bar2 "$other_partition_tmpdir/" && fail=1
+returns_ 1 mv bar2 "$other_partition_tmpdir/" || fail=1
# As per POSIX moving directory from source should replace empty dir in dest
@@ -51,7 +51,7 @@ test -e "$other_partition_tmpdir/bar3/file" || fail=1
# As per POSIX moving directory from source shouldn't update dir in dest
mkdir bar3
touch bar3/file2
-mv bar3 "$other_partition_tmpdir/" && fail=1
+returns_ 1 mv bar3 "$other_partition_tmpdir/" || fail=1
test -e "$other_partition_tmpdir/bar3/file2" && fail=1
Exit $fail
diff --git a/tests/mv/trailing-slash.sh b/tests/mv/trailing-slash.sh
index da2d95d1a..47335d3ca 100755
--- a/tests/mv/trailing-slash.sh
+++ b/tests/mv/trailing-slash.sh
@@ -48,14 +48,14 @@ done
# underlying rename syscall handles the trailing slash.
# It does fail, as desired, on recent Linux and Solaris systems.
#touch a a2
-#mv a a2/ && fail=1
+#returns_ 1 mv a a2/ || fail=1
# Test for a cp-specific diagnostic introduced after coreutils-8.7:
printf '%s\n' \
"cp: cannot create regular file 'no-such/': Not a directory" \
> expected-err
touch b
-cp b no-such/ 2> err && fail=1
+cp b no-such/ 2> err
# Map "No such file..." diagnostic to the expected "Not a directory"
sed 's/No such file or directory/Not a directory/' err > k && mv k err