From: Lennart Poettering Date: Wed, 1 Nov 2023 18:17:02 +0000 (+0100) Subject: test: add integration test for systemd-storagetm X-Git-Tag: v255-rc1~43^2~2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=565b7c90eb4ecf69758b6fb2cee41d9892dd77be;p=thirdparty%2Fsystemd.git test: add integration test for systemd-storagetm --- diff --git a/test/TEST-84-STORAGETM/Makefile b/test/TEST-84-STORAGETM/Makefile new file mode 120000 index 00000000000..e9f93b1104c --- /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 00000000000..8a9730c9575 --- /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 00000000000..2c2577019c3 --- /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 00000000000..954dce2d046 --- /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