mirror of
https://github.com/linux-apfs/apfstests.git
synced 2026-05-01 15:01:44 -07:00
fstests: filter test and scratch together safely
Several tests uses both _filter_test_dir and _filter_scratch concatenated by pipe to filter $TEST_DIR and $SCRATCH_MNT. However, this would fail if the shorter string is a substring of the other (like "/mnt" and "/mnt2"). This patch introduces new common filter function to safely call both _filter_test_dir and _filter_scratch, and update tests and functions to use this new function. I checked this with btrfs/029, generic/409,410,411, and generic/381,383, xfs/106,108 (which calls _filter_quota). Thanks Eryu for advice. [eguan: folded 2nd patch into 1st patch and update commit log a bit] Signed-off-by: Tomohiro Misono <misono.tomohiro@jp.fujitsu.com> Reviewed-by: Eryu Guan <eguan@redhat.com> Signed-off-by: Eryu Guan <eguan@redhat.com>
This commit is contained in:
committed by
Eryu Guan
parent
0e641bc6eb
commit
948b1881f6
+12
-1
@@ -295,6 +295,17 @@ _filter_scratch()
|
||||
-e "/.use_space/d"
|
||||
}
|
||||
|
||||
_filter_testdir_and_scratch()
|
||||
{
|
||||
# filter both $TEST_DIR and $SCRATCH_MNT, but always filter the longer
|
||||
# string first if the other string is a substring of the first one
|
||||
if echo "$TEST_DIR" | grep -q "$SCRATCH_MNT"; then
|
||||
_filter_test_dir | _filter_scratch
|
||||
else
|
||||
_filter_scratch | _filter_test_dir
|
||||
fi
|
||||
}
|
||||
|
||||
# Turn any device in the scratch pool into SCRATCH_DEV
|
||||
_filter_scratch_pool()
|
||||
{
|
||||
@@ -311,7 +322,7 @@ _filter_quota()
|
||||
{
|
||||
# Long dev name might be split onto its own line; last
|
||||
# seds remove that newline if present
|
||||
_filter_scratch | _filter_test_dir | _filter_spaces | \
|
||||
_filter_testdir_and_scratch | _filter_spaces | \
|
||||
sed -e 'N;s/SCRATCH_DEV\n/SCRATCH_DEV/g' | \
|
||||
sed -e 'N;s/TEST_DEV\n/TEST_DEV/g'
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user