From: Anand Jain Date: Fri, 22 Mar 2024 07:05:46 +0000 (+0800) Subject: common/btrfs: refactor _require_btrfs_corrupt_block to check option X-Git-Tag: v2024.04.28~5 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=e6ab6f9c046ebf627a2a50f98f4306871228e9d3;p=xfstests-dev.git common/btrfs: refactor _require_btrfs_corrupt_block to check option 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 Reviewed-by: Zorro Lang Signed-off-by: Zorro Lang --- diff --git a/common/btrfs b/common/btrfs index 06ea63e8..be5948db 100644 --- a/common/btrfs +++ b/common/btrfs @@ -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()