]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test: add coverage for the nvme-subsystem
authorFrantisek Sumsal <frantisek@sumsal.cz>
Tue, 11 Oct 2022 07:54:35 +0000 (09:54 +0200)
committerLuca Boccassi <luca.boccassi@gmail.com>
Tue, 11 Oct 2022 11:38:30 +0000 (13:38 +0200)
Specifically for:
  - https://github.com/systemd/systemd/pull/24748
  - https://github.com/systemd/systemd/pull/24766
  - https://github.com/systemd/systemd/pull/24946

test/TEST-64-UDEV-STORAGE/test.sh
test/units/testsuite-64.sh

index f662d4dafb64c899d0348927b02b722b0e99aa01..f93b92e3c3d7d1838f584b94736a9ec6c1f8a1e7 100755 (executable)
@@ -205,6 +205,36 @@ testcase_nvme_basic() {
     test_run_one "${1:?}"
 }
 
+# Testcase for:
+#   * https://github.com/systemd/systemd/pull/24748
+#   * https://github.com/systemd/systemd/pull/24766
+#   * https://github.com/systemd/systemd/pull/24946
+# Docs: https://qemu.readthedocs.io/en/latest/system/devices/nvme.html#nvm-subsystems
+testcase_nvme_subsystem() {
+    if ! "${QEMU_BIN:?}" -device help | grep 'name "nvme-subsys"'; then
+        echo "nvme-subsystem device driver is not available, skipping test..."
+        return 77
+    fi
+
+    local i
+    local qemu_opts=(
+        # Create an NVM Subsystem Device
+        "-device nvme-subsys,id=nvme-subsys-64,nqn=subsys64"
+        # Attach two NVM controllers to it
+        "-device nvme,subsys=nvme-subsys-64,serial=deadbeef"
+        "-device nvme,subsys=nvme-subsys-64,serial=deadbeef"
+        # And create two shared namespaces attached to both controllers
+        "-device nvme-ns,drive=nvme0,nsid=16,shared=on"
+        "-drive format=raw,cache=unsafe,file=${TESTDIR:?}/disk0.img,if=none,id=nvme0"
+        "-device nvme-ns,drive=nvme1,nsid=17,shared=on"
+        "-drive format=raw,cache=unsafe,file=${TESTDIR:?}/disk1.img,if=none,id=nvme1"
+    )
+
+    KERNEL_APPEND="systemd.setenv=TEST_FUNCTION_NAME=${FUNCNAME[0]} ${USER_KERNEL_APPEND:-}"
+    QEMU_OPTIONS="${qemu_opts[*]} ${USER_QEMU_OPTIONS:-}"
+    test_run_one "${1:?}"
+}
+
 # Test for issue https://github.com/systemd/systemd/issues/20212
 testcase_virtio_scsi_identically_named_partitions() {
 
index df92a0bb43a3a4a5bb11b2a08a0f7f47020dbc87..7673036335044280a665fa20ad49a08b15ef7c06 100755 (executable)
@@ -177,6 +177,18 @@ testcase_nvme_basic() {
     [[ "$(lsblk --noheadings | grep -c "^nvme")" -ge 28 ]]
 }
 
+testcase_nvme_subsystem() {
+    local expected_symlinks=(
+        # Controller(s)
+        /dev/disk/by-id/nvme-QEMU_NVMe_Ctrl_deadbeef
+        # Shared namespaces
+        /dev/disk/by-path/pci-*-nvme-16
+        /dev/disk/by-path/pci-*-nvme-17
+    )
+
+    udevadm wait --settle --timeout=30 "${expected_symlinks[@]}"
+}
+
 testcase_virtio_scsi_identically_named_partitions() {
     local num