From: Sun Ke <sunke32@huawei.com>
To: <linux-block@vger.kernel.org>, <shinichiro.kawasaki@wdc.com>
Cc: <sunke32@huawei.com>, <hch@infradead.org>
Subject: [PATCH blktests v2] nbd: add a module load and device connect test
Date: Thu, 7 Jul 2022 11:56:10 +0800 [thread overview]
Message-ID: <20220707035610.3175550-1-sunke32@huawei.com> (raw)
This is a regression test for commit 06c4da89c24e
nbd: call genl_unregister_family() first in nbd_cleanup()
Two concurrent processes,one load and unlock nbd module
cyclically, the other one connect and disconnect nbd device cyclically.
Last for 10 seconds.
Signed-off-by: Sun Ke <sunke32@huawei.com>
---
v1->v2:
1.change install/uninstall to load/unlock
2.use _have_modules instead
tests/nbd/004 | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++
tests/nbd/004.out | 2 ++
tests/nbd/rc | 18 ++++++++++++++++++
3 files changed, 72 insertions(+)
create mode 100755 tests/nbd/004
create mode 100644 tests/nbd/004.out
diff --git a/tests/nbd/004 b/tests/nbd/004
new file mode 100755
index 0000000..6b2c5ff
--- /dev/null
+++ b/tests/nbd/004
@@ -0,0 +1,52 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-3.0+
+# Copyright (C) 2022 Sun Ke
+#
+# Regression test for commit 06c4da89c24e
+# nbd: call genl_unregister_family() first in nbd_cleanup()
+
+. tests/nbd/rc
+
+DESCRIPTION="module load/unlock concurrently with connect/disconnect"
+QUICK=1
+
+requires() {
+ _have_modules
+}
+
+module_load_and_unlock() {
+ while true; do
+ modprobe nbd >/dev/null 2>&1
+ modprobe -r nbd >/dev/null 2>&1
+ done
+}
+
+connect_and_disconnect() {
+ while true; do
+ _netlink_connect >/dev/null 2>&1
+ _netlink_disconnect >/dev/null 2>&1
+ done
+}
+
+test() {
+ echo "Running ${TEST_NAME}"
+
+ _start_nbd_server_netlink
+
+ module_load_and_unlock &
+ pid1=$!
+ connect_and_disconnect &
+ pid2=$!
+
+ sleep 10
+ {
+ kill -9 $pid1
+ wait $pid1
+ kill -9 $pid2
+ wait $pid2
+ } 2>/dev/null
+
+ _stop_nbd_server_netlink
+ echo "Test complete"
+}
+
diff --git a/tests/nbd/004.out b/tests/nbd/004.out
new file mode 100644
index 0000000..05ced0c
--- /dev/null
+++ b/tests/nbd/004.out
@@ -0,0 +1,2 @@
+Running nbd/004
+Test complete
diff --git a/tests/nbd/rc b/tests/nbd/rc
index 118553c..b0e7d91 100644
--- a/tests/nbd/rc
+++ b/tests/nbd/rc
@@ -76,3 +76,21 @@ _stop_nbd_server() {
rm -f "${TMPDIR}/nbd.pid"
rm -f "${TMPDIR}/export"
}
+
+_start_nbd_server_netlink() {
+ truncate -s 10G "${TMPDIR}/export"
+ nbd-server 8000 "${TMPDIR}/export" >/dev/null 2>&1
+}
+
+_stop_nbd_server_netlink() {
+ killall -SIGTERM nbd-server
+ rm -f "${TMPDIR}/export"
+}
+
+_netlink_connect() {
+ nbd-client localhost 8000 /dev/nbd0 >> "$FULL" 2>&1
+}
+
+_netlink_disconnect() {
+ nbd-client -d /dev/nbd0 >> "$FULL" 2>&1
+}
--
2.13.6
next reply other threads:[~2022-07-07 3:43 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-07 3:56 Sun Ke [this message]
2022-07-07 12:49 ` [PATCH blktests v2] nbd: add a module load and device connect test Shinichiro Kawasaki
2022-07-19 6:22 ` Sun Ke
2022-07-19 6:47 ` Sun Ke
2022-07-22 0:43 ` Shinichiro Kawasaki
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=20220707035610.3175550-1-sunke32@huawei.com \
--to=sunke32@huawei.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