All of lore.kernel.org
 help / color / mirror / Atom feed
From: Anand Jain <anand.jain@oracle.com>
To: fstests@vger.kernel.org
Cc: linux-btrfs@vger.kernel.org
Subject: [PATCH] btrfs/029: fix the test compatible with older cp(1)
Date: Fri,  4 Jun 2021 14:25:47 +0800	[thread overview]
Message-ID: <09a46a038b552686766899cf06112dffbb835902.1622787708.git.anand.jain@oracle.com> (raw)

cp(1) versions 8.30 and 8.32 are compared with its --reflink=always option
and they have different semantic if the target-file (with zero sizes) must be
created when the cp --reflink=alaways fails with a cross-device link
error. As shown below.

$ cp --version | head -1
cp (GNU coreutils) 8.30

$ cp --reflink=always /mnt/scratch/original /mnt/test/test-029/copy
cp: failed to clone '/mnt/test/test-029/copy' from '/mnt/scratch/original': Invalid cross-device link

$ ls -l /mnt/test/test-029/copy
ls: cannot access '/mnt/test/test-029/copy': No such file or directory

$ cp --version | head -1
cp (GNU coreutils) 8.32

$ cp --reflink=always /mnt/scratch/original /mnt/test/test-029/copy;
cp: failed to clone '/mnt/test/test-029/copy' from '/mnt/scratch/original': Invalid cross-device link

$ ls -l /mnt/test/test-029/copy
-rw------- 1 root root 0 Jun  4 13:29 /mnt/test/test-029/copy

Reported-by: Wang Yugui <wangyugui@e16-tech.com>
Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
 tests/btrfs/029     | 6 ++++--
 tests/btrfs/029.out | 2 --
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/tests/btrfs/029 b/tests/btrfs/029
index bbbb79708180..0234a7f0142b 100755
--- a/tests/btrfs/029
+++ b/tests/btrfs/029
@@ -65,8 +65,10 @@ _create_reflinks()
     echo "reflink=always:"
     cp --reflink=always $1 $2 >> $seqres.full 2>&1 || echo "cp reflink failed"
 
-    # The failed target actually gets created by cp:
-    ls $2 | _filter_testdir_and_scratch
+    # The failed target gets created with zero sizes by cp(1) version 8.32. But
+    # in older cp(1) version 8.30 target file is not created when the
+    # cp --reflink=always fails.
+    ls $2 >> $seqres.full 2>&1
 }
 
 echo "test reflinks across different devices"
diff --git a/tests/btrfs/029.out b/tests/btrfs/029.out
index 0547d2803308..f1c887807650 100644
--- a/tests/btrfs/029.out
+++ b/tests/btrfs/029.out
@@ -5,11 +5,9 @@ reflink=auto:
 42d69d1a6d333a7ebdf64792a555e392  TEST_DIR/test-029/copy
 reflink=always:
 cp reflink failed
-TEST_DIR/test-029/copy
 test reflinks across different mountpoints of same device
 reflink=auto:
 42d69d1a6d333a7ebdf64792a555e392  SCRATCH_MNT/original
 42d69d1a6d333a7ebdf64792a555e392  TEST_DIR/test-029/copy
 reflink=always:
 cp reflink failed
-TEST_DIR/test-029/copy
-- 
2.27.0


                 reply	other threads:[~2021-06-04  6:26 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=09a46a038b552686766899cf06112dffbb835902.1622787708.git.anand.jain@oracle.com \
    --to=anand.jain@oracle.com \
    --cc=fstests@vger.kernel.org \
    --cc=linux-btrfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.