summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2023-11-01 19:17:02 +0100
committerLennart Poettering <lennart@poettering.net>2023-11-02 14:19:32 +0100
commit565b7c90eb4ecf69758b6fb2cee41d9892dd77be (patch)
tree3430477b56c7c0e2b187a1c37c978df2e222452f
parentman: add docs for new storagetm service (diff)
downloadsystemd-565b7c90eb4ecf69758b6fb2cee41d9892dd77be.tar.xz
systemd-565b7c90eb4ecf69758b6fb2cee41d9892dd77be.zip
test: add integration test for systemd-storagetm
l---------test/TEST-84-STORAGETM/Makefile1
-rwxr-xr-xtest/TEST-84-STORAGETM/test.sh25
-rw-r--r--test/units/testsuite-84.service9
-rwxr-xr-xtest/units/testsuite-84.sh25
4 files changed, 60 insertions, 0 deletions
diff --git a/test/TEST-84-STORAGETM/Makefile b/test/TEST-84-STORAGETM/Makefile
new file mode 120000
index 0000000000..e9f93b1104
--- /dev/null
+++ b/test/TEST-84-STORAGETM/Makefile
@@ -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
index 0000000000..8a9730c957
--- /dev/null
+++ b/test/TEST-84-STORAGETM/test.sh
@@ -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
index 0000000000..2c2577019c
--- /dev/null
+++ b/test/units/testsuite-84.service
@@ -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
index 0000000000..954dce2d04
--- /dev/null
+++ b/test/units/testsuite-84.sh
@@ -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