]> git-server-git.apps.pok.os.sepia.ceph.com Git - xfstests-dev.git/commitdiff
common/btrfs: refactor _require_btrfs_corrupt_block to check option
authorAnand Jain <anand.jain@oracle.com>
Fri, 22 Mar 2024 07:05:46 +0000 (15:05 +0800)
committerZorro Lang <zlang@kernel.org>
Sun, 28 Apr 2024 11:08:22 +0000 (19:08 +0800)
The -v and -o short options in btrfs-corrupt-block were introduced and
replaced with the long options --value and --offset in the same
btrfs-progs release 5.19 by the following commits:

  b2ada0594116 ("btrfs-progs: corrupt-block: corrupt generic item data")
  22ffee3c6cf2 ("btrfs-progs: corrupt-block: use only long options for value and offset")

We hope that if these commits are backported, they are both backported at
the same time.

Use only the long options of btrfs-corrupt-block in the test cases. Also,
check if btrfs-corrupt-block has the options --value and --offset.

[zlang: use -w option for grep, and remove "ret" local value]

Signed-off-by: Anand Jain <anand.jain@oracle.com>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
common/btrfs

index 06ea63e843018dd54432fe433fb73d0e783574f8..be5948db7e4957673b72a6b0396b03cfd852dc1c 100644 (file)
@@ -759,7 +759,19 @@ _btrfs_buffered_read_on_mirror()
 
 _require_btrfs_corrupt_block()
 {
+       # An optional arg1 argument to also check the option.
+       local opt=$1
+
        _require_command "$BTRFS_CORRUPT_BLOCK_PROG" btrfs-corrupt-block
+
+       if [ -z "$opt" ]; then
+               return
+       fi
+
+       $BTRFS_CORRUPT_BLOCK_PROG -h 2>&1 | grep -wq -- "--$opt"
+       if [ $? != 0 ]; then
+               _notrun "Require $BTRFS_CORRUPT_BLOCK_PROG option --$opt"
+       fi
 }
 
 _require_btrfs_send_version()