btrfs-progs: tests: truncate test image to 0 first
authorDavid Sterba <dsterba@suse.com>
Tue, 23 Jan 2018 16:22:30 +0000 (17:22 +0100)
committerDavid Sterba <dsterba@suse.com>
Wed, 31 Jan 2018 14:14:02 +0000 (15:14 +0100)
We use the prepare_test_dev helper to make sure the image has at least
this size. The "at least" part is not desired by some tests as the
device might be larger than the test expects.

Signed-off-by: David Sterba <dsterba@suse.com>
tests/common

index a2e2f50..2fac202 100644 (file)
@@ -444,6 +444,7 @@ prepare_test_dev()
        [[ "$size" ]] || size='2G'
        # Still truncate it to new size
        if [ -n "$TEST_DEV" ]; then
+               truncate -s 0 "$TEST_DEV"
                truncate -s "$size" "$TEST_DEV"
                return;
        fi
@@ -452,6 +453,7 @@ prepare_test_dev()
                "$RESULTS"
        TEST_DEV="$TOP/tests/test.img"
 
+       truncate -s 0 "$TEST_DEV"
        truncate -s "$size" "$TEST_DEV" || _not_run "create file for loop device failed"
 }