diff mbox

[v4,3/4] btrfs-progs: test/common: Enhance prepare_test_dev to reset device size

Message ID 20171101013043.19294-4-wqu@suse.com (mailing list archive)
State New, archived
Headers show

Commit Message

Qu Wenruo Nov. 1, 2017, 1:30 a.m. UTC
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>
---
 tests/common | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

Comments

David Sterba Nov. 27, 2017, 11:30 p.m. UTC | #1
On Wed, Nov 01, 2017 at 09:30:42AM +0800, Qu Wenruo wrote:
> 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>

Applied, thanks.
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/tests/common b/tests/common
index 977bade201a6..63750dbfeffe 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 [[ "$TEST_DEV" ]]; then
+		truncate -s "$size" "$TEST_DEV"
+		return;
+	fi
 
 	echo "\$TEST_DEV not given, use $TOP/test/test.img as fallback" >> \
 		"$RESULTS"