From 2c2db167c79bee6c0ce88f55f964135908654f74 Mon Sep 17 00:00:00 2001 From: Qu Wenruo Date: Wed, 1 Nov 2017 09:30:42 +0800 Subject: [PATCH] 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 [ switch to [ ] ] Signed-off-by: David Sterba --- tests/common | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/common b/tests/common index 3ce99090..734cd171 100644 --- a/tests/common +++ b/tests/common @@ -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"