diff mbox series

[blktests,2/6] nbd/rc: load nbd module explicitly

Message ID 20220727085251.1474340-3-shinichiro.kawasaki@wdc.com (mailing list archive)
State New, archived
Headers show
Series fix module check issues | expand

Commit Message

Shin'ichiro Kawasaki July 27, 2022, 8:52 a.m. UTC
After the commit "common/rc: avoid module load in _have_driver()",
_have_driver() no longer loads specified module. However, nbd test cases
and _have_nbd_netlink() function assume that the module is loaded by
calling _have_driver(). This causes test case failures and unexpected
skips. To fix them, load and unload modules explicitly in functions
_start_nbd_server*(), _stop_nbd_server*() and _have_nbd_netlink().

Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
---
 tests/nbd/rc | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

Comments

Christoph Hellwig July 28, 2022, 2:46 p.m. UTC | #1
On Wed, Jul 27, 2022 at 05:52:47PM +0900, Shin'ichiro Kawasaki wrote:
> After the commit "common/rc: avoid module load in _have_driver()",
> _have_driver() no longer loads specified module. However, nbd test cases
> and _have_nbd_netlink() function assume that the module is loaded by
> calling _have_driver(). This causes test case failures and unexpected
> skips. To fix them, load and unload modules explicitly in functions
> _start_nbd_server*(), _stop_nbd_server*() and _have_nbd_netlink().

Did you test this with built-in nbd?
Shin'ichiro Kawasaki July 29, 2022, 12:12 a.m. UTC | #2
On Jul 28, 2022 / 16:46, Christoph Hellwig wrote:
> On Wed, Jul 27, 2022 at 05:52:47PM +0900, Shin'ichiro Kawasaki wrote:
> > After the commit "common/rc: avoid module load in _have_driver()",
> > _have_driver() no longer loads specified module. However, nbd test cases
> > and _have_nbd_netlink() function assume that the module is loaded by
> > calling _have_driver(). This causes test case failures and unexpected
> > skips. To fix them, load and unload modules explicitly in functions
> > _start_nbd_server*(), _stop_nbd_server*() and _have_nbd_netlink().
> 
> Did you test this with built-in nbd? 

Yes. I confirmed all test cases in nbd test group pass with built-in nbd.
The modprobe command with -q option does nothing for built-in drivers.

When I confirmed that, I found even nbd/004 passes, which should be skipped.
Next patch addresses this issue.
diff mbox series

Patch

diff --git a/tests/nbd/rc b/tests/nbd/rc
index 9c1c15b..32eea45 100644
--- a/tests/nbd/rc
+++ b/tests/nbd/rc
@@ -28,17 +28,21 @@  _have_nbd() {
 }
 
 _have_nbd_netlink() {
+	local ret=0
+
 	if ! _have_nbd; then
 		return 1
 	fi
 	if ! _have_program genl-ctrl-list; then
 		return 1
 	fi
+	modprobe -q nbd
 	if ! genl-ctrl-list | grep -q nbd; then
 		SKIP_REASONS+=("nbd does not support netlink")
-		return 1
+		ret=1
 	fi
-	return 0
+	modprobe -qr nbd
+	return $ret
 }
 
 _wait_for_nbd_connect() {
@@ -62,6 +66,7 @@  _wait_for_nbd_disconnect() {
 }
 
 _start_nbd_server() {
+	modprobe -q nbd
 	truncate -s 10G "${TMPDIR}/export"
 	cat > "${TMPDIR}/nbd.conf" << EOF
 [generic]
@@ -73,17 +78,20 @@  EOF
 
 _stop_nbd_server() {
 	kill -SIGTERM "$(cat "${TMPDIR}/nbd.pid")"
+	modprobe -qr nbd
 	rm -f "${TMPDIR}/nbd.pid"
 	rm -f "${TMPDIR}/export"
 }
 
 _start_nbd_server_netlink() {
+	modprobe -q nbd
 	truncate -s 10G "${TMPDIR}/export"
 	nbd-server 8000 "${TMPDIR}/export" >/dev/null 2>&1
 }
 
 _stop_nbd_server_netlink() {
 	killall -SIGTERM nbd-server
+	modprobe -qr nbd
 	rm -f "${TMPDIR}/export"
 }