From 51fa85913c4d1826414c6fa5a2e235f65425d91a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Tue, 8 Oct 2019 09:10:12 +0200 Subject: test: add function to reduce copied setup boilerplate Many tests were also masking systemd-machined.service. But machined should only start when activated, so having it not masked shouldn't be noticable. TEST-25-IMPORT needs it. --- test/TEST-02-CRYPTSETUP/test.sh | 9 +-------- test/TEST-03-JOBS/test.sh | 9 +-------- test/TEST-04-JOURNAL/test.sh | 9 +-------- test/TEST-05-RLIMITS/test.sh | 9 +-------- test/TEST-06-SELINUX/test.sh | 8 +------- test/TEST-07-ISSUE-1981/test.sh | 9 +-------- test/TEST-08-ISSUE-2730/test.sh | 7 +------ test/TEST-09-ISSUE-2691/test.sh | 8 +------- test/TEST-10-ISSUE-2467/test.sh | 8 +------- test/TEST-11-ISSUE-3166/test.sh | 9 +-------- test/TEST-12-ISSUE-3171/test.sh | 9 +-------- test/TEST-13-NSPAWN-SMOKE/test.sh | 9 +-------- test/TEST-14-MACHINE-ID/test.sh | 8 +------- test/TEST-15-DROPIN/test.sh | 8 +------- test/TEST-16-EXTEND-TIMEOUT/test.sh | 7 +------ test/TEST-17-UDEV-WANTS/test.sh | 8 +------- test/TEST-18-FAILUREACTION/test.sh | 9 ++------- test/TEST-19-DELEGATE/test.sh | 9 +-------- test/TEST-20-MAINPIDGAMES/test.sh | 10 ++-------- test/TEST-22-TMPFILES/test.sh | 9 +-------- test/TEST-23-TYPE-EXEC/test.sh | 9 +-------- test/TEST-27-STDOUTFILE/test.sh | 12 ++---------- test/TEST-28-PERCENTJ-WANTEDBY/test.sh | 9 ++------- test/TEST-29-UDEV-ID_RENAMING/test.sh | 8 +------- test/TEST-30-ONCLOCKCHANGE/test.sh | 9 +-------- test/TEST-31-DEVICE-ENUMERATION/test.sh | 8 +------- test/TEST-32-OOMPOLICY/test.sh | 9 +-------- test/TEST-33-CLEAN-UNIT/test.sh | 9 +-------- test/TEST-34-DYNAMICUSERMIGRATE/test.sh | 9 +-------- test/TEST-36-NUMAPOLICY/test.sh | 9 +-------- test/TEST-37-RUNTIMEDIRECTORYPRESERVE/test.sh | 9 +-------- test/TEST-39-EXECRELOAD/test.sh | 9 +-------- test/TEST-40-EXEC-COMMAND-EX/test.sh | 9 +-------- test/test-functions | 9 +++++++++ 34 files changed, 46 insertions(+), 252 deletions(-) diff --git a/test/TEST-02-CRYPTSETUP/test.sh b/test/TEST-02-CRYPTSETUP/test.sh index 801dc71569..a7563f4462 100755 --- a/test/TEST-02-CRYPTSETUP/test.sh +++ b/test/TEST-02-CRYPTSETUP/test.sh @@ -40,14 +40,7 @@ test_setup() { eval $(udevadm info --export --query=env --name=${LOOPDEV}p2) setup_basic_environment - - # mask some services that we do not want to run in these tests - ln -fs /dev/null $initdir/etc/systemd/system/systemd-hwdb-update.service - ln -fs /dev/null $initdir/etc/systemd/system/systemd-journal-catalog-update.service - ln -fs /dev/null $initdir/etc/systemd/system/systemd-networkd.service - ln -fs /dev/null $initdir/etc/systemd/system/systemd-networkd.socket - ln -fs /dev/null $initdir/etc/systemd/system/systemd-resolved.service - ln -fs /dev/null $initdir/etc/systemd/system/systemd-machined.service + mask_supporting_services # setup the testsuite service cat >$initdir/etc/systemd/system/testsuite.service <$initdir/etc/systemd/system/testsuite.service <$initdir/etc/systemd/system/testsuite.service <$initdir/etc/systemd/system.conf <$initdir/etc/systemd/system/testsuite.service @@ -91,13 +92,6 @@ EOF dracut_install runcon dracut_install checkmodule semodule semodule_package m4 make /usr/libexec/selinux/hll/pp load_policy sefcontext_compile ) - - # mask some services that we do not want to run in these tests - ln -fs /dev/null $initdir/etc/systemd/system/systemd-hwdb-update.service - ln -fs /dev/null $initdir/etc/systemd/system/systemd-journal-catalog-update.service - ln -fs /dev/null $initdir/etc/systemd/system/systemd-networkd.service - ln -fs /dev/null $initdir/etc/systemd/system/systemd-networkd.socket - ln -fs /dev/null $initdir/etc/systemd/system/systemd-resolved.service } do_test "$@" diff --git a/test/TEST-07-ISSUE-1981/test.sh b/test/TEST-07-ISSUE-1981/test.sh index 2e4f67c5fe..199b4f85a8 100755 --- a/test/TEST-07-ISSUE-1981/test.sh +++ b/test/TEST-07-ISSUE-1981/test.sh @@ -16,14 +16,7 @@ test_setup() { eval $(udevadm info --export --query=env --name=${LOOPDEV}p2) setup_basic_environment - - # mask some services that we do not want to run in these tests - ln -fs /dev/null $initdir/etc/systemd/system/systemd-hwdb-update.service - ln -fs /dev/null $initdir/etc/systemd/system/systemd-journal-catalog-update.service - ln -fs /dev/null $initdir/etc/systemd/system/systemd-networkd.service - ln -fs /dev/null $initdir/etc/systemd/system/systemd-networkd.socket - ln -fs /dev/null $initdir/etc/systemd/system/systemd-resolved.service - ln -fs /dev/null $initdir/etc/systemd/system/systemd-machined.service + mask_supporting_services # setup the testsuite service cat >$initdir/etc/systemd/system/testsuite.service <$initdir/etc/systemd/system/testsuite.service <<'EOF' @@ -31,13 +32,6 @@ EOF setup_testsuite ) - - # mask some services that we do not want to run in these tests - ln -fs /dev/null $initdir/etc/systemd/system/systemd-hwdb-update.service - ln -fs /dev/null $initdir/etc/systemd/system/systemd-journal-catalog-update.service - ln -fs /dev/null $initdir/etc/systemd/system/systemd-networkd.service - ln -fs /dev/null $initdir/etc/systemd/system/systemd-networkd.socket - ln -fs /dev/null $initdir/etc/systemd/system/systemd-resolved.service } do_test "$@" diff --git a/test/TEST-10-ISSUE-2467/test.sh b/test/TEST-10-ISSUE-2467/test.sh index 80b2fd923f..7bb2569630 100755 --- a/test/TEST-10-ISSUE-2467/test.sh +++ b/test/TEST-10-ISSUE-2467/test.sh @@ -13,6 +13,7 @@ test_setup() { eval $(udevadm info --export --query=env --name=${LOOPDEV}p2) setup_basic_environment + mask_supporting_services dracut_install true rm socat # setup the testsuite service @@ -42,13 +43,6 @@ EOF setup_testsuite ) setup_nspawn_root - - # mask some services that we do not want to run in these tests - ln -fs /dev/null $initdir/etc/systemd/system/systemd-hwdb-update.service - ln -fs /dev/null $initdir/etc/systemd/system/systemd-journal-catalog-update.service - ln -fs /dev/null $initdir/etc/systemd/system/systemd-networkd.service - ln -fs /dev/null $initdir/etc/systemd/system/systemd-networkd.socket - ln -fs /dev/null $initdir/etc/systemd/system/systemd-resolved.service } do_test "$@" diff --git a/test/TEST-11-ISSUE-3166/test.sh b/test/TEST-11-ISSUE-3166/test.sh index c50efb8c9b..81c12a2783 100755 --- a/test/TEST-11-ISSUE-3166/test.sh +++ b/test/TEST-11-ISSUE-3166/test.sh @@ -14,16 +14,9 @@ test_setup() { eval $(udevadm info --export --query=env --name=${LOOPDEV}p2) setup_basic_environment + mask_supporting_services dracut_install false touch - # mask some services that we do not want to run in these tests - ln -fs /dev/null $initdir/etc/systemd/system/systemd-hwdb-update.service - ln -fs /dev/null $initdir/etc/systemd/system/systemd-journal-catalog-update.service - ln -fs /dev/null $initdir/etc/systemd/system/systemd-networkd.service - ln -fs /dev/null $initdir/etc/systemd/system/systemd-networkd.socket - ln -fs /dev/null $initdir/etc/systemd/system/systemd-resolved.service - ln -fs /dev/null $initdir/etc/systemd/system/systemd-machined.service - # setup the testsuite service cat >$initdir/etc/systemd/system/testsuite.service <$initdir/etc/systemd/system/testsuite.service <$initdir/etc/machine-id dracut_install mount cmp @@ -72,13 +73,6 @@ chmod +x $initdir/test-machine-id-setup.sh setup_testsuite ) - - # mask some services that we do not want to run in these tests - ln -fs /dev/null $initdir/etc/systemd/system/systemd-hwdb-update.service - ln -fs /dev/null $initdir/etc/systemd/system/systemd-journal-catalog-update.service - ln -fs /dev/null $initdir/etc/systemd/system/systemd-networkd.service - ln -fs /dev/null $initdir/etc/systemd/system/systemd-networkd.socket - ln -fs /dev/null $initdir/etc/systemd/system/systemd-resolved.service } do_test "$@" diff --git a/test/TEST-15-DROPIN/test.sh b/test/TEST-15-DROPIN/test.sh index 9d5ea138b9..a1d0c618d9 100755 --- a/test/TEST-15-DROPIN/test.sh +++ b/test/TEST-15-DROPIN/test.sh @@ -8,13 +8,7 @@ TEST_NO_QEMU=1 test_setup() { # create the basic filesystem layout setup_basic_environment - - # mask some services that we do not want to run in these tests - ln -fs /dev/null $initdir/etc/systemd/system/systemd-hwdb-update.service - ln -fs /dev/null $initdir/etc/systemd/system/systemd-journal-catalog-update.service - ln -fs /dev/null $initdir/etc/systemd/system/systemd-networkd.service - ln -fs /dev/null $initdir/etc/systemd/system/systemd-networkd.socket - ln -fs /dev/null $initdir/etc/systemd/system/systemd-resolved.service + mask_supporting_services # import the test scripts in the rootfs and plug them in systemd cp testsuite.service $initdir/etc/systemd/system/ diff --git a/test/TEST-16-EXTEND-TIMEOUT/test.sh b/test/TEST-16-EXTEND-TIMEOUT/test.sh index 368c9e63ca..c5f8af6ec6 100755 --- a/test/TEST-16-EXTEND-TIMEOUT/test.sh +++ b/test/TEST-16-EXTEND-TIMEOUT/test.sh @@ -14,6 +14,7 @@ test_setup() { eval $(udevadm info --export --query=env --name=${LOOPDEV}p2) setup_basic_environment + mask_supporting_services for s in success-all success-start success-stop success-runtime \ fail-start fail-stop fail-runtime @@ -27,12 +28,6 @@ test_setup() { setup_testsuite ) - # mask some services that we do not want to run in these tests - ln -fs /dev/null $initdir/etc/systemd/system/systemd-hwdb-update.service - ln -fs /dev/null $initdir/etc/systemd/system/systemd-journal-catalog-update.service - ln -fs /dev/null $initdir/etc/systemd/system/systemd-networkd.service - ln -fs /dev/null $initdir/etc/systemd/system/systemd-networkd.socket - ln -fs /dev/null $initdir/etc/systemd/system/systemd-resolved.service setup_nspawn_root } diff --git a/test/TEST-17-UDEV-WANTS/test.sh b/test/TEST-17-UDEV-WANTS/test.sh index 36032348b8..1cdbbd2d8a 100755 --- a/test/TEST-17-UDEV-WANTS/test.sh +++ b/test/TEST-17-UDEV-WANTS/test.sh @@ -14,13 +14,7 @@ test_setup() { eval $(udevadm info --export --query=env --name=${LOOPDEV}p2) setup_basic_environment - - # mask some services that we do not want to run in these tests - ln -fs /dev/null $initdir/etc/systemd/system/systemd-hwdb-update.service - ln -fs /dev/null $initdir/etc/systemd/system/systemd-journal-catalog-update.service - ln -fs /dev/null $initdir/etc/systemd/system/systemd-networkd.service - ln -fs /dev/null $initdir/etc/systemd/system/systemd-networkd.socket - ln -fs /dev/null $initdir/etc/systemd/system/systemd-resolved.service + mask_supporting_services # setup the testsuite service cat >$initdir/etc/systemd/system/testsuite.service <$initdir/etc/systemd/system/testsuite.service <$initdir/etc/systemd/system/testsuite.service <$initdir/etc/systemd/system/testsuite.service <$initdir/etc/systemd/system/testsuite.service <$initdir/etc/systemd/system/testsuite.service <$initdir/etc/systemd/system/specifier-j-wants.service << EOF @@ -48,14 +49,8 @@ EOF setup_testsuite ) - setup_nspawn_root - # mask some services that we do not want to run in these tests - ln -fs /dev/null $initdir/etc/systemd/system/systemd-hwdb-update.service - ln -fs /dev/null $initdir/etc/systemd/system/systemd-journal-catalog-update.service - ln -fs /dev/null $initdir/etc/systemd/system/systemd-networkd.service - ln -fs /dev/null $initdir/etc/systemd/system/systemd-networkd.socket - ln -fs /dev/null $initdir/etc/systemd/system/systemd-resolved.service + setup_nspawn_root } do_test "$@" diff --git a/test/TEST-29-UDEV-ID_RENAMING/test.sh b/test/TEST-29-UDEV-ID_RENAMING/test.sh index 2a483bbc3d..7d173c8422 100755 --- a/test/TEST-29-UDEV-ID_RENAMING/test.sh +++ b/test/TEST-29-UDEV-ID_RENAMING/test.sh @@ -14,13 +14,7 @@ test_setup() { eval $(udevadm info --export --query=env --name=${LOOPDEV}p2) setup_basic_environment - - # mask some services that we do not want to run in these tests - ln -fs /dev/null $initdir/etc/systemd/system/systemd-hwdb-update.service - ln -fs /dev/null $initdir/etc/systemd/system/systemd-journal-catalog-update.service - ln -fs /dev/null $initdir/etc/systemd/system/systemd-networkd.service - ln -fs /dev/null $initdir/etc/systemd/system/systemd-networkd.socket - ln -fs /dev/null $initdir/etc/systemd/system/systemd-resolved.service + mask_supporting_services # setup the testsuite service cat >$initdir/etc/systemd/system/testsuite.service <$initdir/etc/systemd/system/testsuite.service <$initdir/etc/systemd/system/testsuite.service <$initdir/etc/systemd/system/testsuite.service <$initdir/etc/systemd/system/testsuite.service <$initdir/etc/systemd/system/testsuite.service <$initdir/etc/systemd/system/testsuite.service <$initdir/etc/systemd/system/testsuite.service <$initdir/etc/systemd/system/testsuite.service <