public inbox for linux-block@vger.kernel.org
 help / color / mirror / Atom feed
From: Cyril Hrubis <chrubis@suse.cz>
To: linux-block@vger.kernel.org
Cc: Christoph Hellwig <hch@infradead.org>,
	Chaitanya Kulkarni <chaitanyak@nvidia.com>,
	Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>,
	Cyril Hrubis <chrubis@suse.cz>
Subject: [PATCH v2] loop: Add regression test for unsupported backing file fallocate
Date: Mon, 17 Jun 2024 14:00:18 +0200	[thread overview]
Message-ID: <20240617120018.13832-1-chrubis@suse.cz> (raw)

Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
---

v2:
  - make use of grep -c instead of wc -l
  - Add WRITE_ZEROES string to the grep regexp

 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

diff --git a/tests/loop/011 b/tests/loop/011
new file mode 100755
index 0000000..baabe5c
--- /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 -c "operation not supported error, dev .*WRITE_ZEROES")
+
+	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
-- 
2.44.2


             reply	other threads:[~2024-06-17 12:01 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-17 12:00 Cyril Hrubis [this message]
2024-06-18  0:48 ` [PATCH v2] loop: Add regression test for unsupported backing file fallocate Chaitanya Kulkarni
2024-06-20  7:35 ` Shinichiro Kawasaki
2024-06-21  9:09   ` Cyril Hrubis

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240617120018.13832-1-chrubis@suse.cz \
    --to=chrubis@suse.cz \
    --cc=chaitanyak@nvidia.com \
    --cc=hch@infradead.org \
    --cc=linux-block@vger.kernel.org \
    --cc=shinichiro.kawasaki@wdc.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox