summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorPádraig Brady <P@draigBrady.com>2009-09-21 08:43:03 +0100
committerPádraig Brady <P@draigBrady.com>2010-07-01 14:33:27 +0100
commit1af81dfb4d24d104777b8917544d81097db0deab (patch)
tree3030f158798f4246a3b7d38ba9262adb57705849 /tests
parent8aa15b2be2bd2ab4b76d197a279abf8b9091680a (diff)
downloadcoreutils-1af81dfb4d24d104777b8917544d81097db0deab.tar.xz
cp: add an option to only copy the file attributes
* src/copy.c (copy_attr): A new function which merges copy_attr_by_fd and copy_attr_by_name. Also display all errors when --attributes-only * src/copy.c (copy_reg): Skip copying the file contents if specified. Refactor the SELinux error handling code a little and display all SELinux errors when only copying attributes. * src/copy.h (struct cp_options): Add a data_copy_required boolean * src/cp.c (main): Default to copying data but don't if specified * src/install.c: Default to copying data * src/mv.c: Likewise tests/cp/reflink-perm: Add a test to check that --attributes-only does not copy data * tests/cp/acl: Likewise. Also refactor to remove redundant acl manipulation * doc/coreutils.texi (cp invocation): Describe the new option * NEWS: Mention the new feature
Diffstat (limited to 'tests')
-rwxr-xr-xtests/cp/acl22
-rwxr-xr-xtests/cp/reflink-perm4
2 files changed, 17 insertions, 9 deletions
diff --git a/tests/cp/acl b/tests/cp/acl
index 010348a9d..c19eb4e93 100755
--- a/tests/cp/acl
+++ b/tests/cp/acl
@@ -36,28 +36,32 @@ grep '^#define USE_ACL 1' $CONFIG_HEADER > /dev/null ||
mkdir -p a b || framework_failure
touch a/file || framework_failure
-skip=no
# Ensure that setfacl and getfacl work on this file system.
+skip=no
+acl1=`cd a && getfacl file` || skip=yes
setfacl -m user:bin:rw a/file 2> /dev/null || skip=yes
-acl1=`cd a && getfacl file | grep -v ':bin:' | grep -v 'mask::'` \
- || skip=yes
-
test $skip = yes &&
skip_test_ "'.' is not on a suitable file system for this test"
# copy a file without preserving permissions
cp a/file b/ || fail=1
-
acl2=`cd b && getfacl file` || framework_failure
test "$acl1" = "$acl2" || fail=1
-rm a/file || framework_failure
-# copy a file, preserving permissions
-touch a/file || framework_failure
-setfacl -m user:bin:rw a/file || framework_failure
+# Update with acl set above
acl1=`cd a && getfacl file` || framework_failure
+
+# copy a file, preserving permissions
cp -p a/file b/ || fail=1
acl2=`cd b && getfacl file` || framework_failure
test "$acl1" = "$acl2" || fail=1
+# copy a file, preserving permissions, with --attributes-only
+echo > a/file || framework_failure # add some data
+test -s a/file || framework_failure
+cp -p --attributes-only a/file b/ || fail=1
+test -s b/file && fail=1
+acl2=`cd b && getfacl file` || framework_failure
+test "$acl1" = "$acl2" || fail=1
+
Exit $fail
diff --git a/tests/cp/reflink-perm b/tests/cp/reflink-perm
index 92cb7ae8f..77f119f4a 100755
--- a/tests/cp/reflink-perm
+++ b/tests/cp/reflink-perm
@@ -39,4 +39,8 @@ test "$mode" = "-rwxrwxrwx" || fail=1
test copy -nt file && fail=1
+echo > file2 # file with data
+cp --reflink=auto --preserve --attributes-only file2 empty_copy || fail=1
+test -s empty_copy && fail=1
+
Exit $fail