]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test/test-functions: use truncate instead of dd to create testbed image
authorDan Streetman <ddstreet@canonical.com>
Tue, 13 Aug 2019 12:05:06 +0000 (08:05 -0400)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Sun, 25 Aug 2019 06:37:51 +0000 (15:37 +0900)
This avoids unnecessary noise in the stderr logs which dd always produces,
such as:

0+0 records in
0+0 records out
0 bytes copied, 0.000155284 s, 0.0 kB/s

Using truncate should not result in any functional change; the image will
still be created as a sparse file of the size specified.

test/test-functions

index 62439e66fb00e77d2b91756e0c92b4bcc7945636..a8b527b5a6257eaeac6535b400f43f2744ffeecd 100644 (file)
@@ -543,7 +543,7 @@ create_empty_image() {
     fi
     rm -f "$TESTDIR/rootdisk.img"
     # Create the blank file to use as a root filesystem
-    dd if=/dev/null of="$TESTDIR/rootdisk.img" bs=1M seek="$_size"
+    truncate -s "${_size}M" "$TESTDIR/rootdisk.img"
     LOOPDEV=$(losetup --show -P -f $TESTDIR/rootdisk.img)
     [ -b "$LOOPDEV" ] || return 1
     echo "LOOPDEV=$LOOPDEV" >> $STATEFILE