btrfs-progs: test/common: Enhance prepare_test_dev to reset device size

So prepare_test_dev() can be called several times in one test case, to
test different device sizes.

Signed-off-by: Qu Wenruo <wqu@suse.com>
[ switch to [ ] ]
Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
Qu Wenruo 2017-11-01 09:30:42 +08:00 committed by David Sterba
parent 2bf30fb3b1
commit 2c2db167c7
1 changed files with 5 additions and 1 deletions

View File

@ -441,8 +441,12 @@ prepare_test_dev()
# num[K/M/G/T...]
local size="$1"
[[ "$TEST_DEV" ]] && return
[[ "$size" ]] || size='2G'
# Still truncate it to new size
if [ -n "$TEST_DEV" ]; then
truncate -s "$size" "$TEST_DEV"
return;
fi
echo "\$TEST_DEV not given, use $TOP/test/test.img as fallback" >> \
"$RESULTS"