fstests: fix test and scratch filters for overlapping DEV/MNT paths
authorAmir Goldstein <amir73il@gmail.com>
Tue, 28 Feb 2017 12:18:31 +0000 (14:18 +0200)
committerEryu Guan <eguan@redhat.com>
Wed, 1 Mar 2017 10:35:18 +0000 (18:35 +0800)
When configuring overlay base fs, TEST_DEV/DIR and SCRATCH_DEV/MNT
are derived from the base fs mount points, where *_DEV are the
path of the base fs mount point and TEST_DIR/SCRATCH_MNT are
a directory under the base fs mount point.

This means that the overlay DEV paths are prefixes of the overlay
mount points.
Fix the test and sctach filters to check if TEST_DEV/SCRATCH_DEV is
a substring of TEST_DIR/SCRATCH_MNT and try and match the longer
string first.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
common/filter

index 43281599d72956abcca442c4362d8f712fdc65a9..010f080b1c2f945b8a28203c116ff91c1b293eb5 100644 (file)
@@ -280,14 +280,32 @@ _filter_xfs_io_pages_modified()
 
 _filter_test_dir()
 {
-       sed -e "s,$TEST_DEV,TEST_DEV,g" -e "s,$TEST_DIR,TEST_DIR,g"
+       if ( echo $TEST_DIR | grep -q $TEST_DEV ); then
+               # TEST_DEV is substr of TEST_DIR (e.g. /mnt and /mnt/ovl-mnt)
+               # substitute TEST_DIR first
+               sed -e "s,$TEST_DIR,TEST_DIR,g" \
+                   -e "s,$TEST_DEV,TEST_DEV,g"
+       else
+               # TEST_DIR maybe a substr of TEST_DIR (e.g. /vdc and /dev/vdc)
+               # substitute TEST_DEV first
+               sed -e "s,$TEST_DEV,TEST_DEV,g" \
+                   -e "s,$TEST_DIR,TEST_DIR,g"
+       fi
 }
 
 _filter_scratch()
 {
-       sed -e "s,$SCRATCH_DEV,SCRATCH_DEV,g" \
-           -e "s,$SCRATCH_MNT,SCRATCH_MNT,g" \
-           -e "/.use_space/d"
+       if ( echo $SCRATCH_MNT | grep -q $SCRATCH_DEV ); then
+               # SCRATCH_DEV is substr of SCRATCH_MNT
+               sed -e "s,$SCRATCH_MNT,SCRATCH_MNT,g" \
+                   -e "s,$SCRATCH_DEV,SCRATCH_DEV,g" \
+                   -e "/.use_space/d"
+       else
+               # SCRATCH_MNT maybe a substr of SCRATCH_DEV
+               sed -e "s,$SCRATCH_DEV,SCRATCH_DEV,g" \
+                   -e "s,$SCRATCH_MNT,SCRATCH_MNT,g" \
+                   -e "/.use_space/d"
+       fi
 }
 
 # Turn any device in the scratch pool into SCRATCH_DEV