diff options
Diffstat (limited to 'tests/cp')
62 files changed, 219 insertions, 100 deletions
diff --git a/tests/cp/abuse.sh b/tests/cp/abuse.sh index 80eb1d62..cf7b45ab 100755 --- a/tests/cp/abuse.sh +++ b/tests/cp/abuse.sh @@ -1,7 +1,7 @@ #!/bin/sh # ensure that cp does not write through a just-copied symlink -# 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 diff --git a/tests/cp/acl.sh b/tests/cp/acl.sh index 36a5d298..e397ff06 100755 --- a/tests/cp/acl.sh +++ b/tests/cp/acl.sh @@ -2,7 +2,7 @@ # copy files/directories across file system boundaries # and make sure acls are preserved appropriately -# 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/cp/attr-existing.sh b/tests/cp/attr-existing.sh index 7e48fbbc..74b26d73 100755 --- a/tests/cp/attr-existing.sh +++ b/tests/cp/attr-existing.sh @@ -1,7 +1,7 @@ #!/bin/sh # Make sure cp --attributes-only doesn't truncate existing data -# Copyright 2012-2014 Free Software Foundation, Inc. +# Copyright 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/cp/backup-1.sh b/tests/cp/backup-1.sh index 033f8a93..39f48170 100755 --- a/tests/cp/backup-1.sh +++ b/tests/cp/backup-1.sh @@ -1,7 +1,7 @@ #!/bin/sh # Test cp backup. -# Copyright (C) 1997-2014 Free Software Foundation, Inc. +# Copyright (C) 1997-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/cp/backup-dir.sh b/tests/cp/backup-dir.sh index 2b11fd18..e6ead6cf 100755 --- a/tests/cp/backup-dir.sh +++ b/tests/cp/backup-dir.sh @@ -1,7 +1,7 @@ #!/bin/sh # Ensure that cp -b doesn't back up directories. -# 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/cp/backup-is-src.sh b/tests/cp/backup-is-src.sh index ae2502e5..5b9da8dc 100755 --- a/tests/cp/backup-is-src.sh +++ b/tests/cp/backup-is-src.sh @@ -1,7 +1,7 @@ #!/bin/sh # Test cp backup to source file. -# 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/cp/capability.sh b/tests/cp/capability.sh index fb3bc1c8..843b520e 100755 --- a/tests/cp/capability.sh +++ b/tests/cp/capability.sh @@ -1,7 +1,7 @@ #!/bin/sh # Ensure cp --preserves copies capabilities -# Copyright (C) 2010-2014 Free Software Foundation, Inc. +# Copyright (C) 2010-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/cp/cp-HL.sh b/tests/cp/cp-HL.sh index bdc31ed5..08a72b13 100755 --- a/tests/cp/cp-HL.sh +++ b/tests/cp/cp-HL.sh @@ -1,7 +1,7 @@ #!/bin/sh # test cp's -H and -L options -# 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 @@ -33,7 +33,7 @@ test -d dest-dir/src-dir || fail=1 cat dest-dir/slink > /dev/null 2>&1 || fail=1 # Expect this to fail since *this* slink is a dangling symlink. -cat dest-dir/src-dir/slink > /dev/null 2>&1 && fail=1 +returns_ 1 cat dest-dir/src-dir/slink >/dev/null 2>&1 || fail=1 # FIXME: test -L, too. diff --git a/tests/cp/cp-a-selinux.sh b/tests/cp/cp-a-selinux.sh index 58887d27..d000ee8f 100755 --- a/tests/cp/cp-a-selinux.sh +++ b/tests/cp/cp-a-selinux.sh @@ -4,7 +4,7 @@ # Check also locally if --preserve=context, -a and --preserve=all # does work -# 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 @@ -49,14 +49,16 @@ rm -f f # in the destination, so SELinux contexts should be updated too. chmod o+rw restore/existing_dir mkdir -p backup/existing_dir/ || framework_failure_ -ls -Zd backup/existing_dir | grep $ctx && framework_failure_ +ls -Zd backup/existing_dir > ed_ctx || fail=1 +grep $ctx ed_ctx && framework_failure_ touch backup/existing_dir/file || framework_failure_ chcon $ctx backup/existing_dir/file || framework_failure_ # Set the dir context to ensure it is reset mkdir -p --context="$ctx" restore/existing_dir || framework_failure_ # Copy and ensure existing directories updated cp -a backup/. restore/ -ls -Zd restore/existing_dir | grep $ctx && +ls -Zd restore/existing_dir > ed_ctx || fail=1 +grep $ctx ed_ctx && { ls -lZd restore/existing_dir; fail=1; } # Check restorecon (-Z) functionality for file and directory @@ -64,7 +66,7 @@ get_selinux_type() { ls -Zd "$1" | sed -n 's/.*:\(.*_t\):.*/\1/p'; } # Also make a dir with our known context mkdir c_d || framework_failure_ chcon $ctx c_d || framework_failure_ -# Get the type of this known context for file and dir +# Get the type of this known context for file and dir for tracing old_type_f=$(get_selinux_type c) old_type_d=$(get_selinux_type c_d) # Setup copies for manipulation with restorecon @@ -80,7 +82,7 @@ if restorecon Z1 Z1_d 2>/dev/null; then cpZ_type_f=$(get_selinux_type Z2) test "$cpZ_type_f" = "$new_type_f" || fail=1 - # Ensuze -Z overrides -a and that dirs are handled too + # Ensure -Z overrides -a and that dirs are handled too cp -aZ c Z3 || fail=1 cp -aZ c_d Z3_d || fail=1 cpaZ_type_f=$(get_selinux_type Z3) @@ -175,6 +177,7 @@ for no_g_cmd in '' 'rm -f g'; do # restorecon equivalent. Note even though the context # returned from matchpathcon() will not match $ctx # the resulting ENOTSUP warning will be suppressed. + # With absolute path $no_g_cmd cp -Z ../f $(realpath g) || fail=1 @@ -186,7 +189,7 @@ for no_g_cmd in '' 'rm -f g'; do cp -Z -a ../f g || fail=1 # -Z doesn't take an arg $no_g_cmd - cp -Z "$ctx" ../f g && fail=1 + returns_ 1 cp -Z "$ctx" ../f g || fail=1 # Explicit context $no_g_cmd @@ -197,9 +200,9 @@ for no_g_cmd in '' 'rm -f g'; do cp -a --context="$ctx" ../f g || fail=1 done -# Mutually exlusive options -cp -Z --preserve=context ../f g && fail=1 -cp --preserve=context -Z ../f g && fail=1 -cp --preserve=context --context="$ctx" ../f g && fail=1 +# Mutually exclusive options +returns_ 1 cp -Z --preserve=context ../f g || fail=1 +returns_ 1 cp --preserve=context -Z ../f g || fail=1 +returns_ 1 cp --preserve=context --context="$ctx" ../f g || fail=1 Exit $fail diff --git a/tests/cp/cp-deref.sh b/tests/cp/cp-deref.sh index 63a1c22d..7de56e44 100755 --- a/tests/cp/cp-deref.sh +++ b/tests/cp/cp-deref.sh @@ -2,7 +2,7 @@ # cp -RL dir1 dir2' must handle the case in which each of dir1 and dir2 # contain a symlink pointing to some third 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 diff --git a/tests/cp/cp-i.sh b/tests/cp/cp-i.sh index 9f2905e6..e7414130 100755 --- a/tests/cp/cp-i.sh +++ b/tests/cp/cp-i.sh @@ -1,7 +1,7 @@ #!/bin/sh # Test whether cp -i prompts in the right place. -# 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 @@ -60,6 +60,6 @@ echo n | cp -vnf c d 2>/dev/null > out7 || fail=1 compare out7 out_empty || fail=1 # options --backup and --no-clobber are mutually exclusive -cp -bn c d 2>/dev/null && fail=1 +returns_ 1 cp -bn c d 2>/dev/null || fail=1 Exit $fail diff --git a/tests/cp/cp-mv-backup.sh b/tests/cp/cp-mv-backup.sh index e313b72c..15695f19 100755 --- a/tests/cp/cp-mv-backup.sh +++ b/tests/cp/cp-mv-backup.sh @@ -1,7 +1,7 @@ #!/bin/sh # Test basic --backup functionality for both cp and mv. -# 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/cp/cp-mv-enotsup-xattr.sh b/tests/cp/cp-mv-enotsup-xattr.sh index f46977b6..13f477d6 100755 --- a/tests/cp/cp-mv-enotsup-xattr.sh +++ b/tests/cp/cp-mv-enotsup-xattr.sh @@ -3,7 +3,7 @@ # as expected on file system without their support and do show correct # diagnostics when required -# Copyright (C) 2009-2014 Free Software Foundation, Inc. +# Copyright (C) 2009-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/cp/cp-parents.sh b/tests/cp/cp-parents.sh index e326d6bd..f0454f71 100755 --- a/tests/cp/cp-parents.sh +++ b/tests/cp/cp-parents.sh @@ -2,7 +2,7 @@ # cp -R --parents dir-specified-with-trailing-slash/ other-dir # would get a failed assertion. -# 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 @@ -42,7 +42,7 @@ test -d d/a/b/c || fail=1 # With 6.7 and earlier, cp --parents f/g d would mistakenly create a # directory d/f, even though f is a regular file. -cp --parents f/g d 2>/dev/null && fail=1 +returns_ 1 cp --parents f/g d 2>/dev/null || fail=1 test -d d/f && fail=1 # Check that re_protect works. diff --git a/tests/cp/deref-slink.sh b/tests/cp/deref-slink.sh index b81997be..8e094ff2 100755 --- a/tests/cp/deref-slink.sh +++ b/tests/cp/deref-slink.sh @@ -2,7 +2,7 @@ # Demonstrate bug when using -d with an existing destination file # that is a symlink. -# 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/cp/dir-rm-dest.sh b/tests/cp/dir-rm-dest.sh index 2723631d..e9e79937 100755 --- a/tests/cp/dir-rm-dest.sh +++ b/tests/cp/dir-rm-dest.sh @@ -1,7 +1,7 @@ #!/bin/sh # verify that cp's --remove-destination option works with -R -# 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/cp/dir-slash.sh b/tests/cp/dir-slash.sh index 42bf0696..0042de94 100755 --- a/tests/cp/dir-slash.sh +++ b/tests/cp/dir-slash.sh @@ -2,7 +2,7 @@ # Make sure that cp -R DIR1 DIR2 does the right thing # when DIR1 is written with a trailing slash. -# 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/cp/dir-vs-file.sh b/tests/cp/dir-vs-file.sh index 5398656e..8ac159c0 100755 --- a/tests/cp/dir-vs-file.sh +++ b/tests/cp/dir-vs-file.sh @@ -1,7 +1,7 @@ #!/bin/sh # A directory may not replace an existing file. -# 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 @@ -24,7 +24,7 @@ touch file || framework_failure_ # In 4.0.35, this cp invocation silently succeeded. -cp -R dir file 2>/dev/null && fail=1 +returns_ 1 cp -R dir file 2>/dev/null || fail=1 # Make sure file is not replaced with a directory. # In 4.0.35, it was. diff --git a/tests/cp/duplicate-sources.sh b/tests/cp/duplicate-sources.sh new file mode 100755 index 00000000..3b9e0cc1 --- /dev/null +++ b/tests/cp/duplicate-sources.sh @@ -0,0 +1,44 @@ +#!/bin/sh +# Ensure cp warns about but otherwise ignores source +# items specified multiple times. + +# 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 +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + +. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src +print_ver_ cp + +mkdir a || framework_failure_ +touch f || framework_failure_ + +# verify multiple files and dir sources only warned about +mkdir dest || framework_failure_ +cp -a a a f f dest 2>err || fail=1 +rm -Rf dest || framework_failure_ + +# verify multiple dirs and files with different names copied +mkdir dest || framework_failure_ +ln -s a al || framework_failure_ +ln -s f fl || framework_failure_ +cp -aH a al f fl dest 2>>err || fail=1 + +cat <<EOF >exp +cp: warning: source directory 'a' specified more than once +cp: warning: source file 'f' specified more than once +EOF + +compare exp err || fail=1 + +Exit $fail diff --git a/tests/cp/existing-perm-dir.sh b/tests/cp/existing-perm-dir.sh index 46f1be0d..b56041b1 100755 --- a/tests/cp/existing-perm-dir.sh +++ b/tests/cp/existing-perm-dir.sh @@ -1,7 +1,7 @@ #!/bin/sh # Make sure cp -p doesn't "restore" permissions it shouldn't (Bug#9170). -# Copyright 2011-2014 Free Software Foundation, Inc. +# Copyright 2011-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/cp/existing-perm-race.sh b/tests/cp/existing-perm-race.sh index c12cbb85..f48369cd 100755 --- a/tests/cp/existing-perm-race.sh +++ b/tests/cp/existing-perm-race.sh @@ -1,7 +1,7 @@ #!/bin/sh # Make sure cp -p isn't too generous with existing file permissions. -# 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 @@ -37,10 +37,12 @@ chgrp $g1 fifo && chgrp $g2 fifo-copy && chmod g+r fifo-copy || framework-failure +# Terminate any background cp process +cleanup_() { kill $pid 2>/dev/null && wait $pid; } + # Copy a fifo's contents. That way, we can examine the # destination permissions before they're finalized. -cp -p --copy-contents fifo fifo-copy & -cp_pid=$! +cp -p --copy-contents fifo fifo-copy & pid=$! ( # Now 'cp' is reading the fifo. Wait for the destination file to @@ -77,7 +79,7 @@ case $mode in *) fail=1;; esac -wait $cp_pid || fail=1 +wait $pid || fail=1 # Check that the final mode and group are right. ls -l -n fifo-copy >ls.out && diff --git a/tests/cp/fail-perm.sh b/tests/cp/fail-perm.sh index 83518417..6a9cc880 100755 --- a/tests/cp/fail-perm.sh +++ b/tests/cp/fail-perm.sh @@ -1,6 +1,6 @@ #!/bin/sh -# 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 @@ -27,7 +27,7 @@ chmod u=rx,go=,-st D || framework_failure_ # This is expected to exit non-zero, because it can't read D/a. -cp -pR D DD > /dev/null 2>&1 && fail=1 +returns_ 1 cp -pR D DD > /dev/null 2>&1 || fail=1 # Permissions on DD must be 'dr-x------' diff --git a/tests/cp/fiemap-2.sh b/tests/cp/fiemap-2.sh index 79e2c1c4..054be5f8 100755 --- a/tests/cp/fiemap-2.sh +++ b/tests/cp/fiemap-2.sh @@ -1,7 +1,7 @@ #!/bin/sh # Exercise a few more corners of the fiemap-copying code. -# Copyright (C) 2011-2014 Free Software Foundation, Inc. +# Copyright (C) 2011-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/cp/fiemap-FMR.sh b/tests/cp/fiemap-FMR.sh index 7c9e3198..96cc3bd2 100755 --- a/tests/cp/fiemap-FMR.sh +++ b/tests/cp/fiemap-FMR.sh @@ -1,7 +1,7 @@ #!/bin/sh # Trigger a free-memory read bug in cp from coreutils-[8.11..8.19] -# 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/cp/fiemap-empty.sh b/tests/cp/fiemap-empty.sh index 34aec424..b3b2cd72 100755 --- a/tests/cp/fiemap-empty.sh +++ b/tests/cp/fiemap-empty.sh @@ -1,7 +1,7 @@ #!/bin/sh # Test cp reads unwritten extents efficiently -# Copyright (C) 2011-2014 Free Software Foundation, Inc. +# Copyright (C) 2011-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 @@ -22,6 +22,7 @@ print_ver_ cp # FIXME: enable any part of this test that is still relevant, # or, if none are relevant (now that cp does not handle unwritten # extents), just remove the test altogether. +# Note also if checking allocations may need to sync first on BTRFS at least skip_ 'disabled for now' touch fiemap_chk diff --git a/tests/cp/fiemap-perf.sh b/tests/cp/fiemap-perf.sh index 10bb7324..5517ad0c 100755 --- a/tests/cp/fiemap-perf.sh +++ b/tests/cp/fiemap-perf.sh @@ -1,7 +1,7 @@ #!/bin/sh # ensure that a sparse file is copied efficiently, by default -# Copyright (C) 2011-2014 Free Software Foundation, Inc. +# Copyright (C) 2011-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 @@ -35,7 +35,7 @@ timeout 10 truncate -s1T f || # Disable this test on old BTRFS (e.g. Fedora 14) # which reports (unwritten) extents for holes. -filefrag f || skip_ 'the 'filefrag' utility is missing' +filefrag f || skip_ "the 'filefrag' utility is missing" filefrag f | grep -F ': 0 extents found' > /dev/null || skip_ 'this file system reports extents for holes' diff --git a/tests/cp/file-perm-race.sh b/tests/cp/file-perm-race.sh index 5a01675c..8197962d 100755 --- a/tests/cp/file-perm-race.sh +++ b/tests/cp/file-perm-race.sh @@ -1,7 +1,7 @@ #!/bin/sh # Make sure cp -p isn't too generous with file permissions. -# 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 @@ -25,10 +25,12 @@ require_local_dir_ umask 022 mkfifo_or_skip_ fifo +# Terminate any background cp process +cleanup_() { kill $pid 2>/dev/null && wait $pid; } + # Copy a fifo's contents. That way, we can examine the # destination permissions before they're finalized. -cp -p --copy-contents fifo fifo-copy & -cp_pid=$! +cp -p --copy-contents fifo fifo-copy & pid=$! ( # Now 'cp' is reading the fifo. Wait for the destination file to @@ -51,6 +53,6 @@ case $(cat ls.out) in *) fail=1;; esac -wait $cp_pid || fail=1 +wait $pid || fail=1 Exit $fail diff --git a/tests/cp/into-self.sh b/tests/cp/into-self.sh index 124be241..6799d659 100755 --- a/tests/cp/into-self.sh +++ b/tests/cp/into-self.sh @@ -1,7 +1,7 @@ #!/bin/sh # Confirm that copying a directory into itself gets a proper diagnostic. -# 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/cp/link-deref.sh b/tests/cp/link-deref.sh index 1b666589..b0efb6f8 100755 --- a/tests/cp/link-deref.sh +++ b/tests/cp/link-deref.sh @@ -1,7 +1,7 @@ #!/bin/sh # Exercise cp --link's behavior regarding the dereferencing of symbolic links. -# Copyright (C) 2013-2014 Free Software Foundation, Inc. +# Copyright (C) 2013-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 @@ -19,7 +19,8 @@ . "${srcdir=.}/tests/init.sh"; path_prepend_ ./src print_ver_ cp -if grep '^#define HAVE_LINKAT 1' "$CONFIG_HEADER" > /dev/null \ +if { grep '^#define HAVE_LINKAT 1' "$CONFIG_HEADER" > /dev/null \ + && grep '#undef LINKAT_SYMLINK_NOTSUP' "$CONFIG_HEADER" > /dev/null; } \ || grep '^#define LINK_FOLLOWS_SYMLINKS 0' "$CONFIG_HEADER" > /dev/null; then # With this config cp will attempt to linkat() to hardlink a symlink. # So now double check the current file system supports this operation. diff --git a/tests/cp/link-heap.sh b/tests/cp/link-heap.sh index 594ade89..901a92fc 100755 --- a/tests/cp/link-heap.sh +++ b/tests/cp/link-heap.sh @@ -1,7 +1,7 @@ #!/bin/sh # ensure that cp --preserve=link --link doesn't waste heap -# 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/cp/link-no-deref.sh b/tests/cp/link-no-deref.sh index 13fd0ef5..582ea5a3 100755 --- a/tests/cp/link-no-deref.sh +++ b/tests/cp/link-no-deref.sh @@ -1,7 +1,7 @@ #!/bin/sh # Ensure that cp --link --no-dereference works properly -# 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/cp/link-preserve.sh b/tests/cp/link-preserve.sh index c2cfd4ae..00ebe15c 100755 --- a/tests/cp/link-preserve.sh +++ b/tests/cp/link-preserve.sh @@ -2,7 +2,7 @@ # ensure that 'cp -d' preserves hard-links between command line arguments # ensure that --preserve=links works with -RH and -RL -# 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/cp/link-symlink.sh b/tests/cp/link-symlink.sh index 9aab0b85..6bdc9f59 100755 --- a/tests/cp/link-symlink.sh +++ b/tests/cp/link-symlink.sh @@ -1,7 +1,7 @@ #!/bin/sh # Ensure that cp -a --link maintains timestamps if possible -# Copyright (C) 2011-2014 Free Software Foundation, Inc. +# Copyright (C) 2011-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/cp/link.sh b/tests/cp/link.sh index 034a6275..b7917016 100755 --- a/tests/cp/link.sh +++ b/tests/cp/link.sh @@ -2,7 +2,7 @@ # Make sure cp --link -f works when the target exists. # This failed for 4.0z (due to a bug introduced in that test release). -# 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/cp/nfs-removal-race.sh b/tests/cp/nfs-removal-race.sh index 6969e8bd..fdac03f7 100755 --- a/tests/cp/nfs-removal-race.sh +++ b/tests/cp/nfs-removal-race.sh @@ -13,7 +13,7 @@ # This test is skipped on systems that lack LD_PRELOAD support; that's fine. # Similarly, on a system that lacks <dlfcn.h> or __xstat, skipping it is fine. -# 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 @@ -35,6 +35,7 @@ require_gcc_shared_ # Replace each stat call with a call to this wrapper. cat > k.c <<'EOF' || framework_failure_ #define _GNU_SOURCE +#include <stdio.h> #include <sys/types.h> #include <dlfcn.h> @@ -49,6 +50,7 @@ int __xstat (int ver, const char *path, struct stat *st) { static int (*real_stat)(int ver, const char *path, struct stat *st) = NULL; + fclose(fopen("preloaded", "w")); if (!real_stat) real_stat = dlsym (RTLD_NEXT, "__xstat"); /* When asked to stat nonexistent "d", @@ -65,7 +67,9 @@ touch d2 || framework_failure_ echo xyz > src || framework_failure_ # Finally, run the test: -LD_PRELOAD=./k.so cp src d || fail=1 +LD_PRELOAD=$LD_PRELOAD:./k.so cp src d || fail=1 + +test -f preloaded || skip_ 'LD_PRELOAD was ineffective?' compare src d || fail=1 Exit $fail diff --git a/tests/cp/no-ctx.sh b/tests/cp/no-ctx.sh index 8b1328a4..852b8e64 100755 --- a/tests/cp/no-ctx.sh +++ b/tests/cp/no-ctx.sh @@ -4,7 +4,7 @@ # This test is skipped on systems that lack LD_PRELOAD support; that's fine. # Similarly, on a system that lacks lgetfilecon altogether, skipping it is fine. -# Copyright (C) 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 @@ -50,14 +50,15 @@ gcc_shared_ k.c k.so \ touch file_src # New file with SELinux context optionally included -LD_PRELOAD=./k.so cp -a file_src file_dst || fail=1 +LD_PRELOAD=$LD_PRELOAD:./k.so cp -a file_src file_dst || fail=1 # Existing file with SELinux context optionally included -LD_PRELOAD=./k.so cp -a file_src file_dst || fail=1 +LD_PRELOAD=$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 cp --preserve=context file_src file_dst && fail=1 +( export LD_PRELOAD=$LD_PRELOAD:./k.so + returns_ 1 cp --preserve=context file_src file_dst ) || fail=1 test -e preloaded || skip_ 'LD_PRELOAD interception failed' diff --git a/tests/cp/no-deref-link1.sh b/tests/cp/no-deref-link1.sh index 50a94d37..7206b24b 100755 --- a/tests/cp/no-deref-link1.sh +++ b/tests/cp/no-deref-link1.sh @@ -1,7 +1,7 @@ #!/bin/sh # cp from 3.16 fails this test -# Copyright (C) 1997-2014 Free Software Foundation, Inc. +# Copyright (C) 1997-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/cp/no-deref-link2.sh b/tests/cp/no-deref-link2.sh index cf07bf9e..87ab74c3 100755 --- a/tests/cp/no-deref-link2.sh +++ b/tests/cp/no-deref-link2.sh @@ -1,7 +1,7 @@ #!/bin/sh # cp from 3.16 fails this test -# Copyright (C) 1997-2014 Free Software Foundation, Inc. +# Copyright (C) 1997-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/cp/no-deref-link3.sh b/tests/cp/no-deref-link3.sh index a8416855..ea69e217 100755 --- a/tests/cp/no-deref-link3.sh +++ b/tests/cp/no-deref-link3.sh @@ -1,7 +1,7 @@ #!/bin/sh # cp from 3.16 fails this test -# Copyright (C) 1997-2014 Free Software Foundation, Inc. +# Copyright (C) 1997-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/cp/parent-perm-race.sh b/tests/cp/parent-perm-race.sh index b7ea9143..c370f9e0 100755 --- a/tests/cp/parent-perm-race.sh +++ b/tests/cp/parent-perm-race.sh @@ -1,7 +1,7 @@ #!/bin/sh # Make sure cp -pR --parents isn't too generous with parent permissions. -# 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 @@ -26,6 +26,8 @@ umask 002 mkdir mode ownership d || framework_failure_ chmod g+s d 2>/dev/null # The cp test is valid either way. +# Terminate any background cp process +cleanup_() { kill $pid 2>/dev/null && wait $pid; } for attr in mode ownership do @@ -33,8 +35,7 @@ do # Copy a fifo's contents. That way, we can examine d/$attr's # state while cp is running. - cp --preserve=$attr -R --copy-contents --parents $attr d & - cp_pid=$! + cp --preserve=$attr -R --copy-contents --parents $attr d & pid=$! ( # Now 'cp' is reading the fifo. @@ -58,7 +59,7 @@ do fail=1;; esac - wait $cp_pid || fail=1 + wait $pid || fail=1 done Exit $fail diff --git a/tests/cp/parent-perm.sh b/tests/cp/parent-perm.sh index 0a9c41e0..3b557b6d 100755 --- a/tests/cp/parent-perm.sh +++ b/tests/cp/parent-perm.sh @@ -1,7 +1,7 @@ #!/bin/sh # Ensure that cp --parents works properly with a preexisting dest. directory -# 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/cp/perm.sh b/tests/cp/perm.sh index 8311cd21..a8b87977 100755 --- a/tests/cp/perm.sh +++ b/tests/cp/perm.sh @@ -1,7 +1,7 @@ #!/bin/sh # Make sure the permission-preserving code in copy.c (mv, cp, install) works. -# 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/cp/preserve-2.sh b/tests/cp/preserve-2.sh index ac2fcf6a..9918e119 100755 --- a/tests/cp/preserve-2.sh +++ b/tests/cp/preserve-2.sh @@ -1,7 +1,7 @@ #!/bin/sh # ensure that cp's --preserve=X,Y option is parsed properly -# 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/cp/preserve-gid.sh b/tests/cp/preserve-gid.sh index f141ac14..89b88575 100755 --- a/tests/cp/preserve-gid.sh +++ b/tests/cp/preserve-gid.sh @@ -1,7 +1,7 @@ #!/bin/sh # Verify that cp -p preserves GID when it is possible. -# 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 @@ -117,7 +117,8 @@ t1() { u=$1; shift g=$1; shift t0 "$f" "$u" "$g" \ - chroot --user=+$nameless_uid:+$nameless_gid1 \ + chroot --skip-chdir \ + --user=+$nameless_uid:+$nameless_gid1 \ --groups="+$nameless_gid1,+$nameless_gid2" \ / env PATH="$tmp_path" "$@" } diff --git a/tests/cp/preserve-link.sh b/tests/cp/preserve-link.sh index b7e4aa28..b0eb7de7 100755 --- a/tests/cp/preserve-link.sh +++ b/tests/cp/preserve-link.sh @@ -1,7 +1,7 @@ #!/bin/sh # Exercise the fix for http://debbugs.gnu.org/8419 -# Copyright (C) 2011-2014 Free Software Foundation, Inc. +# Copyright (C) 2011-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/cp/preserve-mode.sh b/tests/cp/preserve-mode.sh index 3b36defc..c86c5503 100755 --- a/tests/cp/preserve-mode.sh +++ b/tests/cp/preserve-mode.sh @@ -1,7 +1,7 @@ #!/bin/sh # ensure that cp's --no-preserve=mode works correctly -# 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/cp/preserve-slink-time.sh b/tests/cp/preserve-slink-time.sh index c6c3548f..68114fa8 100755 --- a/tests/cp/preserve-slink-time.sh +++ b/tests/cp/preserve-slink-time.sh @@ -1,7 +1,7 @@ #!/bin/sh # Verify that cp -Pp preserves times even on symlinks. -# Copyright (C) 2009-2014 Free Software Foundation, Inc. +# Copyright (C) 2009-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/cp/proc-short-read.sh b/tests/cp/proc-short-read.sh index bd665620..5dbf8fd5 100755 --- a/tests/cp/proc-short-read.sh +++ b/tests/cp/proc-short-read.sh @@ -1,7 +1,7 @@ #!/bin/sh # exercise cp's short-read failure when operating on >4KB files in /proc -# Copyright (C) 2009-2014 Free Software Foundation, Inc. +# Copyright (C) 2009-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/cp/proc-zero-len.sh b/tests/cp/proc-zero-len.sh index 3fcd5aab..33006b14 100755 --- a/tests/cp/proc-zero-len.sh +++ b/tests/cp/proc-zero-len.sh @@ -1,7 +1,7 @@ #!/bin/sh # Ensure that cp copies contents of non-empty "regular" file with st_size==0 -# 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 @@ -31,7 +31,7 @@ cat $f > out || fail=1 # number of the file changed during the cp run. cp $f exp 2>err \ || { fail=1; - grep 'replaced while being copied' \ + grep 'replaced while being copied' err \ && skip_ "File $f is being replaced while being copied"; } # Don't simply compare contents; they might differ, diff --git a/tests/cp/r-vs-symlink.sh b/tests/cp/r-vs-symlink.sh index 9398c9b4..bc2ef360 100755 --- a/tests/cp/r-vs-symlink.sh +++ b/tests/cp/r-vs-symlink.sh @@ -1,7 +1,7 @@ #!/bin/sh # cp -r should not create symlinks. Fixed in fileutils-4.1.5. -# 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/cp/reflink-auto.sh b/tests/cp/reflink-auto.sh index a16fdc66..b0464a2e 100755 --- a/tests/cp/reflink-auto.sh +++ b/tests/cp/reflink-auto.sh @@ -1,7 +1,7 @@ #!/bin/sh # Test cp --reflink=auto -# Copyright (C) 2009-2014 Free Software Foundation, Inc. +# Copyright (C) 2009-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 @@ -27,7 +27,7 @@ rm -f "$a_other" || framework_failure_ echo non_zero_size > "$a_other" || framework_failure_ # we shouldn't be able to reflink() files on separate partitions -cp --reflink "$a_other" b && fail=1 +returns_ 1 cp --reflink "$a_other" b || fail=1 # --reflink=auto should fall back to a normal copy cp --reflink=auto "$a_other" b || fail=1 diff --git a/tests/cp/reflink-perm.sh b/tests/cp/reflink-perm.sh index 52f5e257..7160f46d 100755 --- a/tests/cp/reflink-perm.sh +++ b/tests/cp/reflink-perm.sh @@ -1,7 +1,7 @@ #!/bin/sh # Test cp --reflink copies permissions -# Copyright (C) 2009-2014 Free Software Foundation, Inc. +# Copyright (C) 2009-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/cp/same-file.sh b/tests/cp/same-file.sh index f62a9a72..47c6507c 100755 --- a/tests/cp/same-file.sh +++ b/tests/cp/same-file.sh @@ -2,7 +2,7 @@ # Test some of cp's options and how cp handles situations in # which a naive implementation might overwrite the source file. -# 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 @@ -36,7 +36,7 @@ ln dangling-slink hard-link > /dev/null 2>&1 \ rm -f no-such dangling-slink hard-link test $hard_link_to_symlink_does_the_deref = yes \ - && remove_these_sed='/^0 -[bf]*l .*sl1 ->/d' \ + && remove_these_sed='/^0 -[bf]*l .*sl1 ->/d; /hlsl/d' \ || remove_these_sed='/^ELIDE NO TEST OUTPUT/d' exec 3>&1 1> actual @@ -44,7 +44,8 @@ exec 3>&1 1> actual # FIXME: This should be bigger: like more than 8k contents=XYZ -for args in 'foo symlink' 'symlink foo' 'foo foo' 'sl1 sl2' 'foo hardlink'; do +for args in 'foo symlink' 'symlink foo' 'foo foo' 'sl1 sl2' \ + 'foo hardlink' 'hlsl sl2'; do for options in '' -d -f -df --rem -b -bd -bf -bdf \ -l -dl -fl -dfl -bl -bdl -bfl -bdfl; do case $args$options in @@ -76,6 +77,8 @@ for args in 'foo symlink' 'symlink foo' 'foo foo' 'sl1 sl2' 'foo hardlink'; do continue ;; 'yes:sl1 sl2:-bfl') continue ;; + yes:hlsl*) + continue ;; esac rm -rf dir @@ -86,6 +89,7 @@ for args in 'foo symlink' 'symlink foo' 'foo foo' 'sl1 sl2' 'foo hardlink'; do case "$args" in *hardlink*) ln foo hardlink ;; esac case "$args" in *sl1*) ln -s foo sl1;; esac case "$args" in *sl2*) ln -s foo sl2;; esac + case "$args" in *hlsl*) ln sl2 hlsl;; esac ( ( # echo 1>&2 cp $options $args @@ -211,6 +215,24 @@ cat <<\EOF | sed "$remove_these_sed" > expected 0 -bfl (foo hardlink) 0 -bdfl (foo hardlink) +1 [cp: 'hlsl' and 'sl2' are the same file] (foo hlsl -> foo sl2 -> foo) +0 -d (foo hlsl -> foo sl2 -> foo) +1 -f [cp: 'hlsl' and 'sl2' are the same file] (foo hlsl -> foo sl2 -> foo) +0 -df (foo hlsl -> foo sl2 -> foo) +0 --rem (foo hlsl -> foo sl2) +0 -b (foo hlsl -> foo sl2 sl2.~1~ -> foo) +0 -bd (foo hlsl -> foo sl2 -> foo sl2.~1~ -> foo) +0 -bf (foo hlsl -> foo sl2 sl2.~1~ -> foo) +0 -bdf (foo hlsl -> foo sl2 -> foo sl2.~1~ -> foo) +1 -l [cp: cannot create hard link 'sl2' to 'hlsl'] (foo hlsl -> foo sl2 -> foo) +0 -dl (foo hlsl -> foo sl2 -> foo) +0 -fl (foo hlsl -> foo sl2) +0 -dfl (foo hlsl -> foo sl2 -> foo) +0 -bl (foo hlsl -> foo sl2 sl2.~1~ -> foo) +0 -bdl (foo hlsl -> foo sl2 -> foo) +0 -bfl (foo hlsl -> foo sl2 sl2.~1~ -> foo) +0 -bdfl (foo hlsl -> foo sl2 -> foo) + EOF exec 1>&3 3>&- diff --git a/tests/cp/slink-2-slink.sh b/tests/cp/slink-2-slink.sh index 19a28621..65cce9e6 100755 --- a/tests/cp/slink-2-slink.sh +++ b/tests/cp/slink-2-slink.sh @@ -2,7 +2,7 @@ # 'test cp --update A B' where A and B are both symlinks that point # to the same file -# 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/cp/sparse-fiemap.sh b/tests/cp/sparse-fiemap.sh index 7aa24715..ac6ea3c7 100755 --- a/tests/cp/sparse-fiemap.sh +++ b/tests/cp/sparse-fiemap.sh @@ -1,7 +1,7 @@ #!/bin/sh # Test cp --sparse=always through fiemap copy -# Copyright (C) 2010-2014 Free Software Foundation, Inc. +# Copyright (C) 2010-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/cp/sparse-to-pipe.sh b/tests/cp/sparse-to-pipe.sh index b800e069..2c3dcefb 100755 --- a/tests/cp/sparse-to-pipe.sh +++ b/tests/cp/sparse-to-pipe.sh @@ -1,7 +1,7 @@ #!/bin/sh # copy a sparse file to a pipe, to exercise some seldom-used parts of copy.c -# Copyright (C) 2011-2014 Free Software Foundation, Inc. +# Copyright (C) 2011-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,14 +21,17 @@ print_ver_ cp require_sparse_support_ +# Terminate any background cp process +cleanup_() { kill $pid 2>/dev/null && wait $pid; } + mkfifo_or_skip_ pipe -timeout 10 cat pipe > copy & +timeout 10 cat pipe > copy & pid=$! truncate -s1M sparse || framework_failure_ cp sparse pipe || fail=1 # Ensure that the cat has completed before comparing. -wait +wait $pid cmp sparse copy || fail=1 diff --git a/tests/cp/sparse.sh b/tests/cp/sparse.sh index d6cc4c4b..958de830 100755 --- a/tests/cp/sparse.sh +++ b/tests/cp/sparse.sh @@ -1,7 +1,7 @@ #!/bin/sh # Test cp --sparse=always -# 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 @@ -34,7 +34,40 @@ cp --sparse=always sparse copy || fail=1 test $(stat --printf %b copy) -le $(stat --printf %b sparse) || fail=1 # Ensure that --sparse={always,never} with --reflink fail. -cp --sparse=always --reflink sparse copy && fail=1 -cp --sparse=never --reflink sparse copy && fail=1 +returns_ 1 cp --sparse=always --reflink sparse copy || fail=1 +returns_ 1 cp --sparse=never --reflink sparse copy || fail=1 + + +# Ensure we handle sparse/non-sparse transitions correctly +maxn=128 # how many $hole_size chunks per file +hole_size=$(stat -c %o copy) +dd if=/dev/zero bs=$hole_size count=$maxn of=zeros || framework_failure_ +tr '\0' 'U' < zeros > nonzero || framework_failure_ + +for pattern in 1 0; do + test "$pattern" = 1 && pattern="$(printf '%s\n%s' nonzero zeros)" + test "$pattern" = 0 && pattern="$(printf '%s\n%s' zeros nonzero)" + + for n in 1 2 4 11 32 $maxn; do + parts=$(expr $maxn / $n) + + rm -f sparse.in + + # Generate non sparse file for copying with alternating + # hole/data patterns of size n * $hole_size + for i in $(yes "$pattern" | head -n$parts); do + dd iflag=fullblock if=$i of=sparse.in conv=notrunc oflag=append \ + bs=$hole_size count=$n status=none || framework_failure_ + done + + cp --sparse=always sparse.in sparse.out || fail=1 # non sparse input + cp --sparse=always sparse.out sparse.out2 || fail=1 # sparse input + + cmp sparse.in sparse.out || fail=1 + cmp sparse.in sparse.out2 || fail=1 + + ls -lsh sparse.* + done +done Exit $fail diff --git a/tests/cp/special-bits.sh b/tests/cp/special-bits.sh index a55eea21..ec17ccec 100755 --- a/tests/cp/special-bits.sh +++ b/tests/cp/special-bits.sh @@ -2,7 +2,7 @@ # make sure 'cp -p' preserves special bits # This works only when run as root. -# 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 @@ -42,7 +42,8 @@ set _ $(ls -l b); shift; p1=$1 set _ $(ls -l b2); shift; p2=$1 test $p1 = $p2 || fail=1 -chroot --user=$NON_ROOT_USERNAME / env PATH="$PATH" cp -p c c2 || fail=1 +chroot --skip-chdir --user=$NON_ROOT_USERNAME / env PATH="$PATH" cp -p c c2 \ + || fail=1 set _ $(ls -l c); shift; p1=$1 set _ $(ls -l c2); shift; p2=$1 test $p1 = $p2 && fail=1 diff --git a/tests/cp/special-f.sh b/tests/cp/special-f.sh index ee01bb33..2217c675 100755 --- a/tests/cp/special-f.sh +++ b/tests/cp/special-f.sh @@ -2,7 +2,7 @@ # Ensure that "cp -Rf fifo E" unlinks E and retries. # Up until coreutils-6.10.171, it would not. -# 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/cp/src-base-dot.sh b/tests/cp/src-base-dot.sh index 599f4cdc..75aa62e0 100755 --- a/tests/cp/src-base-dot.sh +++ b/tests/cp/src-base-dot.sh @@ -1,7 +1,7 @@ #!/bin/sh # Ensure that "mkdir x y; cd y; cp -ab ../x/. ." is a successful, silent, no-op. -# 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/cp/symlink-slash.sh b/tests/cp/symlink-slash.sh index 1ae846b6..ee70b77e 100755 --- a/tests/cp/symlink-slash.sh +++ b/tests/cp/symlink-slash.sh @@ -2,7 +2,7 @@ # Make sure that cp -dR dereferences a symlink arg if its name is # written with a trailing slash. -# 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/cp/thru-dangling.sh b/tests/cp/thru-dangling.sh index f4a609d5..bd8e7084 100755 --- a/tests/cp/thru-dangling.sh +++ b/tests/cp/thru-dangling.sh @@ -1,7 +1,7 @@ #!/bin/sh # Ensure that cp works as documented, when the destination is a dangling symlink -# 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 |