@@ -16,11 +16,9 @@ requires() {
test() {
echo "Running ${TEST_NAME}"
- local iterations=1000
-
- modprobe nvmet
- modprobe nvme-loop
+ _setup_nvmet
+ local iterations=1000
local port
port="$(_create_nvmet_port "loop")"
@@ -41,7 +39,5 @@ test() {
_remove_nvmet_port "${port}"
- modprobe -r nvme-loop
- modprobe -r nvmet
echo "Test complete"
}
@@ -17,8 +17,7 @@ requires() {
test() {
echo "Running ${TEST_NAME}"
- modprobe nvmet
- modprobe nvme-loop
+ _setup_nvmet
local port
port="$(_create_nvmet_port "loop")"
@@ -47,7 +46,5 @@ test() {
_remove_nvmet_subsystem "blktests-subsystem-1"
_remove_nvmet_port "${port}"
- modprobe -r nvme-loop
- modprobe -r nvmet
echo "Test complete"
}
@@ -18,8 +18,7 @@ requires() {
test() {
echo "Running ${TEST_NAME}"
- modprobe nvmet
- modprobe nvme-loop
+ _setup_nvmet
local port
port="$(_create_nvmet_port "loop")"
@@ -47,7 +46,5 @@ test() {
losetup -d "$loop_dev"
rm "$TMPDIR/img"
- modprobe -r nvme-loop
- modprobe -r nvmet
echo "Test complete"
}
@@ -19,8 +19,7 @@ requires() {
test() {
echo "Running ${TEST_NAME}"
- modprobe nvmet
- modprobe nvme-loop
+ _setup_nvmet
local port
port="$(_create_nvmet_port "loop")"
@@ -51,8 +50,5 @@ test() {
losetup -d "$loop_dev"
rm "$TMPDIR/img"
- modprobe -r nvme-loop
- modprobe -r nvmet
-
echo "Test complete"
}
@@ -21,8 +21,7 @@ test() {
local loop_dev
local subsys_name="blktests-subsystem-1"
- modprobe nvmet
- modprobe nvme-loop
+ _setup_nvmet
truncate -s 1G "$TMPDIR/img"
@@ -41,8 +40,5 @@ test() {
rm "$TMPDIR/img"
- modprobe -r nvme-loop
- modprobe -r nvmet
-
echo "Test complete"
}
@@ -20,8 +20,7 @@ test() {
local file_path
local subsys_name="blktests-subsystem-1"
- modprobe nvmet
- modprobe nvme-loop
+ _setup_nvmet
file_path="${TMPDIR}/img"
@@ -38,8 +37,5 @@ test() {
rm "${file_path}"
- modprobe -r nvme-loop
- modprobe -r nvmet
-
echo "Test complete"
}
@@ -17,8 +17,7 @@ requires() {
test() {
echo "Running ${TEST_NAME}"
- modprobe nvmet
- modprobe nvme-loop
+ _setup_nvmet
local port
local nvmedev
@@ -53,8 +52,5 @@ test() {
rm "${file_path}"
- modprobe -r nvme-loop
- modprobe -r nvmet
-
echo "Test complete"
}
@@ -16,8 +16,7 @@ requires() {
test() {
echo "Running ${TEST_NAME}"
- modprobe nvmet
- modprobe nvme-loop
+ _setup_nvmet
local port
local nvmedev
@@ -47,7 +46,5 @@ test() {
rm "${file_path}"
- modprobe -r nvme-loop
- modprobe -r nvmet
echo "Test complete"
}
@@ -17,8 +17,7 @@ requires() {
test() {
echo "Running ${TEST_NAME}"
- modprobe nvmet
- modprobe nvme-loop
+ _setup_nvmet
local port
local nvmedev
@@ -54,8 +53,5 @@ test() {
rm "${file_path}"
rm -f local*verify*state
- modprobe -r nvme_loop
- modprobe -r nvmet
-
echo "Test complete"
}
@@ -17,8 +17,7 @@ requires() {
test() {
echo "Running ${TEST_NAME}"
- modprobe nvmet
- modprobe nvme-loop
+ _setup_nvmet
local port
local nvmedev
@@ -50,8 +49,5 @@ test() {
rm "${file_path}"
rm -f local-write-and-verify*state
- modprobe -r nvme_loop
- modprobe -r nvmet
-
echo "Test complete"
}
@@ -17,8 +17,7 @@ requires() {
test() {
echo "Running ${TEST_NAME}"
- modprobe nvmet
- modprobe nvme-loop
+ _setup_nvmet
local port
local nvmedev
@@ -66,8 +65,5 @@ test() {
rm "${file_path}"
rm -fr "${mount_dir}"
- modprobe -r nvme_loop
- modprobe -r nvmet
-
echo "Test complete"
}
@@ -17,8 +17,7 @@ requires() {
test() {
echo "Running ${TEST_NAME}"
- modprobe nvmet
- modprobe nvme-loop
+ _setup_nvmet
local port
local nvmedev
@@ -62,8 +61,5 @@ test() {
rm "${file_path}"
rm -fr "${mount_dir}"
- modprobe -r nvme_loop
- modprobe -r nvmet
-
echo "Test complete"
}
@@ -17,8 +17,7 @@ requires() {
test() {
echo "Running ${TEST_NAME}"
- modprobe nvmet
- modprobe nvme-loop
+ _setup_nvmet
local port
local nvmedev
@@ -55,8 +54,5 @@ test() {
rm "${file_path}"
- modprobe -r nvme-loop
- modprobe -r nvmet
-
echo "Test complete"
}
@@ -16,8 +16,7 @@ requires() {
test() {
echo "Running ${TEST_NAME}"
- modprobe nvmet
- modprobe nvme-loop
+ _setup_nvmet
local port
local nvmedev
@@ -20,8 +20,7 @@ test() {
local loop_dev
local subsys_nqn="blktests-subsystem-1"
- modprobe nvmet
- modprobe nvme-loop
+ _setup_nvmet
loop_dev="$(losetup -f)"
@@ -44,6 +43,5 @@ test() {
_remove_nvmet_subsystem "${subsys_nqn}"
- modprobe -r nvme-loop nvmet
echo "Test complete"
}
@@ -20,8 +20,7 @@ test() {
local iterations=1000
local subsys_name="blktests-subsystem-1"
- modprobe nvmet
- modprobe nvme-loop
+ _setup_nvmet
file_path="${TMPDIR}/img"
@@ -49,8 +48,5 @@ test() {
rm "${file_path}"
- modprobe -r nvme-loop
- modprobe -r nvmet
-
echo "Test complete"
}
@@ -18,8 +18,7 @@ requires() {
test() {
echo "Running ${TEST_NAME}"
- modprobe nvmet
- modprobe nvme-loop
+ _setup_nvmet
local port
local nvmedev
@@ -17,8 +17,7 @@ requires() {
test() {
echo "Running ${TEST_NAME}"
- modprobe nvmet
- modprobe nvme-loop
+ _setup_nvmet
local port
local nvmedev
@@ -55,8 +54,5 @@ test() {
rm -f "${file_path}"
- modprobe -r nvme-loop
- modprobe -r nvmet
-
echo "Test complete"
}
@@ -16,8 +16,7 @@ requires() {
test() {
echo "Running ${TEST_NAME}"
- modprobe nvmet
- modprobe nvme-loop
+ _setup_nvmet
local port
local nvmedev
@@ -49,7 +48,5 @@ test() {
rm -f "${file_path}"
- modprobe -r nvme-loop
- modprobe -r nvmet
echo "Test complete"
}
@@ -17,8 +17,7 @@ requires() {
test() {
echo "Running ${TEST_NAME}"
- modprobe nvmet
- modprobe nvme-loop
+ _setup_nvmet
local port
local nvmedev
@@ -50,8 +49,5 @@ test() {
rm -f "${file_path}"
- modprobe -r nvme-loop
- modprobe -r nvmet
-
echo "Test complete"
}
@@ -17,8 +17,7 @@ requires() {
test() {
echo "Running ${TEST_NAME}"
- modprobe nvmet
- modprobe nvme-loop
+ _setup_nvmet
local port
local nvmedev
@@ -50,8 +49,5 @@ test() {
rm -f "${file_path}"
- modprobe -r nvme-loop
- modprobe -r nvmet
-
echo "Test complete"
}
@@ -17,8 +17,7 @@ requires() {
test() {
echo "Running ${TEST_NAME}"
- modprobe nvmet
- modprobe nvme-loop
+ _setup_nvmet
local port
local nvmedev
@@ -55,8 +54,5 @@ test() {
rm -f "${file_path}"
- modprobe -r nvme-loop
- modprobe -r nvmet
-
echo "Test complete"
}
@@ -17,8 +17,7 @@ requires() {
test() {
echo "Running ${TEST_NAME}"
- modprobe nvmet
- modprobe nvme-loop
+ _setup_nvmet
local port
local nvmedev
@@ -49,8 +48,5 @@ test() {
rm -f "${file_path}"
- modprobe -r nvme-loop
- modprobe -r nvmet
-
echo "Test complete"
}
@@ -17,8 +17,7 @@ requires() {
test() {
echo "Running ${TEST_NAME}"
- modprobe nvmet
- modprobe nvme-loop
+ _setup_nvmet
local port
local nvmedev
@@ -50,8 +49,5 @@ test() {
rm -f "${file_path}"
- modprobe -r nvme-loop
- modprobe -r nvmet
-
echo "Test complete"
}
@@ -17,8 +17,7 @@ requires() {
test() {
echo "Running ${TEST_NAME}"
- modprobe nvmet
- modprobe nvme-loop
+ _setup_nvmet
local port
local nvmedev
@@ -50,8 +49,5 @@ test() {
rm -f "${file_path}"
- modprobe -r nvme-loop
- modprobe -r nvmet
-
echo "Test complete"
}
@@ -17,8 +17,7 @@ requires() {
test() {
echo "Running ${TEST_NAME}"
- modprobe nvmet
- modprobe nvme-loop
+ _setup_nvmet
local port
local nvmedev
@@ -49,8 +48,5 @@ test() {
rm -f "${file_path}"
- modprobe -r nvme-loop
- modprobe -r nvmet
-
echo "Test complete"
}
@@ -17,8 +17,7 @@ requires() {
test() {
echo "Running ${TEST_NAME}"
- modprobe nvmet
- modprobe nvme-loop
+ _setup_nvmet
local port
local nvmedev
@@ -49,8 +48,5 @@ test() {
rm -f "${file_path}"
- modprobe -r nvme-loop
- modprobe -r nvmet
-
echo "Test complete"
}
@@ -50,8 +50,7 @@ test_user_io()
test() {
echo "Running ${TEST_NAME}"
- modprobe nvmet
- modprobe nvme-loop
+ _setup_nvmet
local port
local nvmedev
@@ -92,8 +91,5 @@ test() {
rm "${file_path}"
- modprobe -r nvme-loop
- modprobe -r nvmet
-
echo "Test complete"
}
@@ -36,8 +36,7 @@ test() {
echo "Running ${TEST_NAME}"
- modprobe nvmet
- modprobe nvme-loop
+ _setup_nvmet
port="$(_create_nvmet_port "loop")"
@@ -69,8 +68,5 @@ test() {
_remove_nvmet_port "${port}"
- modprobe -r nvme-loop
- modprobe -r nvmet
-
echo "Test complete"
}
@@ -24,6 +24,17 @@ _test_dev_is_nvme() {
return 0
}
+_cleanup_nvmet() {
+ modprobe -r nvme-loop
+ modprobe -r nvmet
+}
+
+_setup_nvmet() {
+ _register_test_cleanup _cleanup_nvmet
+ modprobe nvmet
+ modprobe nvme-loop
+}
+
_create_nvmet_port() {
local trtype="$1"
Move all the lines to modprobe nvmet and nvme-loop into _setup_nvmet() and _cleanup_nvmet() helper functions and call _cleanup_nvmet() using _register_test_cleanup() to ensure it's always called after the test terminates. This will allow us to improve the cleanup of these tests and not leave the system in an inconsistent state when tests are aborted. Signed-off-by: Logan Gunthorpe <logang@deltatee.com> --- tests/nvme/002 | 8 ++------ tests/nvme/003 | 5 +---- tests/nvme/004 | 5 +---- tests/nvme/005 | 6 +----- tests/nvme/006 | 6 +----- tests/nvme/007 | 6 +----- tests/nvme/008 | 6 +----- tests/nvme/009 | 5 +---- tests/nvme/010 | 6 +----- tests/nvme/011 | 6 +----- tests/nvme/012 | 6 +----- tests/nvme/013 | 6 +----- tests/nvme/014 | 6 +----- tests/nvme/015 | 3 +-- tests/nvme/016 | 4 +--- tests/nvme/017 | 6 +----- tests/nvme/018 | 3 +-- tests/nvme/019 | 6 +----- tests/nvme/020 | 5 +---- tests/nvme/021 | 6 +----- tests/nvme/022 | 6 +----- tests/nvme/023 | 6 +----- tests/nvme/024 | 6 +----- tests/nvme/025 | 6 +----- tests/nvme/026 | 6 +----- tests/nvme/027 | 6 +----- tests/nvme/028 | 6 +----- tests/nvme/029 | 6 +----- tests/nvme/030 | 6 +----- tests/nvme/rc | 11 +++++++++++ 30 files changed, 41 insertions(+), 134 deletions(-)