diff options
author | Igor Pashev <pashev.igor@gmail.com> | 2015-07-04 17:17:09 +0300 |
---|---|---|
committer | Igor Pashev <pashev.igor@gmail.com> | 2015-07-04 17:17:09 +0300 |
commit | cc78bdc31749e9754120ae5a9d4849f4832b40a4 (patch) | |
tree | 4f9e3f2064e56651ed8d41ae9d8ce8b08fc5241b /tests/mv | |
parent | 8425beb209e6fedf50bcdd934ced14dfa0d7b596 (diff) | |
parent | 71cd8e3a743046573744123777061b64881bf372 (diff) | |
download | coreutils-cc78bdc31749e9754120ae5a9d4849f4832b40a4.tar.gz |
Merge tag 'upstream/8.24'
Upstream version 8.24
Conflicts:
INSTALL
Makefile.in
aclocal.m4
build-aux/config.guess
build-aux/config.rpath
build-aux/config.sub
build-aux/depcomp
build-aux/missing
build-aux/test-driver
build-aux/texinfo.tex
doc/coreutils.info
doc/stamp-vti
doc/version.texi
gnulib-tests/Makefile.in
po/Makefile.in.in
Diffstat (limited to 'tests/mv')
42 files changed, 129 insertions, 110 deletions
diff --git a/tests/mv/acl.sh b/tests/mv/acl.sh index f681f5d0..b09125c5 100755 --- a/tests/mv/acl.sh +++ b/tests/mv/acl.sh @@ -2,7 +2,7 @@ # move files/directories across file system boundaries # and make sure acls are preserved -# Copyright (C) 2005-2014 Free Software Foundation, Inc. +# Copyright (C) 2005-2015 Free Software Foundation, Inc. # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/tests/mv/atomic.sh b/tests/mv/atomic.sh index a026bd5b..6d8c5a92 100755 --- a/tests/mv/atomic.sh +++ b/tests/mv/atomic.sh @@ -1,7 +1,7 @@ #!/bin/sh # ensure that mv doesn't first unlink its destination in one particular case -# Copyright (C) 2006-2014 Free Software Foundation, Inc. +# Copyright (C) 2006-2015 Free Software Foundation, Inc. # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/tests/mv/atomic2.sh b/tests/mv/atomic2.sh index 92a8e436..6787dd34 100755 --- a/tests/mv/atomic2.sh +++ b/tests/mv/atomic2.sh @@ -1,7 +1,7 @@ #!/bin/sh # ensure that mv doesn't first unlink a multi-hard-linked destination -# Copyright (C) 2008-2014 Free Software Foundation, Inc. +# Copyright (C) 2008-2015 Free Software Foundation, Inc. # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/tests/mv/backup-dir.sh b/tests/mv/backup-dir.sh index 682173d4..f547a63e 100755 --- a/tests/mv/backup-dir.sh +++ b/tests/mv/backup-dir.sh @@ -1,7 +1,7 @@ #!/bin/sh # Ensure "mv --verbose --backup" works the same for dirs and non-dirs. -# Copyright (C) 2006-2014 Free Software Foundation, Inc. +# Copyright (C) 2006-2015 Free Software Foundation, Inc. # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/tests/mv/backup-is-src.sh b/tests/mv/backup-is-src.sh index 4208d91e..acfe5684 100755 --- a/tests/mv/backup-is-src.sh +++ b/tests/mv/backup-is-src.sh @@ -1,7 +1,7 @@ #!/bin/sh # Force mv to use the copying code. -# Copyright (C) 1998-2014 Free Software Foundation, Inc. +# Copyright (C) 1998-2015 Free Software Foundation, Inc. # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/tests/mv/childproof.sh b/tests/mv/childproof.sh index c212b83d..cc879ff1 100755 --- a/tests/mv/childproof.sh +++ b/tests/mv/childproof.sh @@ -3,7 +3,7 @@ # With fileutils-4.1 and earlier, this test would fail for cp and mv. # With coreutils-6.9 and earlier, this test would fail for ln. -# Copyright (C) 2001-2014 Free Software Foundation, Inc. +# Copyright (C) 2001-2015 Free Software Foundation, Inc. # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -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/diag.sh b/tests/mv/diag.sh index b38fb18c..62bc2da5 100755 --- a/tests/mv/diag.sh +++ b/tests/mv/diag.sh @@ -1,7 +1,7 @@ #!/bin/sh # make sure we get proper diagnostics: e.g., with --target-dir=d but no args -# Copyright (C) 2000-2014 Free Software Foundation, Inc. +# Copyright (C) 2000-2015 Free Software Foundation, Inc. # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/tests/mv/dir-file.sh b/tests/mv/dir-file.sh index bb32f356..7b798ed6 100755 --- a/tests/mv/dir-file.sh +++ b/tests/mv/dir-file.sh @@ -1,7 +1,7 @@ #!/bin/sh # mv must fail when src and dest are mismatched directory/non-directory. -# Copyright (C) 2000-2014 Free Software Foundation, Inc. +# Copyright (C) 2000-2015 Free Software Foundation, Inc. # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -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/dir2dir.sh b/tests/mv/dir2dir.sh index 7a8f7fd3..6f9c3ce7 100755 --- a/tests/mv/dir2dir.sh +++ b/tests/mv/dir2dir.sh @@ -2,7 +2,7 @@ # Ensure that mv prints the right diagnostic for a dir->dir move # where the destination directory is not empty. -# Copyright (C) 2006-2014 Free Software Foundation, Inc. +# Copyright (C) 2006-2015 Free Software Foundation, Inc. # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/tests/mv/dup-source.sh b/tests/mv/dup-source.sh index d3b56c5e..c160c0de 100755 --- a/tests/mv/dup-source.sh +++ b/tests/mv/dup-source.sh @@ -4,7 +4,7 @@ # made this fail: cp a a d/ # Ensure that mv fails with a similar command. -# Copyright (C) 2001-2014 Free Software Foundation, Inc. +# Copyright (C) 2001-2015 Free Software Foundation, Inc. # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/tests/mv/force.sh b/tests/mv/force.sh index 05adabc5..cd4e7948 100755 --- a/tests/mv/force.sh +++ b/tests/mv/force.sh @@ -1,7 +1,7 @@ #!/bin/sh # move a file onto itself -# Copyright (C) 1999-2014 Free Software Foundation, Inc. +# Copyright (C) 1999-2015 Free Software Foundation, Inc. # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -25,18 +25,19 @@ ff2=mvforce2 echo force-contents > $ff || framework_failure_ ln $ff $ff2 || framework_failure_ -# This mv command should exit nonzero. -mv $ff $ff > out 2>&1 && fail=1 +# mv should fail for the same name, or separate hardlinks as in +# both cases rename() will do nothing and return success. +# One could unlink(src) in the hardlink case, but that would +# introduce races with overlapping mv instances removing both hardlinks. -cat > exp <<EOF -mv: '$ff' and '$ff' are the same file -EOF +for dest in $ff $ff2; do + # This mv command should exit nonzero. + mv $ff $dest > out 2>&1 && fail=1 -compare exp out || fail=1 -test $(cat $ff) = force-contents || fail=1 + printf "mv: '$ff' and '$dest' are the same file\n" > exp + compare exp out || fail=1 -# This should succeed, even though the source and destination -# device and inodes are the same. -mv $ff $ff2 || fail=1 + test $(cat $ff) = force-contents || fail=1 +done Exit $fail diff --git a/tests/mv/hard-2.sh b/tests/mv/hard-2.sh index 0b2880a2..1276c9eb 100755 --- a/tests/mv/hard-2.sh +++ b/tests/mv/hard-2.sh @@ -2,7 +2,7 @@ # Ensure that moving hard-linked arguments onto existing destinations works. # Likewise when using cp --preserve=link. -# Copyright (C) 2003-2014 Free Software Foundation, Inc. +# Copyright (C) 2003-2015 Free Software Foundation, Inc. # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/tests/mv/hard-3.sh b/tests/mv/hard-3.sh index a3acd1a6..380aa4ca 100755 --- a/tests/mv/hard-3.sh +++ b/tests/mv/hard-3.sh @@ -2,7 +2,7 @@ # Ensure that using 'cp --preserve=link' to copy hard-linked arguments # onto existing destinations works, even when one of the link operations fails. -# Copyright (C) 2003-2014 Free Software Foundation, Inc. +# Copyright (C) 2003-2015 Free Software Foundation, Inc. # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/tests/mv/hard-4.sh b/tests/mv/hard-4.sh index d518e3bc..c751c33d 100755 --- a/tests/mv/hard-4.sh +++ b/tests/mv/hard-4.sh @@ -1,7 +1,7 @@ #!/bin/sh -# ensure that mv removes a in this case: touch a; ln a b; mv a b +# ensure that mv maintains a in this case: touch a; ln a b; mv a b -# Copyright (C) 2003-2014 Free Software Foundation, Inc. +# Copyright (C) 2003-2015 Free Software Foundation, Inc. # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -21,15 +21,18 @@ print_ver_ mv touch a || framework_failure_ ln a b || framework_failure_ +# Between coreutils-5.0 and coreutils-8.24, 'a' would be removed. +# Before coreutils-5.0.1 the issue would not have been diagnosed. +# We don't emulate the rename(a,b) with unlink(a) as that would +# introduce races with overlapping mv instances removing both links. +mv a b 2>err && fail=1 +printf "mv: 'a' and 'b' are the same file\n" > exp +compare exp err || fail=1 -mv a b || fail=1 - -# In coreutils-5.0 and earlier, a would not be removed. -test -r a && fail=1 +test -r a || fail=1 test -r b || fail=1 -# Make sure it works also with --backup. -ln b a +# Make sure it works with --backup. mv --backup=simple a b || fail=1 test -r a && fail=1 test -r b || fail=1 diff --git a/tests/mv/hard-link-1.sh b/tests/mv/hard-link-1.sh index fdf355a3..392ca2ef 100755 --- a/tests/mv/hard-link-1.sh +++ b/tests/mv/hard-link-1.sh @@ -2,7 +2,7 @@ # move a directory containing hard-linked files and # make sure the links are preserved -# Copyright (C) 1998-2014 Free Software Foundation, Inc. +# Copyright (C) 1998-2015 Free Software Foundation, Inc. # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/tests/mv/hard-verbose.sh b/tests/mv/hardlink-case.sh index 45491ab0..3e51c38a 100755 --- a/tests/mv/hard-verbose.sh +++ b/tests/mv/hardlink-case.sh @@ -1,7 +1,7 @@ #!/bin/sh -# ensure that mv's --verbose options works even in this unusual case +# Ensure multi-hardlinked files are not lost on case insensitive file systems -# Copyright (C) 2006-2014 Free Software Foundation, Inc. +# Copyright (C) 2014-2015 Free Software Foundation, Inc. # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -18,16 +18,20 @@ . "${srcdir=.}/tests/init.sh"; path_prepend_ ./src print_ver_ mv +require_root_ -touch x || framework_failure_ -ln x y || framework_failure_ +cwd=$(pwd) +cleanup_() { cd /; umount "$cwd/mnt"; } +truncate -s100M hfs.img || framework_failure_ +mkfs -t hfsplus hfs.img || skip_ 'failed to create hfs file system' +mkdir mnt || framework_failure_ +mount hfs.img mnt || skip_ 'failed to mount hfs file system' -mv --verbose x y > out || fail=1 -cat <<\EOF > exp || fail=1 -removed 'x' -EOF - -compare exp out || fail=1 +cd mnt +touch foo +ln foo whatever +returns_ 1 mv foo Foo || fail=1 +test -r foo || fail=1 Exit $fail diff --git a/tests/mv/i-1.pl b/tests/mv/i-1.pl index 84902ee2..714783c8 100755 --- a/tests/mv/i-1.pl +++ b/tests/mv/i-1.pl @@ -1,7 +1,7 @@ #!/usr/bin/perl # Make sure a 'n' reply to 'mv -i...' aborts the move operation. -# Copyright (C) 2001-2014 Free Software Foundation, Inc. +# Copyright (C) 2001-2015 Free Software Foundation, Inc. # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/tests/mv/i-2.sh b/tests/mv/i-2.sh index 4202b5c5..39cdafb2 100755 --- a/tests/mv/i-2.sh +++ b/tests/mv/i-2.sh @@ -2,7 +2,7 @@ # Test both cp and mv for their behavior with -if and -fi # The standards (POSIX and SuS) dictate annoyingly inconsistent behavior. -# Copyright (C) 2000-2014 Free Software Foundation, Inc. +# Copyright (C) 2000-2015 Free Software Foundation, Inc. # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/tests/mv/i-3.sh b/tests/mv/i-3.sh index 8c58d5d3..5dba1fe4 100755 --- a/tests/mv/i-3.sh +++ b/tests/mv/i-3.sh @@ -2,7 +2,7 @@ # Make sure that 'mv file unwritable-file' prompts the user # and that 'mv -f file unwritable-file' doesn't. -# Copyright (C) 2001-2014 Free Software Foundation, Inc. +# Copyright (C) 2001-2015 Free Software Foundation, Inc. # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -23,7 +23,7 @@ require_controlling_input_terminal_ skip_if_root_ trap '' TTIN # Ignore SIGTTIN -test "$(uname -s)" = FreeBSD && skip_ "known spurious failure on FreeBSD" +uname -s | grep 'BSD$' && skip_ 'known spurious failure on *BSD' touch f g h i || framework_failure_ chmod 0 g i || framework_failure_ @@ -39,6 +39,9 @@ tty=$(readlink -f /dev/stdin) test -r "$tty" 2>&1 \ || skip_ '/dev/stdin is not readable' +# Terminate any background processes +cleanup_() { kill $pid 2>/dev/null && wait $pid; } + mv f g < $tty > out 2>&1 & pid=$! # Test for the expected prompt; sleep upon non-match. @@ -54,7 +57,7 @@ check_overwrite_prompt() # Wait for up to 12.7 seconds for the expected prompt. retry_delay_ check_overwrite_prompt .1 7 || { fail=1; cat out; } -kill $pid +cleanup_ mv -f h i > out 2>&1 || fail=1 test -f i || fail=1 diff --git a/tests/mv/i-4.sh b/tests/mv/i-4.sh index b366bc46..ff3513a8 100755 --- a/tests/mv/i-4.sh +++ b/tests/mv/i-4.sh @@ -1,7 +1,7 @@ #!/bin/sh # make sure 'mv -i a b' does its job with a positive response -# Copyright (C) 2001-2014 Free Software Foundation, Inc. +# Copyright (C) 2001-2015 Free Software Foundation, Inc. # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -23,6 +23,7 @@ for i in a b; do echo $i > $i || framework_failure_ done echo y > y || framework_failure_ +echo n > n || framework_failure_ mv -i a b < y >/dev/null 2>&1 || fail=1 @@ -32,18 +33,15 @@ case "$(cat b)" in *) fail=1 ;; esac -# Ensure that mv -i a b works properly with 'n' and 'y' -# responses, even when a and b are hard links to the same file. -# This 'n' test would fail (no prompt) for coreutils-5.0.1 through 5.3.0. -echo n > n +# Ensure that mv -i a b works properly with 'n' and 'y' responses, +# when a and b are hard links to the same file. rm -f a b echo a > a ln a b -mv -i a b < n >/dev/null 2>&1 || fail=1 +mv -i a b < y 2>err && fail=1 test -r a || fail=1 test -r b || fail=1 -mv -i a b < y >/dev/null 2>&1 || fail=1 -test -r a && fail=1 -test -r b || fail=1 +printf "mv: 'a' and 'b' are the same file\n" > exp +compare exp err || fail=1 Exit $fail diff --git a/tests/mv/i-5.sh b/tests/mv/i-5.sh index c69f1784..85931122 100755 --- a/tests/mv/i-5.sh +++ b/tests/mv/i-5.sh @@ -1,7 +1,7 @@ #!/bin/sh # Make sure 'mv -i dir file' prompts before failing. -# Copyright (C) 2006-2014 Free Software Foundation, Inc. +# Copyright (C) 2006-2015 Free Software Foundation, Inc. # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/tests/mv/i-link-no.sh b/tests/mv/i-link-no.sh index 67a8ff9c..59bee0b1 100755 --- a/tests/mv/i-link-no.sh +++ b/tests/mv/i-link-no.sh @@ -1,7 +1,7 @@ #!/bin/sh # Show that mv doesn't preserve links to files the user has declined to move. -# Copyright (C) 2002-2014 Free Software Foundation, Inc. +# Copyright (C) 2002-2015 Free Software Foundation, Inc. # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/tests/mv/into-self-2.sh b/tests/mv/into-self-2.sh index 4109d9e6..645ed41a 100755 --- a/tests/mv/into-self-2.sh +++ b/tests/mv/into-self-2.sh @@ -3,7 +3,7 @@ # Consider the case where SRC and DEST are on different # partitions and DEST is a symlink to SRC. -# Copyright (C) 1998-2014 Free Software Foundation, Inc. +# Copyright (C) 1998-2015 Free Software Foundation, Inc. # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/tests/mv/into-self-3.sh b/tests/mv/into-self-3.sh index 52069b88..e7a1ee76 100755 --- a/tests/mv/into-self-3.sh +++ b/tests/mv/into-self-3.sh @@ -1,7 +1,7 @@ #!/bin/sh # move a directory into itself, with a twist -# Copyright (C) 1998-2014 Free Software Foundation, Inc. +# Copyright (C) 1998-2015 Free Software Foundation, Inc. # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/tests/mv/into-self-4.sh b/tests/mv/into-self-4.sh index ac78f90b..2ae0468f 100755 --- a/tests/mv/into-self-4.sh +++ b/tests/mv/into-self-4.sh @@ -2,7 +2,7 @@ # confirm that 'mv symlink symlink' doesn't remove symlink # Based on an example from David Luyer. -# Copyright (C) 2001-2014 Free Software Foundation, Inc. +# Copyright (C) 2001-2015 Free Software Foundation, Inc. # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -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/into-self.sh b/tests/mv/into-self.sh index 76aefa26..0a08154b 100755 --- a/tests/mv/into-self.sh +++ b/tests/mv/into-self.sh @@ -1,7 +1,7 @@ #! /bin/sh # Demonstrate how mv fails when it tries to move a directory into itself. -# Copyright (C) 1998-2014 Free Software Foundation, Inc. +# Copyright (C) 1998-2015 Free Software Foundation, Inc. # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/tests/mv/leak-fd.sh b/tests/mv/leak-fd.sh index 6b81f5cb..b36da8d3 100755 --- a/tests/mv/leak-fd.sh +++ b/tests/mv/leak-fd.sh @@ -2,7 +2,7 @@ # Exercise mv's file-descriptor-leak bug, reported against coreutils-5.2.1 # and fixed (properly) on 2004-10-21. -# Copyright (C) 2004-2014 Free Software Foundation, Inc. +# Copyright (C) 2004-2015 Free Software Foundation, Inc. # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/tests/mv/mv-n.sh b/tests/mv/mv-n.sh index 30ba35bb..8c3fedb8 100755 --- a/tests/mv/mv-n.sh +++ b/tests/mv/mv-n.sh @@ -1,7 +1,7 @@ #!/bin/sh # Test whether mv -n works as documented (not overwrite target). -# Copyright (C) 2006-2014 Free Software Foundation, Inc. +# Copyright (C) 2006-2015 Free Software Foundation, Inc. # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -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/mv-special-1.sh b/tests/mv/mv-special-1.sh index 34449150..0c649f03 100755 --- a/tests/mv/mv-special-1.sh +++ b/tests/mv/mv-special-1.sh @@ -1,7 +1,7 @@ #! /bin/sh # Test "mv" with special files. -# Copyright (C) 1998-2014 Free Software Foundation, Inc. +# Copyright (C) 1998-2015 Free Software Foundation, Inc. # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/tests/mv/no-target-dir.sh b/tests/mv/no-target-dir.sh index ac65ff7f..d7bca59b 100755 --- a/tests/mv/no-target-dir.sh +++ b/tests/mv/no-target-dir.sh @@ -2,7 +2,7 @@ # ensure that --no-target-directory (-T) works when the destination is # an empty directory. -# Copyright (C) 2006-2014 Free Software Foundation, Inc. +# Copyright (C) 2006-2015 Free Software Foundation, Inc. # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -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-fail.sh b/tests/mv/part-fail.sh index 71ee30c0..164a6393 100755 --- a/tests/mv/part-fail.sh +++ b/tests/mv/part-fail.sh @@ -4,7 +4,7 @@ # This is a bit fragile since it relies on the string used # for EPERM: 'permission denied'. -# Copyright (C) 2002-2014 Free Software Foundation, Inc. +# Copyright (C) 2002-2015 Free Software Foundation, Inc. # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/tests/mv/part-hardlink.sh b/tests/mv/part-hardlink.sh index 8eacaabc..c4a5830f 100755 --- a/tests/mv/part-hardlink.sh +++ b/tests/mv/part-hardlink.sh @@ -4,7 +4,7 @@ # For additional constraints, see the comment in copy.c. # Before coreutils-5.2.1, this test would fail. -# Copyright (C) 2004-2014 Free Software Foundation, Inc. +# Copyright (C) 2004-2015 Free Software Foundation, Inc. # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/tests/mv/part-rename.sh b/tests/mv/part-rename.sh index ba68f6e6..b84f6886 100755 --- a/tests/mv/part-rename.sh +++ b/tests/mv/part-rename.sh @@ -1,7 +1,7 @@ #!/bin/sh # Test various cases for moving directories across file systems -# Copyright (C) 2000-2014 Free Software Foundation, Inc. +# Copyright (C) 2000-2015 Free Software Foundation, Inc. # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -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/part-symlink.sh b/tests/mv/part-symlink.sh index 9604d873..16856259 100755 --- a/tests/mv/part-symlink.sh +++ b/tests/mv/part-symlink.sh @@ -2,7 +2,7 @@ # make sure cp and mv can handle many combinations of local and # other-partition regular/symlink'd files. -# Copyright (C) 2000-2014 Free Software Foundation, Inc. +# Copyright (C) 2000-2015 Free Software Foundation, Inc. # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/tests/mv/partition-perm.sh b/tests/mv/partition-perm.sh index 713988f7..18c1a77f 100755 --- a/tests/mv/partition-perm.sh +++ b/tests/mv/partition-perm.sh @@ -1,7 +1,7 @@ #!/bin/sh # Make sure permissions are preserved when moving from one partition to another. -# Copyright (C) 1999-2014 Free Software Foundation, Inc. +# Copyright (C) 1999-2015 Free Software Foundation, Inc. # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/tests/mv/perm-1.sh b/tests/mv/perm-1.sh index 2826c61f..3632d8d4 100755 --- a/tests/mv/perm-1.sh +++ b/tests/mv/perm-1.sh @@ -2,7 +2,7 @@ # ensure that mv gives one diagnostic, not two, when failing # due to lack of permissions -# Copyright (C) 2002-2014 Free Software Foundation, Inc. +# Copyright (C) 2002-2015 Free Software Foundation, Inc. # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/tests/mv/sticky-to-xpart.sh b/tests/mv/sticky-to-xpart.sh index e0c99e94..602562cc 100755 --- a/tests/mv/sticky-to-xpart.sh +++ b/tests/mv/sticky-to-xpart.sh @@ -4,7 +4,7 @@ # mv: cannot remove 'x': Operation not permitted # Affects coreutils-6.0-6.9. -# Copyright (C) 2007-2014 Free Software Foundation, Inc. +# Copyright (C) 2007-2015 Free Software Foundation, Inc. # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -42,7 +42,8 @@ chmod go+x . || framework_failure_ # Ensure that $NON_ROOT_USERNAME can access the required version of mv. version=$( - chroot --user=$NON_ROOT_USERNAME / env PATH="$PATH" mv --version | + chroot --skip-chdir --user=$NON_ROOT_USERNAME / env PATH="$PATH" \ + mv --version | sed -n '1s/.* //p' ) case $version in @@ -50,7 +51,7 @@ case $version in *) skip_ "cannot access just-built mv as user $NON_ROOT_USERNAME";; esac -chroot --user=$NON_ROOT_USERNAME / env PATH="$PATH" \ +chroot --skip-chdir --user=$NON_ROOT_USERNAME / env PATH="$PATH" \ mv t/root-owned "$other_partition_tmpdir" 2> out-t && fail=1 # On some systems, we get 'Not owner'. Convert it. diff --git a/tests/mv/symlink-onto-hardlink-to-self.sh b/tests/mv/symlink-onto-hardlink-to-self.sh index f3e8ff98..295844c0 100755 --- a/tests/mv/symlink-onto-hardlink-to-self.sh +++ b/tests/mv/symlink-onto-hardlink-to-self.sh @@ -1,10 +1,10 @@ #!/bin/sh -# Demonstrate that when moving a symlink onto a hardlink-to-that-symlink, the -# source symlink is removed. Depending on your kernel (e.g., Linux, Solaris, +# Demonstrate that when moving a symlink onto a hardlink-to-that-symlink, +# an error is presented. Depending on your kernel (e.g., Linux, Solaris, # but not NetBSD), prior to coreutils-8.16, the mv would successfully perform # a no-op. I.e., surprisingly, mv s1 s2 would succeed, yet fail to remove s1. -# Copyright (C) 2012-2014 Free Software Foundation, Inc. +# Copyright (C) 2012-2015 Free Software Foundation, Inc. # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -26,27 +26,34 @@ print_ver_ mv touch f || framework_failure_ ln -s f s2 || framework_failure_ -for opt in '' --backup; do +# Attempt to create a hard link to that symlink. +# On some systems, it's not possible: they create a hard link to the referent. +ln s2 s1 || framework_failure_ - # Attempt to create a hard link to that symlink. - # On some systems, it's not possible: they create a hard link to the referent. - ln s2 s1 || framework_failure_ +# If s1 is not a symlink, skip this test. +test -h s1 \ + || skip_ your kernel or file system cannot create a hard link to a symlink - # If s1 is not a symlink, skip this test. - test -h s1 \ - || skip_ your kernel or file system cannot create a hard link to a symlink +for opt in '' --backup; do - mv $opt s1 s2 > out 2>&1 || fail=1 - compare /dev/null out || fail=1 + if test "$opt" = --backup; then + mv $opt s1 s2 > out 2>&1 || fail=1 + compare /dev/null out || fail=1 - # Ensure that s1 is gone. - test -e s1 && fail=1 + # Ensure that s1 is gone. + test -e s1 && fail=1 - if test "$opt" = --backup; then # With --backup, ensure that the backup file was created. ref=$(readlink s2~) || fail=1 test "$ref" = f || fail=1 else + echo "mv: 's1' and 's2' are the same file" > exp + mv $opt s1 s2 2>err && fail=1 + compare exp err || fail=1 + + # Ensure that s1 is still present. + test -e s1 || fail=1 + # Without --backup, ensure there is no backup file. test -e s2~ && fail=1 fi diff --git a/tests/mv/symlink-onto-hardlink.sh b/tests/mv/symlink-onto-hardlink.sh index 5b4dead0..9bd370b1 100755 --- a/tests/mv/symlink-onto-hardlink.sh +++ b/tests/mv/symlink-onto-hardlink.sh @@ -1,7 +1,7 @@ #!/bin/sh # Ensure that mv works with a few symlink-onto-hard-link cases. -# Copyright (C) 2012-2014 Free Software Foundation, Inc. +# Copyright (C) 2012-2015 Free Software Foundation, Inc. # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/tests/mv/to-symlink.sh b/tests/mv/to-symlink.sh index 70ca6179..8b8091a9 100755 --- a/tests/mv/to-symlink.sh +++ b/tests/mv/to-symlink.sh @@ -2,7 +2,7 @@ # Make sure that the copying code used in an inter-partition # move unlinks a destination symlink before opening it. -# Copyright (C) 1999-2014 Free Software Foundation, Inc. +# Copyright (C) 1999-2015 Free Software Foundation, Inc. # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/tests/mv/trailing-slash.sh b/tests/mv/trailing-slash.sh index e3225025..47335d3c 100755 --- a/tests/mv/trailing-slash.sh +++ b/tests/mv/trailing-slash.sh @@ -4,7 +4,7 @@ # Also, ensure that "mv dir non-exist-dir/" works. # Also, ensure that "cp dir non-exist-dir/" works. -# Copyright (C) 2004-2014 Free Software Foundation, Inc. +# Copyright (C) 2004-2015 Free Software Foundation, Inc. # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -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 diff --git a/tests/mv/update.sh b/tests/mv/update.sh index 4c0553a5..2ada7dd1 100755 --- a/tests/mv/update.sh +++ b/tests/mv/update.sh @@ -1,7 +1,7 @@ #!/bin/sh # make sure --update works as advertised -# Copyright (C) 2001-2014 Free Software Foundation, Inc. +# Copyright (C) 2001-2015 Free Software Foundation, Inc. # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by |