diff options
author | Zhao Lei <zhaolei@cn.fujitsu.com> | 2015-07-27 20:24:31 +0800 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2015-08-31 19:25:11 +0200 |
commit | bafc3a33f5527f3cdd4f27be17687703256d0914 (patch) | |
tree | 01af11e70d0fa4d3571316168ee236869147c2bd /tests/common | |
parent | cb3424cd23c4c682063d1aa89347fec0736d9c4d (diff) |
btrfs-progs: tests: Move code to create loop device to common
This code block is used several tests, move it to ./common and add a
helper.
Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'tests/common')
-rw-r--r-- | tests/common | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/common b/tests/common index 899ec7b1..2d337b0b 100644 --- a/tests/common +++ b/tests/common @@ -142,3 +142,19 @@ setup_root_helper() fi SUDO_HELPER=root_helper } + +prepare_test_dev() +{ + # num[K/M/G/T...] + local size="$1" + + [[ "$TEST_DEV" ]] && return + [[ "$size" ]] || size='1G' + + echo "\$TEST_DEV not given, use $TOP/test/test.img as fallback" >> \ + $RESULTS + TEST_DEV="$TOP/tests/test.img" + + truncate -s "$size" "$TEST_DEV" || _not_run "create file for loop device failed" +} + |