nbdkit/0002-tests-test-nozero.sh-Create-test-file-as-single-exte.patch

54 lines
1.7 KiB
Diff
Raw Normal View History

From 89a36b1fab8302ddc370695d386a28a03a74eae7 Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Sat, 1 Aug 2020 08:46:53 +0100
Subject: [PATCH 2/4] tests/test-nozero.sh: Create test file as single extent,
add debugging.
Previously the test file was created by repeatedly appending, ie:
$ rm file; for f in {0..1023}; do printf '%1024s' . >> file; done ; stat -c "%b %B" file
3968 512
This seems to create files which have more than one extent. I have
changed it to the simpler form:
$ rm file; for f in {0..1023}; do printf '%1024s' .; done > file; stat -c "%b %B" file
2048 512
Also this commit adds debugging.
---
tests/test-nozero.sh | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/tests/test-nozero.sh b/tests/test-nozero.sh
index 9a815814..f1bb8a38 100755
--- a/tests/test-nozero.sh
+++ b/tests/test-nozero.sh
@@ -71,13 +71,21 @@ cleanup ()
}
cleanup_fn cleanup
-# Prep images, and check that zero with trim results in a sparse image.
-for f in {0..1023}; do printf '%1024s' . >> nozero1.img; done
+# Prep images.
+for f in {0..1023}; do printf '%1024s' . ; done > nozero1.img
cp nozero1.img nozero2.img
cp nozero1.img nozero3.img
cp nozero1.img nozero4.img
cp nozero1.img nozero5.img
cp nozero1.img nozero6.img
+
+# Debug number of blocks and block size in the images.
+for f in {1..6}; do
+ stat -c "%n: %b allocated blocks of size %B bytes, total size %s" \
+ nozero$f.img
+done
+
+# Check that zero with trim results in a sparse image.
requires nbdkit -U - --filter=log file logfile=nozero1.log nozero1.img \
--run 'nbdsh -u "$uri" -c "h.zero (1024*1024, 0)"'
if test "$(stat -c %b nozero1.img)" = "$(stat -c %b nozero2.img)"; then
--
2.27.0