* [PATCH blktests] nbd: add a module install and device connect test
@ 2022-07-06 7:02 Sun Ke
2022-07-06 8:08 ` Christoph Hellwig
0 siblings, 1 reply; 3+ messages in thread
From: Sun Ke @ 2022-07-06 7:02 UTC (permalink / raw)
To: linux-block, shinichiro.kawasaki; +Cc: sunke32
This is a regression test for commit 06c4da89c24e
nbd: call genl_unregister_family() first in nbd_cleanup()
Two concurrent processes,one install and uninstall nbd module
cyclically, the other one connect and disconnect nbd device cyclically.
Last for 10 seconds.
Signed-off-by: Sun Ke <sunke32@huawei.com>
---
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..8c23425
--- /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 install/uninstall concurrently with connect/disconnect"
+QUICK=1
+
+requires() {
+ _have_nbd
+}
+
+module_install_and_remove() {
+ 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_install_and_remove &
+ 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
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH blktests] nbd: add a module install and device connect test
2022-07-06 7:02 [PATCH blktests] nbd: add a module install and device connect test Sun Ke
@ 2022-07-06 8:08 ` Christoph Hellwig
2022-07-07 3:34 ` Sun Ke
0 siblings, 1 reply; 3+ messages in thread
From: Christoph Hellwig @ 2022-07-06 8:08 UTC (permalink / raw)
To: Sun Ke; +Cc: linux-block, shinichiro.kawasaki
On Wed, Jul 06, 2022 at 03:02:09PM +0800, Sun Ke wrote:
> This is a regression test for commit 06c4da89c24e
> nbd: call genl_unregister_family() first in nbd_cleanup()
>
> Two concurrent processes,one install and uninstall nbd module
> cyclically, the other one connect and disconnect nbd device cyclically.
> Last for 10 seconds.
I think you mean load/unlock instead of install.
> +requires() {
> + _have_nbd
> +}
This needs to use _have_modules instead.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH blktests] nbd: add a module install and device connect test
2022-07-06 8:08 ` Christoph Hellwig
@ 2022-07-07 3:34 ` Sun Ke
0 siblings, 0 replies; 3+ messages in thread
From: Sun Ke @ 2022-07-07 3:34 UTC (permalink / raw)
To: Christoph Hellwig; +Cc: linux-block, shinichiro.kawasaki
在 2022/7/6 16:08, Christoph Hellwig 写道:
> On Wed, Jul 06, 2022 at 03:02:09PM +0800, Sun Ke wrote:
>> This is a regression test for commit 06c4da89c24e
>> nbd: call genl_unregister_family() first in nbd_cleanup()
>>
>> Two concurrent processes,one install and uninstall nbd module
>> cyclically, the other one connect and disconnect nbd device cyclically.
>> Last for 10 seconds.
>
> I think you mean load/unlock instead of install.
Thanks for your suggestion, I do not sure how to descibe it. I will fix
it in both function name and commit info.
>
>> +requires() {
>> + _have_nbd
>> +}
>
> This needs to use _have_modules instead.
ok
Thanks,
Sun Ke
> .
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-07-07 3:34 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-07-06 7:02 [PATCH blktests] nbd: add a module install and device connect test Sun Ke
2022-07-06 8:08 ` Christoph Hellwig
2022-07-07 3:34 ` Sun Ke
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).