btrfs-progs/tests/common.local
Qu Wenruo eca65a8977 btrfs-progs: tests: Allow check test to repair in lowmem mode for certain errors
Since lowmem mode can repair certain corruptions (mostly in fs tree),
insert a beacon into each fsck test cases to allow some of them be
tested in lowmem mode.

With this patch, fsck option override will check the beacon file
".lowmem_repairable" in the same directory of the test image, and if the
beacon exists, then it will also run lowmem mode repair to repair the
image.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2017-10-16 20:33:00 +02:00

38 lines
893 B
Bash

#!/bin/bash
#
# additional arguments to various commands
# already defined, eg. via make argument
if [ -z "$TEST_ENABLE_OVERRIDE" ]; then
# set to 'true'
TEST_ENABLE_OVERRIDE=false
TEST_ARGS_CHECK=--mode=lowmem
fi
# gets arguments of a current command and can decide if the argument insertion
# should happen, eg. if some option combination does not make sense or would
# break tests
#
# Return 0 if we need to skip option override
# Return 1 if we don't need to skip option override
_skip_spec()
{
local beacon
beacon=.lowmem_repairable
# For lowmem repair, only support fs tree repair for now
# So we place lowmem repair beacon in the same dir of the test case
if echo "$TEST_ARGS_CHECK" | grep -q 'mode=lowmem' &&
echo "$@" | grep -q -- '--repair'; then
dir="$(dirname ${@: -1})"
if [ -f ${dir}/${beacon} ]; then
return 1;
fi
return 0;
fi
return 1
}