diff mbox series

loop: Add regression test for unsupported backing file fallocate

Message ID 20240613164007.22721-1-metan@ucw.cz (mailing list archive)
State New, archived
Headers show
Series loop: Add regression test for unsupported backing file fallocate | expand

Commit Message

Cyril Hrubis June 13, 2024, 4:40 p.m. UTC
From: Cyril Hrubis <chrubis@suse.cz>

Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
---
 tests/loop/011     | 37 +++++++++++++++++++++++++++++++++++++
 tests/loop/011.out |  3 +++
 2 files changed, 40 insertions(+)
 create mode 100755 tests/loop/011
 create mode 100644 tests/loop/011.out

Comments

Chaitanya Kulkarni June 14, 2024, 11:29 p.m. UTC | #1
On 6/13/24 09:40, Cyril Hrubis wrote:
> From: Cyril Hrubis <chrubis@suse.cz>
>
> Signed-off-by: Cyril Hrubis <chrubis@suse.cz>

thanks for the test, little detail about the issue in the commit
log is always helpful in long run ...

[...]

> +test() {
> +	local loop_dev;
> +	echo "Running ${TEST_NAME}"
> +
> +	mkdir "$TMPDIR/tmpfs"
> +	mount -t tmpfs testfs "$TMPDIR/tmpfs"
> +	dd if=/dev/zero of="$TMPDIR/tmpfs/disk.img" bs=1M count=100 &> /dev/null
> +
> +	if ! loop_dev="$(losetup -f --show "$TMPDIR/tmpfs/disk.img")"; then
> +		return 1
> +	fi
> +
> +	mkfs.ext2 /dev/loop0 &> /dev/null
> +
> +	errors=$(_dmesg_since_test_start |grep "operation not supported error, dev" |wc -l)

nit:- can we use grep -c by any chance instead of wc -l ?

errors=$(_dmesg_since_test_start | grep -c "operation not supported 
error, dev")

if not please ignore this comment ...

> +
> +	losetup -d "$loop_dev"
> +	umount "$TMPDIR/tmpfs"
> +
> +	echo "Found $errors error(s) in dmesg"
> +
> +	echo "Test complete"
> +}
>

we are looking for REQ_OP_WRITE_ZEORES failure i.e. string 
"WRITE_ZEROES" on the
loop device "loop0" that will come from :

blk_complete_reqs()
  blk_mq_end_request()
   blk_update_request()
    blk_print_req_error()
     blk_op_str() <---

else we might take random errors into consideration that are not related to
write-zeroes and loop0 ?

other than this it looks good to me ...

-ck
diff mbox series

Patch

diff --git a/tests/loop/011 b/tests/loop/011
new file mode 100755
index 0000000..6a3dac7
--- /dev/null
+++ b/tests/loop/011
@@ -0,0 +1,37 @@ 
+#!/bin/bash
+# SPDX-License-Identifier: GPL-3.0+
+# Copyright (C) 2024 Cyril Hrubis
+#
+# Regression test for patch "loop: Disable fallocate() zero and discard if not supported".
+#
+
+. tests/loop/rc
+DESCRIPTION="Make sure unsupported backing file fallocate does not fill dmesg with errors"
+
+requires() {
+	_have_program mkfs.ext2
+}
+
+test() {
+	local loop_dev;
+	echo "Running ${TEST_NAME}"
+
+	mkdir "$TMPDIR/tmpfs"
+	mount -t tmpfs testfs "$TMPDIR/tmpfs"
+	dd if=/dev/zero of="$TMPDIR/tmpfs/disk.img" bs=1M count=100 &> /dev/null
+
+	if ! loop_dev="$(losetup -f --show "$TMPDIR/tmpfs/disk.img")"; then
+		return 1
+	fi
+
+	mkfs.ext2 /dev/loop0 &> /dev/null
+
+	errors=$(_dmesg_since_test_start |grep "operation not supported error, dev" |wc -l)
+
+	losetup -d "$loop_dev"
+	umount "$TMPDIR/tmpfs"
+
+	echo "Found $errors error(s) in dmesg"
+
+	echo "Test complete"
+}
diff --git a/tests/loop/011.out b/tests/loop/011.out
new file mode 100644
index 0000000..cd88fd5
--- /dev/null
+++ b/tests/loop/011.out
@@ -0,0 +1,3 @@ 
+Running loop/011
+Found 1 error(s) in dmesg
+Test complete