[PATCH blktests] Add mount and clear_sock test for nbd by netlink

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This test case catches regressions fixed by commit 92b5c8f0063e4 "nbd:
replace kill_bdev() with __invalidate_device() again". The nbd device is
connected by netlink interface.

Signed-off-by: Sun Ke <sunke32@xxxxxxxxxx>
---
 tests/nbd/004     | 30 ++++++++++++++++++++++++++++++
 tests/nbd/004.out |  1 +
 tests/nbd/rc      | 10 ++++++++++
 3 files changed, 41 insertions(+)
 create mode 100644 tests/nbd/004
 create mode 100644 tests/nbd/004.out

diff --git a/tests/nbd/004 b/tests/nbd/004
new file mode 100644
index 0000000..324c903
--- /dev/null
+++ b/tests/nbd/004
@@ -0,0 +1,30 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-3.0+
+# Copyright (C) 2020 Sun Ke
+#
+# Regression test for commit 2b5c8f0063e4 ("nbd: replace kill_bdev() with
+# __invalidate_device() again").
+
+. tests/nbd/rc
+
+DESCRIPTION="connected by netlink, mount/unmount concurrently with NBD_CLEAR_SOCK"
+QUICK=1
+
+requires() {
+	_have_nbd && _have_src_program mount_clear_sock
+}
+
+test() {
+	echo "Running ${TEST_NAME}"
+
+	_start_nbd_server_netlink
+	nbd-client localhost 8000 /dev/nbd0 >> "$FULL" 2>&1
+	mkfs.ext4 /dev/nbd0 >> "$FULL" 2>&1
+
+	mkdir -p "${TMPDIR}/mnt"
+	src/mount_clear_sock /dev/nbd0 "${TMPDIR}/mnt" ext4 5000
+
+	nbd-client -d /dev/nbd0 >> "$FULL" 2>&1
+	rm -rf "${TMPDIR}/mnt"
+	_stop_nbd_server_netlink
+}
diff --git a/tests/nbd/004.out b/tests/nbd/004.out
new file mode 100644
index 0000000..01a875a
--- /dev/null
+++ b/tests/nbd/004.out
@@ -0,0 +1 @@
+Running nbd/004
diff --git a/tests/nbd/rc b/tests/nbd/rc
index 9d0e3d1..767043a 100644
--- a/tests/nbd/rc
+++ b/tests/nbd/rc
@@ -76,3 +76,13 @@ _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" >> "$FULL" 2>&1
+}
+
+_stop_nbd_server_netlink() {
+	pkill -SIGTERM -f 8000
+	rm -f "${TMPDIR}/export"
+}
-- 
2.13.6




[Index of Archives]     [Linux RAID]     [Linux SCSI]     [Linux ATA RAID]     [IDE]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Device Mapper]

  Powered by Linux