common/rc: Add _require_filefrag_options() to check options for filefrag
authorXiao Yang <yangx.jy@cn.fujitsu.com>
Fri, 23 Nov 2018 05:24:23 +0000 (13:24 +0800)
committerEryu Guan <guaneryu@gmail.com>
Fri, 23 Nov 2018 06:25:01 +0000 (14:25 +0800)
In generic/519, filefrag command use FIBMAP ioctl(-B option) to print
output in extent format(-e option) on purpose and sync file(-s option),
so add _require_filefrag_options() to check if the command supports
all of these options.

References:
1) filefrag supports -e option by commit 2508eaa since e2fsprogs v1.42.7.
2) filefrag supports -B option by commit 5d5e01d since e2fsprogs v1.41.9.
3) filefrag supports -s option by commit e62847c since e2fsprogs v1.41.6.

Signed-off-by: Xiao Yang <yangx.jy@cn.fujitsu.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
common/rc
tests/generic/519

index ecb17380bad8e4861ef825b3746b25cd92686f17..e5da648466ebf4237113ccd7d23dbb5e6d6203db 100644 (file)
--- a/common/rc
+++ b/common/rc
@@ -3843,10 +3843,23 @@ _require_scratch_btime()
        _scratch_unmount
 }
 
-_require_fibmap()
+_require_filefrag_options()
 {
        _require_command "$FILEFRAG_PROG" filefrag
 
+       local options=$1
+       local file="$TEST_DIR/options_testfile"
+
+       echo "XX" > $file
+       ${FILEFRAG_PROG} -$options $file 2>&1 | grep -q "invalid option" && \
+               _notrun "filefrag doesn't support $options option"
+       rm -f $file
+}
+
+_require_fibmap()
+{
+       _require_filefrag_options "B"
+
        local file="$TEST_DIR/fibmap_testfile"
 
        echo "XX" > $file
index 229c5b4618fe38cf23838abfd3df966816337db9..d1a3c1711ec1483f9112226136522aa817b51660 100755 (executable)
@@ -33,8 +33,8 @@ rm -f $seqres.full
 _supported_fs generic
 _supported_os Linux
 _require_scratch
-_require_command "$FILEFRAG_PROG" filefrag
 _require_fibmap
+_require_filefrag_options "es"
 
 testfile="$SCRATCH_MNT/$seq-testfile"