Add mount and clear_sock test for nbd by netlink
PATCH 1/1 Add mount and clear_sock test for nbd by netlink
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 <[email protected]>
--- 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
tests/nbd/004 new file +30 -0
@@ -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 +}
tests/nbd/004.out new file +1 -0
@@ -0,0 +1 @@ +Running nbd/004
tests/nbd/rc +10 -0
@@ -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" +}
Signature · 1 line
2.13.6