]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test: add integration test for systemd-storagetm
authorLennart Poettering <lennart@poettering.net>
Wed, 1 Nov 2023 18:17:02 +0000 (19:17 +0100)
committerLennart Poettering <lennart@poettering.net>
Thu, 2 Nov 2023 13:19:32 +0000 (14:19 +0100)
test/TEST-84-STORAGETM/Makefile [new symlink]
test/TEST-84-STORAGETM/test.sh [new file with mode: 0755]
test/units/testsuite-84.service [new file with mode: 0644]
test/units/testsuite-84.sh [new file with mode: 0755]

diff --git a/test/TEST-84-STORAGETM/Makefile b/test/TEST-84-STORAGETM/Makefile
new file mode 120000 (symlink)
index 0000000..e9f93b1
--- /dev/null
@@ -0,0 +1 @@
+../TEST-01-BASIC/Makefile
\ No newline at end of file
diff --git a/test/TEST-84-STORAGETM/test.sh b/test/TEST-84-STORAGETM/test.sh
new file mode 100755 (executable)
index 0000000..8a9730c
--- /dev/null
@@ -0,0 +1,25 @@
+#!/usr/bin/env bash
+# SPDX-License-Identifier: LGPL-2.1-or-later
+set -e
+
+TEST_DESCRIPTION="test storagetm"
+
+TEST_NO_NSPAWN=1
+
+# shellcheck source=test/test-functions
+. "${TEST_BASE_DIR:?}/test-functions"
+
+test_require_bin nvme
+
+modprobe -nv nvmet-tcp || exit 0
+
+test_append_files() {
+    inst_binary nvme
+
+    instmods "=nvme"
+    instmods configfs
+
+    generate_module_dependencies
+}
+
+do_test "$@"
diff --git a/test/units/testsuite-84.service b/test/units/testsuite-84.service
new file mode 100644 (file)
index 0000000..2c25770
--- /dev/null
@@ -0,0 +1,9 @@
+# SPDX-License-Identifier: LGPL-2.1-or-later
+[Unit]
+Description=TEST-84-STORAGETM
+After=multi-user.target
+
+[Service]
+ExecStartPre=rm -f /failed /testok
+ExecStart=/usr/lib/systemd/tests/testdata/units/%N.sh
+Type=oneshot
diff --git a/test/units/testsuite-84.sh b/test/units/testsuite-84.sh
new file mode 100755 (executable)
index 0000000..954dce2
--- /dev/null
@@ -0,0 +1,25 @@
+#!/usr/bin/env bash
+# SPDX-License-Identifier: LGPL-2.1-or-later
+set -eux
+set -o pipefail
+
+modprobe -v nvmet-tcp
+modprobe -v nvme-tcp
+
+systemctl start sys-kernel-config.mount
+
+dd if=/dev/urandom of=/var/tmp/storagetm.test bs=1024 count=10240
+
+systemd-run -u teststoragetm.service -p Type=notify /usr/lib/systemd/systemd-storagetm /var/tmp/storagetm.test --nqn=quux
+
+nvme connect-all -t tcp -a 127.0.0.1 -s 16858 --hostid="$(cat /proc/sys/kernel/random/uuid)"
+
+dd if=/dev/nvme1n1 bs=1024 | cmp /var/tmp/storagetm.test -
+
+nvme disconnect --device=nvme1
+
+systemctl stop teststoragetm.service
+
+rm /var/tmp/storagetm.test
+
+touch /testok