diff options
Diffstat (limited to 'test')
51 files changed, 398 insertions, 477 deletions
diff --git a/test/TEST-01-BASIC/test.sh b/test/TEST-01-BASIC/test.sh index 1c64017aaa..2314ec37ce 100755 --- a/test/TEST-01-BASIC/test.sh +++ b/test/TEST-01-BASIC/test.sh @@ -1,6 +1,4 @@ #!/bin/bash -# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- -# ex: ts=8 sw=4 sts=4 et filetype=sh set -e TEST_DESCRIPTION="Basic systemd setup" RUN_IN_UNPRIVILEGED_CONTAINER=${RUN_IN_UNPRIVILEGED_CONTAINER:-yes} diff --git a/test/TEST-02-CRYPTSETUP/test.sh b/test/TEST-02-CRYPTSETUP/test.sh index 97eb2f409e..aed1c59106 100755 --- a/test/TEST-02-CRYPTSETUP/test.sh +++ b/test/TEST-02-CRYPTSETUP/test.sh @@ -1,6 +1,4 @@ #!/bin/bash -# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- -# ex: ts=8 sw=4 sts=4 et filetype=sh set -e TEST_DESCRIPTION="cryptsetup systemd setup" TEST_NO_NSPAWN=1 diff --git a/test/TEST-03-JOBS/test.sh b/test/TEST-03-JOBS/test.sh index 93a387df59..89125109d8 100755 --- a/test/TEST-03-JOBS/test.sh +++ b/test/TEST-03-JOBS/test.sh @@ -1,6 +1,4 @@ #!/bin/bash -# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- -# ex: ts=8 sw=4 sts=4 et filetype=sh set -e TEST_DESCRIPTION="Job-related tests" TEST_NO_QEMU=1 diff --git a/test/TEST-04-JOURNAL/test-journal.sh b/test/TEST-04-JOURNAL/test-journal.sh index e198cb6ede..4e539aa151 100755 --- a/test/TEST-04-JOURNAL/test-journal.sh +++ b/test/TEST-04-JOURNAL/test-journal.sh @@ -1,5 +1,4 @@ #!/bin/bash - set -x set -e set -o pipefail diff --git a/test/TEST-04-JOURNAL/test.sh b/test/TEST-04-JOURNAL/test.sh index 33bfcbf681..f24a8f6be7 100755 --- a/test/TEST-04-JOURNAL/test.sh +++ b/test/TEST-04-JOURNAL/test.sh @@ -1,6 +1,4 @@ #!/bin/bash -# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- -# ex: ts=8 sw=4 sts=4 et filetype=sh set -e TEST_DESCRIPTION="Journal-related tests" diff --git a/test/TEST-05-RLIMITS/test-rlimits.sh b/test/TEST-05-RLIMITS/test-rlimits.sh index ba665c5968..b4d79c9655 100755 --- a/test/TEST-05-RLIMITS/test-rlimits.sh +++ b/test/TEST-05-RLIMITS/test-rlimits.sh @@ -1,5 +1,4 @@ #!/bin/bash - set -x set -e set -o pipefail diff --git a/test/TEST-05-RLIMITS/test.sh b/test/TEST-05-RLIMITS/test.sh index 3eb2165796..3c29b2ee3f 100755 --- a/test/TEST-05-RLIMITS/test.sh +++ b/test/TEST-05-RLIMITS/test.sh @@ -1,6 +1,4 @@ #!/bin/bash -# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- -# ex: ts=8 sw=4 sts=4 et filetype=sh set -e TEST_DESCRIPTION="Resource limits-related tests" diff --git a/test/TEST-06-SELINUX/test-selinux-checks.sh b/test/TEST-06-SELINUX/test-selinux-checks.sh index 153fab3aac..dae48cd4b2 100755 --- a/test/TEST-06-SELINUX/test-selinux-checks.sh +++ b/test/TEST-06-SELINUX/test-selinux-checks.sh @@ -1,5 +1,4 @@ #!/bin/bash - set -x set -e set -o pipefail diff --git a/test/TEST-06-SELINUX/test.sh b/test/TEST-06-SELINUX/test.sh index 0c924ecbbd..2b49b3d5ae 100755 --- a/test/TEST-06-SELINUX/test.sh +++ b/test/TEST-06-SELINUX/test.sh @@ -1,6 +1,4 @@ #!/bin/bash -# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- -# ex: ts=8 sw=4 sts=4 et filetype=sh set -e TEST_DESCRIPTION="SELinux tests" TEST_NO_NSPAWN=1 diff --git a/test/TEST-07-ISSUE-1981/test-segfault.sh b/test/TEST-07-ISSUE-1981/test-segfault.sh index 48f05d89fb..82339c23cd 100755 --- a/test/TEST-07-ISSUE-1981/test-segfault.sh +++ b/test/TEST-07-ISSUE-1981/test-segfault.sh @@ -1,5 +1,4 @@ #!/bin/bash - set -x set -e diff --git a/test/TEST-07-ISSUE-1981/test.sh b/test/TEST-07-ISSUE-1981/test.sh index 499a36038c..93ddb6f5fb 100755 --- a/test/TEST-07-ISSUE-1981/test.sh +++ b/test/TEST-07-ISSUE-1981/test.sh @@ -1,6 +1,4 @@ #!/bin/bash -# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- -# ex: ts=8 sw=4 sts=4 et filetype=sh set -e TEST_DESCRIPTION="https://github.com/systemd/systemd/issues/1981" TEST_NO_QEMU=1 diff --git a/test/TEST-08-ISSUE-2730/test.sh b/test/TEST-08-ISSUE-2730/test.sh index b01df3656b..ef2aba0e17 100755 --- a/test/TEST-08-ISSUE-2730/test.sh +++ b/test/TEST-08-ISSUE-2730/test.sh @@ -1,6 +1,4 @@ #!/bin/bash -# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- -# ex: ts=8 sw=4 sts=4 et filetype=sh set -e TEST_DESCRIPTION="https://github.com/systemd/systemd/issues/2730" TEST_NO_NSPAWN=1 diff --git a/test/TEST-09-ISSUE-2691/test.sh b/test/TEST-09-ISSUE-2691/test.sh index 01eb4dbac8..8e7402fcd4 100755 --- a/test/TEST-09-ISSUE-2691/test.sh +++ b/test/TEST-09-ISSUE-2691/test.sh @@ -1,6 +1,4 @@ #!/bin/bash -# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- -# ex: ts=8 sw=4 sts=4 et filetype=sh set -e TEST_DESCRIPTION="https://github.com/systemd/systemd/issues/2691" TEST_NO_NSPAWN=1 diff --git a/test/TEST-10-ISSUE-2467/test.sh b/test/TEST-10-ISSUE-2467/test.sh index c85433d7d3..dc7a9acaa1 100755 --- a/test/TEST-10-ISSUE-2467/test.sh +++ b/test/TEST-10-ISSUE-2467/test.sh @@ -1,6 +1,4 @@ #!/bin/bash -# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- -# ex: ts=8 sw=4 sts=4 et filetype=sh set -e TEST_DESCRIPTION="https://github.com/systemd/systemd/issues/2467" diff --git a/test/TEST-11-ISSUE-3166/test.sh b/test/TEST-11-ISSUE-3166/test.sh index 38c725fa70..3419b78fe7 100755 --- a/test/TEST-11-ISSUE-3166/test.sh +++ b/test/TEST-11-ISSUE-3166/test.sh @@ -1,6 +1,4 @@ #!/bin/bash -# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- -# ex: ts=8 sw=4 sts=4 et filetype=sh set -e TEST_DESCRIPTION="https://github.com/systemd/systemd/issues/3166" TEST_NO_NSPAWN=1 diff --git a/test/TEST-12-ISSUE-3171/test.sh b/test/TEST-12-ISSUE-3171/test.sh index 0c267e11a6..31cf1b471a 100755 --- a/test/TEST-12-ISSUE-3171/test.sh +++ b/test/TEST-12-ISSUE-3171/test.sh @@ -1,6 +1,4 @@ #!/bin/bash -# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- -# ex: ts=8 sw=4 sts=4 et filetype=sh set -e TEST_DESCRIPTION="https://github.com/systemd/systemd/issues/3171" TEST_NO_QEMU=1 diff --git a/test/TEST-13-NSPAWN-SMOKE/test.sh b/test/TEST-13-NSPAWN-SMOKE/test.sh index 774b7cbed5..bd85b92caa 100755 --- a/test/TEST-13-NSPAWN-SMOKE/test.sh +++ b/test/TEST-13-NSPAWN-SMOKE/test.sh @@ -1,6 +1,4 @@ #!/bin/bash -# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- -# ex: ts=8 sw=4 sts=4 et filetype=sh set -e TEST_DESCRIPTION="systemd-nspawn smoke test" TEST_NO_NSPAWN=1 diff --git a/test/TEST-14-MACHINE-ID/test.sh b/test/TEST-14-MACHINE-ID/test.sh index 9435834204..33e311a1e7 100755 --- a/test/TEST-14-MACHINE-ID/test.sh +++ b/test/TEST-14-MACHINE-ID/test.sh @@ -1,6 +1,4 @@ #!/bin/bash -# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- -# ex: ts=8 sw=4 sts=4 et filetype=sh set -e TEST_DESCRIPTION="/etc/machine-id testing" TEST_NO_NSPAWN=1 diff --git a/test/TEST-15-DROPIN/test-dropin.sh b/test/TEST-15-DROPIN/test-dropin.sh index ab0a58caea..02962a8a07 100755 --- a/test/TEST-15-DROPIN/test-dropin.sh +++ b/test/TEST-15-DROPIN/test-dropin.sh @@ -1,279 +1,278 @@ #! /bin/bash - set -e set -x _clear_service () { - systemctl stop $1.service 2>/dev/null || : - rm -f /{etc,run,usr/lib}/systemd/system/$1.service - rm -fr /{etc,run,usr/lib}/systemd/system/$1.service.d - rm -fr /{etc,run,usr/lib}/systemd/system/$1.service.{wants,requires} + systemctl stop $1.service 2>/dev/null || : + rm -f /{etc,run,usr/lib}/systemd/system/$1.service + rm -fr /{etc,run,usr/lib}/systemd/system/$1.service.d + rm -fr /{etc,run,usr/lib}/systemd/system/$1.service.{wants,requires} } clear_services () { - for u in $*; do - _clear_service $u - done - systemctl daemon-reload + for u in $*; do + _clear_service $u + done + systemctl daemon-reload } create_service () { - clear_services $1 + clear_services $1 - cat >/etc/systemd/system/$1.service<<EOF + cat >/etc/systemd/system/$1.service<<EOF [Unit] Description=$1 unit [Service] ExecStart=/bin/sleep 100000 EOF - mkdir -p /{etc,run,usr/lib}/systemd/system/$1.service.d - mkdir -p /etc/systemd/system/$1.service.{wants,requires} - mkdir -p /run/systemd/system/$1.service.{wants,requires} - mkdir -p /usr/lib/systemd/system/$1.service.{wants,requires} + mkdir -p /{etc,run,usr/lib}/systemd/system/$1.service.d + mkdir -p /etc/systemd/system/$1.service.{wants,requires} + mkdir -p /run/systemd/system/$1.service.{wants,requires} + mkdir -p /usr/lib/systemd/system/$1.service.{wants,requires} } create_services () { - for u in $*; do - create_service $u - done + for u in $*; do + create_service $u + done } check_ok () { - [ $# -eq 3 ] || return + [ $# -eq 3 ] || return - x="$(systemctl show --value -p $2 $1)" - case "$x" in - *$3*) return 0 ;; - *) return 1 - esac + x="$(systemctl show --value -p $2 $1)" + case "$x" in + *$3*) return 0 ;; + *) return 1 ;; + esac } check_ko () { - ! check_ok "$@" + ! check_ok "$@" } test_basic_dropins () { - echo "Testing basic dropins..." - - echo "*** test a wants b wants c" - create_services a b c - ln -s ../b.service /etc/systemd/system/a.service.wants/ - ln -s ../c.service /etc/systemd/system/b.service.wants/ - check_ok a Wants b.service - check_ok b Wants c.service - - echo "*** test a wants,requires b" - create_services a b c - ln -s ../b.service /etc/systemd/system/a.service.wants/ - ln -s ../b.service /etc/systemd/system/a.service.requires/ - check_ok a Wants b.service - check_ok a Requires b.service - - echo "*** test a wants nonexistent" - create_service a - ln -s ../nonexistent.service /etc/systemd/system/a.service.wants/ - check_ok a Wants nonexistent.service - systemctl start a - systemctl stop a - - echo "*** test a requires nonexistent" - ln -sf ../nonexistent.service /etc/systemd/system/a.service.requires/ - systemctl daemon-reload - check_ok a Requires nonexistent.service - - # 'b' is already loaded when 'c' pulls it in via a dropin. - echo "*** test a,c require b" - create_services a b c - ln -sf ../b.service /etc/systemd/system/a.service.requires/ - ln -sf ../b.service /etc/systemd/system/c.service.requires/ - systemctl start a - check_ok c Requires b.service - systemctl stop a b - - # 'b' is already loaded when 'c' pulls it in via an alias dropin. - echo "*** test a wants alias" - create_services a b c - ln -sf c.service /etc/systemd/system/c1.service - ln -sf ../c.service /etc/systemd/system/a.service.wants/ - ln -sf ../c1.service /etc/systemd/system/b.service.wants/ - systemctl start a - check_ok a Wants c.service - check_ok b Wants c.service - systemctl stop a c - - clear_services a b c + echo "Testing basic dropins..." + + echo "*** test a wants b wants c" + create_services a b c + ln -s ../b.service /etc/systemd/system/a.service.wants/ + ln -s ../c.service /etc/systemd/system/b.service.wants/ + check_ok a Wants b.service + check_ok b Wants c.service + + echo "*** test a wants,requires b" + create_services a b c + ln -s ../b.service /etc/systemd/system/a.service.wants/ + ln -s ../b.service /etc/systemd/system/a.service.requires/ + check_ok a Wants b.service + check_ok a Requires b.service + + echo "*** test a wants nonexistent" + create_service a + ln -s ../nonexistent.service /etc/systemd/system/a.service.wants/ + check_ok a Wants nonexistent.service + systemctl start a + systemctl stop a + + echo "*** test a requires nonexistent" + ln -sf ../nonexistent.service /etc/systemd/system/a.service.requires/ + systemctl daemon-reload + check_ok a Requires nonexistent.service + + # 'b' is already loaded when 'c' pulls it in via a dropin. + echo "*** test a,c require b" + create_services a b c + ln -sf ../b.service /etc/systemd/system/a.service.requires/ + ln -sf ../b.service /etc/systemd/system/c.service.requires/ + systemctl start a + check_ok c Requires b.service + systemctl stop a b + + # 'b' is already loaded when 'c' pulls it in via an alias dropin. + echo "*** test a wants alias" + create_services a b c + ln -sf c.service /etc/systemd/system/c1.service + ln -sf ../c.service /etc/systemd/system/a.service.wants/ + ln -sf ../c1.service /etc/systemd/system/b.service.wants/ + systemctl start a + check_ok a Wants c.service + check_ok b Wants c.service + systemctl stop a c + + clear_services a b c } test_template_dropins () { - echo "Testing template dropins..." + echo "Testing template dropins..." - create_services foo bar@ yup@ + create_services foo bar@ yup@ - ln -s /etc/systemd/system/bar@.service /etc/systemd/system/foo.service.wants/bar@1.service - check_ok foo Wants bar@1.service + ln -s /etc/systemd/system/bar@.service /etc/systemd/system/foo.service.wants/bar@1.service + check_ok foo Wants bar@1.service - clear_services foo bar@ yup@ + clear_services foo bar@ yup@ } test_alias_dropins () { - echo "Testing alias dropins..." - - echo "*** test a wants b1 alias of b" - create_services a b - ln -sf b.service /etc/systemd/system/b1.service - ln -sf ../b1.service /etc/systemd/system/a.service.wants/ - check_ok a Wants b.service - systemctl start a - systemctl --quiet is-active b - systemctl stop a b - rm /etc/systemd/system/b1.service - clear_services a b - - # A weird behavior: the dependencies for 'a' may vary. It can be - # changed by loading an alias... - # - # [1] 'a1' is loaded and then "renamed" into 'a'. 'a1' is therefore - # part of the names set so all its specific dropins are loaded. - # - # [2] 'a' is already loaded. 'a1' is simply only merged into 'a' so - # none of its dropins are loaded ('y' is missing from the deps). - echo "*** test 2" - create_services a x y - mkdir -p /etc/systemd/system/a1.service.wants/ - ln -sf a.service /etc/systemd/system/a1.service - ln -sf ../x.service /etc/systemd/system/a.service.wants/ - ln -sf ../y.service /etc/systemd/system/a1.service.wants/ - check_ok a1 Wants x.service # see [1] - check_ok a1 Wants y.service - systemctl start a - check_ok a1 Wants x.service # see [2] - check_ko a1 Wants y.service - systemctl stop a x y - rm /etc/systemd/system/a1.service - - clear_services a x y + echo "Testing alias dropins..." + + echo "*** test a wants b1 alias of b" + create_services a b + ln -sf b.service /etc/systemd/system/b1.service + ln -sf ../b1.service /etc/systemd/system/a.service.wants/ + check_ok a Wants b.service + systemctl start a + systemctl --quiet is-active b + systemctl stop a b + rm /etc/systemd/system/b1.service + clear_services a b + + # A weird behavior: the dependencies for 'a' may vary. It can be + # changed by loading an alias... + # + # [1] 'a1' is loaded and then "renamed" into 'a'. 'a1' is therefore + # part of the names set so all its specific dropins are loaded. + # + # [2] 'a' is already loaded. 'a1' is simply only merged into 'a' so + # none of its dropins are loaded ('y' is missing from the deps). + echo "*** test 2" + create_services a x y + mkdir -p /etc/systemd/system/a1.service.wants/ + ln -sf a.service /etc/systemd/system/a1.service + ln -sf ../x.service /etc/systemd/system/a.service.wants/ + ln -sf ../y.service /etc/systemd/system/a1.service.wants/ + check_ok a1 Wants x.service # see [1] + check_ok a1 Wants y.service + systemctl start a + check_ok a1 Wants x.service # see [2] + check_ko a1 Wants y.service + systemctl stop a x y + rm /etc/systemd/system/a1.service + + clear_services a x y } test_masked_dropins () { - echo "Testing masked dropins..." - - create_services a b - - # 'b' is masked for both deps - echo "*** test a wants,requires b is masked" - ln -sf /dev/null /etc/systemd/system/a.service.wants/b.service - ln -sf /dev/null /etc/systemd/system/a.service.requires/b.service - check_ko a Wants b.service - check_ko a Requires b.service - - # 'a' wants 'b' and 'b' is masked at a lower level - echo "*** test a wants b, mask override" - ln -sf ../b.service /etc/systemd/system/a.service.wants/b.service - ln -sf /dev/null /usr/lib/systemd/system/a.service.wants/b.service - check_ok a Wants b.service - - # 'a' wants 'b' and 'b' is masked at a higher level - echo "*** test a wants b, mask" - ln -sf /dev/null /etc/systemd/system/a.service.wants/b.service - ln -sf ../b.service /usr/lib/systemd/system/a.service.wants/b.service - check_ko a Wants b.service - - # 'a' is masked but has an override config file - echo "*** test a is masked but has an override" - create_services a b - ln -sf /dev/null /etc/systemd/system/a.service - cat >/usr/lib/systemd/system/a.service.d/override.conf <<EOF + echo "Testing masked dropins..." + + create_services a b + + # 'b' is masked for both deps + echo "*** test a wants,requires b is masked" + ln -sf /dev/null /etc/systemd/system/a.service.wants/b.service + ln -sf /dev/null /etc/systemd/system/a.service.requires/b.service + check_ko a Wants b.service + check_ko a Requires b.service + + # 'a' wants 'b' and 'b' is masked at a lower level + echo "*** test a wants b, mask override" + ln -sf ../b.service /etc/systemd/system/a.service.wants/b.service + ln -sf /dev/null /usr/lib/systemd/system/a.service.wants/b.service + check_ok a Wants b.service + + # 'a' wants 'b' and 'b' is masked at a higher level + echo "*** test a wants b, mask" + ln -sf /dev/null /etc/systemd/system/a.service.wants/b.service + ln -sf ../b.service /usr/lib/systemd/system/a.service.wants/b.service + check_ko a Wants b.service + + # 'a' is masked but has an override config file + echo "*** test a is masked but has an override" + create_services a b + ln -sf /dev/null /etc/systemd/system/a.service + cat >/usr/lib/systemd/system/a.service.d/override.conf <<EOF [Unit] After=b.service EOF - check_ok a UnitFileState masked - - # 'b1' is an alias for 'b': masking 'b' dep should not influence 'b1' dep - echo "*** test a wants b, b1, and one is masked" - create_services a b - ln -sf b.service /etc/systemd/system/b1.service - ln -sf /dev/null /etc/systemd/system/a.service.wants/b.service - ln -sf ../b1.service /usr/lib/systemd/system/a.service.wants/b1.service - systemctl cat a - systemctl show -p Wants,Requires a - systemctl cat b1 - systemctl show -p Wants,Requires b1 - check_ok a Wants b.service - check_ko a Wants b1.service # the alias does not show up in the list of units - rm /etc/systemd/system/b1.service - - # 'b1' is an alias for 'b': masking 'b1' should not influence 'b' dep - echo "*** test a wants b, alias dep is masked" - create_services a b - ln -sf b.service /etc/systemd/system/b1.service - ln -sf /dev/null /etc/systemd/system/a.service.wants/b1.service - ln -sf ../b.service /usr/lib/systemd/system/a.service.wants/b.service - check_ok a Wants b.service - check_ko a Wants b1.service # the alias does not show up in the list of units - rm /etc/systemd/system/b1.service - - # 'a' has Wants=b.service but also has a masking - # dropin 'b': 'b' should still be pulled in. - echo "*** test a wants b both ways" - create_services a b - ln -sf /dev/null /etc/systemd/system/a.service.wants/b.service - cat >/usr/lib/systemd/system/a.service.d/wants-b.conf<<EOF + check_ok a UnitFileState masked + + # 'b1' is an alias for 'b': masking 'b' dep should not influence 'b1' dep + echo "*** test a wants b, b1, and one is masked" + create_services a b + ln -sf b.service /etc/systemd/system/b1.service + ln -sf /dev/null /etc/systemd/system/a.service.wants/b.service + ln -sf ../b1.service /usr/lib/systemd/system/a.service.wants/b1.service + systemctl cat a + systemctl show -p Wants,Requires a + systemctl cat b1 + systemctl show -p Wants,Requires b1 + check_ok a Wants b.service + check_ko a Wants b1.service # the alias does not show up in the list of units + rm /etc/systemd/system/b1.service + + # 'b1' is an alias for 'b': masking 'b1' should not influence 'b' dep + echo "*** test a wants b, alias dep is masked" + create_services a b + ln -sf b.service /etc/systemd/system/b1.service + ln -sf /dev/null /etc/systemd/system/a.service.wants/b1.service + ln -sf ../b.service /usr/lib/systemd/system/a.service.wants/b.service + check_ok a Wants b.service + check_ko a Wants b1.service # the alias does not show up in the list of units + rm /etc/systemd/system/b1.service + + # 'a' has Wants=b.service but also has a masking + # dropin 'b': 'b' should still be pulled in. + echo "*** test a wants b both ways" + create_services a b + ln -sf /dev/null /etc/systemd/system/a.service.wants/b.service + cat >/usr/lib/systemd/system/a.service.d/wants-b.conf<<EOF [Unit] Wants=b.service EOF - check_ok a Wants b.service - - # mask a dropin that points to an nonexistent unit. - echo "*** test a wants nonexistent is masked" - create_services a - ln -sf /dev/null /etc/systemd/system/a.service.requires/nonexistent.service - ln -sf ../nonexistent.service /usr/lib/systemd/system/a.service.requires/ - check_ko a Requires nonexistent.service - - # 'b' is already loaded when 'c' pulls it in via a dropin but 'b' is - # masked at a higher level. - echo "*** test a wants b is masked" - create_services a b c - ln -sf ../b.service /etc/systemd/system/a.service.requires/ - ln -sf ../b.service /run/systemd/system/c.service.requires/ - ln -sf /dev/null /etc/systemd/system/c.service.requires/b.service - systemctl start a - check_ko c Requires b.service - systemctl stop a b - - # 'b' is already loaded when 'c' pulls it in via a dropin but 'b' is - # masked at a lower level. - echo "*** test a requires b is masked" - create_services a b c - ln -sf ../b.service /etc/systemd/system/a.service.requires/ - ln -sf ../b.service /etc/systemd/system/c.service.requires/ - ln -sf /dev/null /run/systemd/system/c.service.requires/b.service - systemctl start a - check_ok c Requires b.service - systemctl stop a b - - # 'a' requires 2 aliases of 'b' and one of them is a mask. - echo "*** test a requires alias of b, other alias masked" - create_services a b - ln -sf b.service /etc/systemd/system/b1.service - ln -sf b.service /etc/systemd/system/b2.service - ln -sf /dev/null /etc/systemd/system/a.service.requires/b1.service - ln -sf ../b1.service /run/systemd/system/a.service.requires/ - ln -sf ../b2.service /usr/lib/systemd/system/a.service.requires/ - check_ok a Requires b - - # Same as above but now 'b' is masked. - echo "*** test a requires alias of b, b dep masked" - create_services a b - ln -sf b.service /etc/systemd/system/b1.service - ln -sf b.service /etc/systemd/system/b2.service - ln -sf ../b1.service /run/systemd/system/a.service.requires/ - ln -sf ../b2.service /usr/lib/systemd/system/a.service.requires/ - ln -sf /dev/null /etc/systemd/system/a.service.requires/b.service - check_ok a Requires b - - clear_services a b + check_ok a Wants b.service + + # mask a dropin that points to an nonexistent unit. + echo "*** test a wants nonexistent is masked" + create_services a + ln -sf /dev/null /etc/systemd/system/a.service.requires/nonexistent.service + ln -sf ../nonexistent.service /usr/lib/systemd/system/a.service.requires/ + check_ko a Requires nonexistent.service + + # 'b' is already loaded when 'c' pulls it in via a dropin but 'b' is + # masked at a higher level. + echo "*** test a wants b is masked" + create_services a b c + ln -sf ../b.service /etc/systemd/system/a.service.requires/ + ln -sf ../b.service /run/systemd/system/c.service.requires/ + ln -sf /dev/null /etc/systemd/system/c.service.requires/b.service + systemctl start a + check_ko c Requires b.service + systemctl stop a b + + # 'b' is already loaded when 'c' pulls it in via a dropin but 'b' is + # masked at a lower level. + echo "*** test a requires b is masked" + create_services a b c + ln -sf ../b.service /etc/systemd/system/a.service.requires/ + ln -sf ../b.service /etc/systemd/system/c.service.requires/ + ln -sf /dev/null /run/systemd/system/c.service.requires/b.service + systemctl start a + check_ok c Requires b.service + systemctl stop a b + + # 'a' requires 2 aliases of 'b' and one of them is a mask. + echo "*** test a requires alias of b, other alias masked" + create_services a b + ln -sf b.service /etc/systemd/system/b1.service + ln -sf b.service /etc/systemd/system/b2.service + ln -sf /dev/null /etc/systemd/system/a.service.requires/b1.service + ln -sf ../b1.service /run/systemd/system/a.service.requires/ + ln -sf ../b2.service /usr/lib/systemd/system/a.service.requires/ + check_ok a Requires b + + # Same as above but now 'b' is masked. + echo "*** test a requires alias of b, b dep masked" + create_services a b + ln -sf b.service /etc/systemd/system/b1.service + ln -sf b.service /etc/systemd/system/b2.service + ln -sf ../b1.service /run/systemd/system/a.service.requires/ + ln -sf ../b2.service /usr/lib/systemd/system/a.service.requires/ + ln -sf /dev/null /etc/systemd/system/a.service.requires/b.service + check_ok a Requires b + + clear_services a b } test_basic_dropins diff --git a/test/TEST-15-DROPIN/test.sh b/test/TEST-15-DROPIN/test.sh index cc0d56da8a..fab127362a 100755 --- a/test/TEST-15-DROPIN/test.sh +++ b/test/TEST-15-DROPIN/test.sh @@ -1,6 +1,4 @@ #!/bin/bash -# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- -# ex: ts=8 sw=4 sts=4 et filetype=sh set -e TEST_DESCRIPTION="Dropin tests" TEST_NO_QEMU=1 @@ -8,27 +6,27 @@ TEST_NO_QEMU=1 . $TEST_BASE_DIR/test-functions test_setup() { - # create the basic filesystem layout - setup_basic_environment + # create the basic filesystem layout + setup_basic_environment - # mask some services that we do not want to run in these tests - ln -s /dev/null $initdir/etc/systemd/system/systemd-hwdb-update.service - ln -s /dev/null $initdir/etc/systemd/system/systemd-journal-catalog-update.service - ln -s /dev/null $initdir/etc/systemd/system/systemd-networkd.service - ln -s /dev/null $initdir/etc/systemd/system/systemd-networkd.socket - ln -s /dev/null $initdir/etc/systemd/system/systemd-resolved.service + # mask some services that we do not want to run in these tests + ln -s /dev/null $initdir/etc/systemd/system/systemd-hwdb-update.service + ln -s /dev/null $initdir/etc/systemd/system/systemd-journal-catalog-update.service + ln -s /dev/null $initdir/etc/systemd/system/systemd-networkd.service + ln -s /dev/null $initdir/etc/systemd/system/systemd-networkd.socket + ln -s /dev/null $initdir/etc/systemd/system/systemd-resolved.service - # import the test scripts in the rootfs and plug them in systemd - cp testsuite.service $initdir/etc/systemd/system/ - cp test-dropin.sh $initdir/ - setup_testsuite + # import the test scripts in the rootfs and plug them in systemd + cp testsuite.service $initdir/etc/systemd/system/ + cp test-dropin.sh $initdir/ + setup_testsuite - # create dedicated rootfs for nspawn (located in $TESTDIR/nspawn-root) - setup_nspawn_root + # create dedicated rootfs for nspawn (located in $TESTDIR/nspawn-root) + setup_nspawn_root } test_cleanup() { - return 0 + return 0 } do_test "$@" diff --git a/test/TEST-16-EXTEND-TIMEOUT/test.sh b/test/TEST-16-EXTEND-TIMEOUT/test.sh index e7bb5430c0..6613e32fc9 100755 --- a/test/TEST-16-EXTEND-TIMEOUT/test.sh +++ b/test/TEST-16-EXTEND-TIMEOUT/test.sh @@ -1,6 +1,4 @@ #!/bin/bash -# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- -# ex: ts=8 sw=4 sts=4 et filetype=sh set -e TEST_DESCRIPTION="EXTEND_TIMEOUT_USEC=usec start/runtime/stop tests" SKIP_INITRD=yes diff --git a/test/TEST-17-UDEV-WANTS/test.sh b/test/TEST-17-UDEV-WANTS/test.sh index 074771ab75..9bd6e98644 100755 --- a/test/TEST-17-UDEV-WANTS/test.sh +++ b/test/TEST-17-UDEV-WANTS/test.sh @@ -1,6 +1,4 @@ #!/bin/bash -# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- -# ex: ts=8 sw=4 sts=4 et filetype=sh set -e TEST_DESCRIPTION="UDEV SYSTEMD_WANTS property" TEST_NO_NSPAWN=1 diff --git a/test/TEST-17-UDEV-WANTS/testsuite.sh b/test/TEST-17-UDEV-WANTS/testsuite.sh index 5f97084cee..ceac3697b5 100755 --- a/test/TEST-17-UDEV-WANTS/testsuite.sh +++ b/test/TEST-17-UDEV-WANTS/testsuite.sh @@ -1,6 +1,4 @@ #!/bin/bash -# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- -# ex: ts=8 sw=4 sts=4 et filetype=sh set -ex set -o pipefail diff --git a/test/TEST-18-FAILUREACTION/test.sh b/test/TEST-18-FAILUREACTION/test.sh index 783b3aac6e..277cc2c798 100755 --- a/test/TEST-18-FAILUREACTION/test.sh +++ b/test/TEST-18-FAILUREACTION/test.sh @@ -1,6 +1,4 @@ #!/bin/bash -# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- -# ex: ts=8 sw=4 sts=4 et filetype=sh set -e TEST_DESCRIPTION="FailureAction= operation" diff --git a/test/TEST-18-FAILUREACTION/testsuite.sh b/test/TEST-18-FAILUREACTION/testsuite.sh index 1867cc3c47..bf9c025766 100755 --- a/test/TEST-18-FAILUREACTION/testsuite.sh +++ b/test/TEST-18-FAILUREACTION/testsuite.sh @@ -1,6 +1,4 @@ #!/bin/bash -# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- -# ex: ts=8 sw=4 sts=4 et filetype=sh set -ex set -o pipefail diff --git a/test/TEST-19-DELEGATE/test.sh b/test/TEST-19-DELEGATE/test.sh index bb0c5057b2..3ed6a1b928 100755 --- a/test/TEST-19-DELEGATE/test.sh +++ b/test/TEST-19-DELEGATE/test.sh @@ -1,6 +1,4 @@ #!/bin/bash -# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- -# ex: ts=8 sw=4 sts=4 et filetype=sh set -e TEST_DESCRIPTION="test cgroup delegation in the unified hierarchy" TEST_NO_NSPAWN=1 diff --git a/test/TEST-19-DELEGATE/testsuite.sh b/test/TEST-19-DELEGATE/testsuite.sh index fdfab950b1..a2cb2b875f 100755 --- a/test/TEST-19-DELEGATE/testsuite.sh +++ b/test/TEST-19-DELEGATE/testsuite.sh @@ -1,39 +1,37 @@ #!/bin/bash -# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- -# ex: ts=8 sw=4 sts=4 et filetype=sh set -ex set -o pipefail if grep -q cgroup2 /proc/filesystems ; then - systemd-run --wait --unit=test0.service -p "DynamicUser=1" -p "Delegate=" \ - test -w /sys/fs/cgroup/system.slice/test0.service/ -a \ - -w /sys/fs/cgroup/system.slice/test0.service/cgroup.procs -a \ - -w /sys/fs/cgroup/system.slice/test0.service/cgroup.subtree_control + systemd-run --wait --unit=test0.service -p "DynamicUser=1" -p "Delegate=" \ + test -w /sys/fs/cgroup/system.slice/test0.service/ -a \ + -w /sys/fs/cgroup/system.slice/test0.service/cgroup.procs -a \ + -w /sys/fs/cgroup/system.slice/test0.service/cgroup.subtree_control - systemd-run --wait --unit=test1.service -p "DynamicUser=1" -p "Delegate=memory pids" \ - grep -q memory /sys/fs/cgroup/system.slice/test1.service/cgroup.controllers + systemd-run --wait --unit=test1.service -p "DynamicUser=1" -p "Delegate=memory pids" \ + grep -q memory /sys/fs/cgroup/system.slice/test1.service/cgroup.controllers - systemd-run --wait --unit=test2.service -p "DynamicUser=1" -p "Delegate=memory pids" \ - grep -q pids /sys/fs/cgroup/system.slice/test2.service/cgroup.controllers + systemd-run --wait --unit=test2.service -p "DynamicUser=1" -p "Delegate=memory pids" \ + grep -q pids /sys/fs/cgroup/system.slice/test2.service/cgroup.controllers - # "io" is not among the controllers enabled by default for all units, verify that - grep -qv io /sys/fs/cgroup/system.slice/cgroup.controllers + # "io" is not among the controllers enabled by default for all units, verify that + grep -qv io /sys/fs/cgroup/system.slice/cgroup.controllers - # Run a service with "io" enabled, and verify it works - systemd-run --wait --unit=test3.service -p "IOAccounting=yes" -p "Slice=system-foo-bar-baz.slice" \ - grep -q io /sys/fs/cgroup/system.slice/system-foo.slice/system-foo-bar.slice/system-foo-bar-baz.slice/test3.service/cgroup.controllers + # Run a service with "io" enabled, and verify it works + systemd-run --wait --unit=test3.service -p "IOAccounting=yes" -p "Slice=system-foo-bar-baz.slice" \ + grep -q io /sys/fs/cgroup/system.slice/system-foo.slice/system-foo-bar.slice/system-foo-bar-baz.slice/test3.service/cgroup.controllers - # We want to check if "io" is removed again from the controllers - # list. However, PID 1 (rightfully) does this asynchronously. In order - # to force synchronization on this, let's start a short-lived service - # which requires PID 1 to refresh the cgroup tree, so that we can - # verify that this all works. - systemd-run --wait --unit=test4.service true + # We want to check if "io" is removed again from the controllers + # list. However, PID 1 (rightfully) does this asynchronously. In order + # to force synchronization on this, let's start a short-lived service + # which requires PID 1 to refresh the cgroup tree, so that we can + # verify that this all works. + systemd-run --wait --unit=test4.service true - # And now check again, "io" should have vanished - grep -qv io /sys/fs/cgroup/system.slice/cgroup.controllers + # And now check again, "io" should have vanished + grep -qv io /sys/fs/cgroup/system.slice/cgroup.controllers else - echo "Skipping TEST-19-DELEGATE, as the kernel doesn't actually support cgroup v2" >&2 + echo "Skipping TEST-19-DELEGATE, as the kernel doesn't actually support cgroup v2" >&2 fi echo OK > /testok diff --git a/test/TEST-20-MAINPIDGAMES/test.sh b/test/TEST-20-MAINPIDGAMES/test.sh index 4ec8081478..bf80e8b584 100755 --- a/test/TEST-20-MAINPIDGAMES/test.sh +++ b/test/TEST-20-MAINPIDGAMES/test.sh @@ -1,6 +1,4 @@ #!/bin/bash -# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- -# ex: ts=8 sw=4 sts=4 et filetype=sh set -e TEST_DESCRIPTION="test changing main PID" diff --git a/test/TEST-20-MAINPIDGAMES/testsuite.sh b/test/TEST-20-MAINPIDGAMES/testsuite.sh index b183ec9a6b..9471a5d734 100755 --- a/test/TEST-20-MAINPIDGAMES/testsuite.sh +++ b/test/TEST-20-MAINPIDGAMES/testsuite.sh @@ -1,6 +1,4 @@ #!/bin/bash -# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- -# ex: ts=8 sw=4 sts=4 et filetype=sh set -ex set -o pipefail diff --git a/test/TEST-21-SYSUSERS/test.sh b/test/TEST-21-SYSUSERS/test.sh index b1049e720d..9f64e030b5 100755 --- a/test/TEST-21-SYSUSERS/test.sh +++ b/test/TEST-21-SYSUSERS/test.sh @@ -1,21 +1,19 @@ #!/bin/bash -# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- -# ex: ts=8 sw=4 sts=4 et filetype=sh set -e TEST_DESCRIPTION="Sysuser-related tests" . $TEST_BASE_DIR/test-functions test_setup() { - mkdir -p $TESTDIR/etc/sysusers.d $TESTDIR/usr/lib/sysusers.d $TESTDIR/tmp + mkdir -p $TESTDIR/etc/sysusers.d $TESTDIR/usr/lib/sysusers.d $TESTDIR/tmp } prepare_testdir() { - rm -f $TESTDIR/etc/*{passwd,group,shadow} - for i in $1.initial-{passwd,group,shadow}; do - test -f $i && cp $i $TESTDIR/etc/${i#*.initial-} - done - return 0 + rm -f $TESTDIR/etc/*{passwd,group,shadow} + for i in $1.initial-{passwd,group,shadow}; do + test -f $i && cp $i $TESTDIR/etc/${i#*.initial-} + done + return 0 } preprocess() { @@ -30,92 +28,92 @@ preprocess() { compare() { if ! diff -u $TESTDIR/etc/passwd <(preprocess ${1%.*}.expected-passwd); then - echo "**** Unexpected output for $f" - exit 1 + echo "**** Unexpected output for $f" + exit 1 fi if ! diff -u $TESTDIR/etc/group <(preprocess ${1%.*}.expected-group); then - echo "**** Unexpected output for $f $2" - exit 1 + echo "**** Unexpected output for $f $2" + exit 1 fi } test_run() { - # ensure our build of systemd-sysusers is run - PATH=${BUILD_DIR}:$PATH - - rm -f $TESTDIR/etc/sysusers.d/* $TESTDIR/usr/lib/sysusers.d/* - - # happy tests - for f in test-*.input; do - echo "*** Running $f" - prepare_testdir ${f%.input} - cp $f $TESTDIR/usr/lib/sysusers.d/test.conf - systemd-sysusers --root=$TESTDIR - - compare $f "" - done - - for f in test-*.input; do - echo "*** Running $f on stdin" - prepare_testdir ${f%.input} - touch $TESTDIR/etc/sysusers.d/test.conf - cat $f | systemd-sysusers --root=$TESTDIR - - - compare $f "on stdin" - done - - for f in test-*.input; do - echo "*** Running $f on stdin with --replace" - prepare_testdir ${f%.input} - touch $TESTDIR/etc/sysusers.d/test.conf - # this overrides test.conf which is masked on disk - cat $f | systemd-sysusers --root=$TESTDIR --replace=/etc/sysusers.d/test.conf - - # this should be ignored - cat test-1.input | systemd-sysusers --root=$TESTDIR --replace=/usr/lib/sysusers.d/test.conf - - - compare $f "on stdin with --replace" - done - - # test --inline - echo "*** Testing --inline" - prepare_testdir - # copy a random file to make sure it is ignored - cp $f $TESTDIR/etc/sysusers.d/confuse.conf - systemd-sysusers --root=$TESTDIR --inline \ - "u u1 222 - - /bin/zsh" \ - "g g1 111" - - compare inline "(--inline)" - - # test --replace - echo "*** Testing --inline with --replace" - prepare_testdir - # copy a random file to make sure it is ignored - cp $f $TESTDIR/etc/sysusers.d/confuse.conf - systemd-sysusers --root=$TESTDIR \ - --inline \ - --replace=/etc/sysusers.d/confuse.conf \ - "u u1 222 - - /bin/zsh" \ - "g g1 111" - - compare inline "(--inline --replace=…)" - - rm -f $TESTDIR/etc/sysusers.d/* $TESTDIR/usr/lib/sysusers.d/* - - # tests for error conditions - for f in unhappy-*.input; do - echo "*** Running test $f" - prepare_testdir ${f%.input} - cp $f $TESTDIR/usr/lib/sysusers.d/test.conf - systemd-sysusers --root=$TESTDIR 2> /dev/null - journalctl -t systemd-sysusers -o cat | tail -n1 > $TESTDIR/tmp/err - if ! diff -u $TESTDIR/tmp/err ${f%.*}.expected-err; then - echo "**** Unexpected error output for $f" - cat $TESTDIR/tmp/err - exit 1 - fi - done + # ensure our build of systemd-sysusers is run + PATH=${BUILD_DIR}:$PATH + + rm -f $TESTDIR/etc/sysusers.d/* $TESTDIR/usr/lib/sysusers.d/* + + # happy tests + for f in test-*.input; do + echo "*** Running $f" + prepare_testdir ${f%.input} + cp $f $TESTDIR/usr/lib/sysusers.d/test.conf + systemd-sysusers --root=$TESTDIR + + compare $f "" + done + + for f in test-*.input; do + echo "*** Running $f on stdin" + prepare_testdir ${f%.input} + touch $TESTDIR/etc/sysusers.d/test.conf + cat $f | systemd-sysusers --root=$TESTDIR - + + compare $f "on stdin" + done + + for f in test-*.input; do + echo "*** Running $f on stdin with --replace" + prepare_testdir ${f%.input} + touch $TESTDIR/etc/sysusers.d/test.conf + # this overrides test.conf which is masked on disk + cat $f | systemd-sysusers --root=$TESTDIR --replace=/etc/sysusers.d/test.conf - + # this should be ignored + cat test-1.input | systemd-sysusers --root=$TESTDIR --replace=/usr/lib/sysusers.d/test.conf - + + compare $f "on stdin with --replace" + done + + # test --inline + echo "*** Testing --inline" + prepare_testdir + # copy a random file to make sure it is ignored + cp $f $TESTDIR/etc/sysusers.d/confuse.conf + systemd-sysusers --root=$TESTDIR --inline \ + "u u1 222 - - /bin/zsh" \ + "g g1 111" + + compare inline "(--inline)" + + # test --replace + echo "*** Testing --inline with --replace" + prepare_testdir + # copy a random file to make sure it is ignored + cp $f $TESTDIR/etc/sysusers.d/confuse.conf + systemd-sysusers --root=$TESTDIR \ + --inline \ + --replace=/etc/sysusers.d/confuse.conf \ + "u u1 222 - - /bin/zsh" \ + "g g1 111" + + compare inline "(--inline --replace=…)" + + rm -f $TESTDIR/etc/sysusers.d/* $TESTDIR/usr/lib/sysusers.d/* + + # tests for error conditions + for f in unhappy-*.input; do + echo "*** Running test $f" + prepare_testdir ${f%.input} + cp $f $TESTDIR/usr/lib/sysusers.d/test.conf + systemd-sysusers --root=$TESTDIR 2> /dev/null + journalctl -t systemd-sysusers -o cat | tail -n1 > $TESTDIR/tmp/err + if ! diff -u $TESTDIR/tmp/err ${f%.*}.expected-err; then + echo "**** Unexpected error output for $f" + cat $TESTDIR/tmp/err + exit 1 + fi + done } do_test "$@" diff --git a/test/TEST-22-TMPFILES/test.sh b/test/TEST-22-TMPFILES/test.sh index 13e191bd92..5c509f63fb 100755 --- a/test/TEST-22-TMPFILES/test.sh +++ b/test/TEST-22-TMPFILES/test.sh @@ -1,6 +1,4 @@ #!/bin/bash -# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- -# ex: ts=8 sw=4 sts=4 et filetype=sh set -e TEST_DESCRIPTION="Tmpfiles related tests" TEST_NO_QEMU=1 diff --git a/test/TEST-23-TYPE-EXEC/test.sh b/test/TEST-23-TYPE-EXEC/test.sh index 2e76451f5b..6ed22be366 100755 --- a/test/TEST-23-TYPE-EXEC/test.sh +++ b/test/TEST-23-TYPE-EXEC/test.sh @@ -1,6 +1,4 @@ #!/bin/bash -# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- -# ex: ts=8 sw=4 sts=4 et filetype=sh set -e TEST_DESCRIPTION="test Type=exec" diff --git a/test/TEST-23-TYPE-EXEC/testsuite.sh b/test/TEST-23-TYPE-EXEC/testsuite.sh index 4f7cc44310..b161d97a7c 100755 --- a/test/TEST-23-TYPE-EXEC/testsuite.sh +++ b/test/TEST-23-TYPE-EXEC/testsuite.sh @@ -1,6 +1,4 @@ #!/bin/bash -# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- -# ex: ts=8 sw=4 sts=4 et filetype=sh set -ex set -o pipefail diff --git a/test/TEST-24-UNIT-TESTS/test.sh b/test/TEST-24-UNIT-TESTS/test.sh index fc8c89fe0a..038303edf8 100755 --- a/test/TEST-24-UNIT-TESTS/test.sh +++ b/test/TEST-24-UNIT-TESTS/test.sh @@ -1,6 +1,4 @@ #!/bin/bash -# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- -# ex: ts=8 sw=4 sts=4 et filetype=sh set -e TEST_DESCRIPTION="Run unit tests under containers" RUN_IN_UNPRIVILEGED_CONTAINER=yes diff --git a/test/TEST-24-UNIT-TESTS/testsuite.sh b/test/TEST-24-UNIT-TESTS/testsuite.sh index 7c7a068556..e33d04d043 100755 --- a/test/TEST-24-UNIT-TESTS/testsuite.sh +++ b/test/TEST-24-UNIT-TESTS/testsuite.sh @@ -1,6 +1,4 @@ #!/bin/bash -# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- -# ex: ts=8 sw=4 sts=4 et filetype=sh #set -ex #set -o pipefail diff --git a/test/TEST-25-IMPORT/test.sh b/test/TEST-25-IMPORT/test.sh index 188e7233bb..7fe367c3be 100755 --- a/test/TEST-25-IMPORT/test.sh +++ b/test/TEST-25-IMPORT/test.sh @@ -1,6 +1,4 @@ #!/bin/bash -# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- -# ex: ts=8 sw=4 sts=4 et filetype=sh set -e TEST_DESCRIPTION="test importd" diff --git a/test/TEST-25-IMPORT/testsuite.sh b/test/TEST-25-IMPORT/testsuite.sh index 2bb96f137d..380ba3d82d 100755 --- a/test/TEST-25-IMPORT/testsuite.sh +++ b/test/TEST-25-IMPORT/testsuite.sh @@ -1,6 +1,4 @@ #!/bin/bash -# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- -# ex: ts=8 sw=4 sts=4 et filetype=sh set -ex set -o pipefail diff --git a/test/TEST-26-SETENV/test.sh b/test/TEST-26-SETENV/test.sh index fb9c18926f..9a2913d330 100755 --- a/test/TEST-26-SETENV/test.sh +++ b/test/TEST-26-SETENV/test.sh @@ -1,6 +1,4 @@ #!/bin/bash -# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- -# ex: ts=8 sw=4 sts=4 et filetype=sh set -e TEST_DESCRIPTION="test setenv" diff --git a/test/TEST-26-SETENV/testsuite.sh b/test/TEST-26-SETENV/testsuite.sh index 2d93cb49c9..0abbf95326 100755 --- a/test/TEST-26-SETENV/testsuite.sh +++ b/test/TEST-26-SETENV/testsuite.sh @@ -1,6 +1,4 @@ #!/bin/bash -# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- -# ex: ts=8 sw=4 sts=4 et filetype=sh set -ex set -o pipefail diff --git a/test/TEST-27-STDOUTFILE/test.sh b/test/TEST-27-STDOUTFILE/test.sh index 724dbef231..fb35f80ec1 100755 --- a/test/TEST-27-STDOUTFILE/test.sh +++ b/test/TEST-27-STDOUTFILE/test.sh @@ -1,6 +1,4 @@ #!/bin/bash -# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- -# ex: ts=8 sw=4 sts=4 et filetype=sh set -e TEST_DESCRIPTION="test StandardOutput=file:" diff --git a/test/TEST-27-STDOUTFILE/testsuite.sh b/test/TEST-27-STDOUTFILE/testsuite.sh index 6975b7966f..2c813da720 100755 --- a/test/TEST-27-STDOUTFILE/testsuite.sh +++ b/test/TEST-27-STDOUTFILE/testsuite.sh @@ -1,13 +1,15 @@ #!/bin/bash -# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- -# ex: ts=8 sw=4 sts=4 et filetype=sh set -ex set -o pipefail systemd-analyze log-level debug systemd-analyze log-target console -systemd-run --wait --unit=one -p StandardOutput=file:/tmp/stdout -p StandardError=file:/tmp/stderr -p Type=exec sh -c 'echo x ; echo y >&2' +systemd-run --wait --unit=one \ + -p StandardOutput=file:/tmp/stdout \ + -p StandardError=file:/tmp/stderr \ + -p Type=exec \ + sh -c 'echo x ; echo y >&2' cmp /tmp/stdout <<EOF x EOF @@ -15,7 +17,11 @@ cmp /tmp/stderr <<EOF y EOF -systemd-run --wait --unit=two -p StandardOutput=file:/tmp/stdout -p StandardError=file:/tmp/stderr -p Type=exec sh -c 'echo z ; echo a >&2' +systemd-run --wait --unit=two \ + -p StandardOutput=file:/tmp/stdout \ + -p StandardError=file:/tmp/stderr \ + -p Type=exec \ + sh -c 'echo z ; echo a >&2' cmp /tmp/stdout <<EOF z EOF @@ -23,7 +29,11 @@ cmp /tmp/stderr <<EOF a EOF -systemd-run --wait --unit=three -p StandardOutput=append:/tmp/stdout -p StandardError=append:/tmp/stderr -p Type=exec sh -c 'echo b ; echo c >&2' +systemd-run --wait --unit=three \ + -p StandardOutput=append:/tmp/stdout \ + -p StandardError=append:/tmp/stderr \ + -p Type=exec \ + sh -c 'echo b ; echo c >&2' cmp /tmp/stdout <<EOF z b diff --git a/test/TEST-28-PERCENTJ-WANTEDBY/test.sh b/test/TEST-28-PERCENTJ-WANTEDBY/test.sh index 68935d0da0..67be1d51cc 100755 --- a/test/TEST-28-PERCENTJ-WANTEDBY/test.sh +++ b/test/TEST-28-PERCENTJ-WANTEDBY/test.sh @@ -1,6 +1,4 @@ #!/bin/bash -# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- -# ex: ts=8 sw=4 sts=4 et filetype=sh set -e TEST_DESCRIPTION="Ensure %j Wants directives work" RUN_IN_UNPRIVILEGED_CONTAINER=yes diff --git a/test/TEST-29-UDEV-ID_RENAMING/test.sh b/test/TEST-29-UDEV-ID_RENAMING/test.sh index 74362c052a..26ad2f902d 100755 --- a/test/TEST-29-UDEV-ID_RENAMING/test.sh +++ b/test/TEST-29-UDEV-ID_RENAMING/test.sh @@ -1,6 +1,4 @@ #!/bin/bash -# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- -# ex: ts=8 sw=4 sts=4 et filetype=sh set -e TEST_DESCRIPTION="UDEV ID_RENAMING property" TEST_NO_NSPAWN=1 diff --git a/test/TEST-29-UDEV-ID_RENAMING/testsuite.sh b/test/TEST-29-UDEV-ID_RENAMING/testsuite.sh index 9452c3a27b..eb9b2ffb89 100755 --- a/test/TEST-29-UDEV-ID_RENAMING/testsuite.sh +++ b/test/TEST-29-UDEV-ID_RENAMING/testsuite.sh @@ -1,6 +1,4 @@ #!/bin/bash -# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- -# ex: ts=8 sw=4 sts=4 et filetype=sh set -ex set -o pipefail diff --git a/test/TEST-30-ONCLOCKCHANGE/test.sh b/test/TEST-30-ONCLOCKCHANGE/test.sh index a9b3d78d6e..40e6ff25cd 100755 --- a/test/TEST-30-ONCLOCKCHANGE/test.sh +++ b/test/TEST-30-ONCLOCKCHANGE/test.sh @@ -1,6 +1,4 @@ #!/bin/bash -# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- -# ex: ts=8 sw=4 sts=4 et filetype=sh set -e TEST_DESCRIPTION="test OnClockChange= + OnTimezoneChange=" TEST_NO_NSPAWN=1 diff --git a/test/TEST-30-ONCLOCKCHANGE/testsuite.sh b/test/TEST-30-ONCLOCKCHANGE/testsuite.sh index 3f7c264000..7b24922e62 100755 --- a/test/TEST-30-ONCLOCKCHANGE/testsuite.sh +++ b/test/TEST-30-ONCLOCKCHANGE/testsuite.sh @@ -1,6 +1,4 @@ #!/bin/bash -# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- -# ex: ts=8 sw=4 sts=4 et filetype=sh set -ex set -o pipefail diff --git a/test/TEST-31-DEVICE-ENUMERATION/test.sh b/test/TEST-31-DEVICE-ENUMERATION/test.sh index d7cea73361..7156528873 100755 --- a/test/TEST-31-DEVICE-ENUMERATION/test.sh +++ b/test/TEST-31-DEVICE-ENUMERATION/test.sh @@ -1,6 +1,4 @@ #!/bin/bash -# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- -# ex: ts=8 sw=4 sts=4 et filetype=sh set -e TEST_DESCRIPTION="plugged -> dead -> plugged issue #11997" TEST_NO_NSPAWN=1 diff --git a/test/TEST-31-DEVICE-ENUMERATION/testsuite.sh b/test/TEST-31-DEVICE-ENUMERATION/testsuite.sh index cb12b51bd2..aa94d59bd3 100755 --- a/test/TEST-31-DEVICE-ENUMERATION/testsuite.sh +++ b/test/TEST-31-DEVICE-ENUMERATION/testsuite.sh @@ -1,6 +1,4 @@ #!/bin/bash -# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- -# ex: ts=8 sw=4 sts=4 et filetype=sh set -ex set -o pipefail diff --git a/test/run-integration-tests.sh b/test/run-integration-tests.sh index 0d2377128e..74fd64d24a 100755 --- a/test/run-integration-tests.sh +++ b/test/run-integration-tests.sh @@ -2,9 +2,9 @@ BUILD_DIR="$($(dirname "$0")/../tools/find-build-dir.sh)" if [ $# -gt 0 ]; then - args="$@" + args="$@" else - args="clean setup run clean-again" + args="clean setup run clean-again" fi ninja -C "$BUILD_DIR" @@ -16,35 +16,35 @@ FAILURES=0 cd "$(dirname "$0")" for TEST in TEST-??-* ; do - COUNT=$(($COUNT+1)) + COUNT=$(($COUNT+1)) - echo -e "\n--x-- Running $TEST --x--" - set +e - ( set -x ; make -C "$TEST" "BUILD_DIR=$BUILD_DIR" $args ) - RESULT=$? - set -e - echo "--x-- Result of $TEST: $RESULT --x--" + echo -e "\n--x-- Running $TEST --x--" + set +e + ( set -x ; make -C "$TEST" "BUILD_DIR=$BUILD_DIR" $args ) + RESULT=$? + set -e + echo "--x-- Result of $TEST: $RESULT --x--" - results["$TEST"]="$RESULT" + results["$TEST"]="$RESULT" - [ "$RESULT" -ne "0" ] && FAILURES=$(($FAILURES+1)) + [ "$RESULT" -ne "0" ] && FAILURES=$(($FAILURES+1)) done echo "" for TEST in ${!results[@]}; do - RESULT="${results[$TEST]}" - if [ "$RESULT" -eq "0" ] ; then - echo "$TEST: SUCCESS" - else - echo "$TEST: FAIL" - fi + RESULT="${results[$TEST]}" + if [ "$RESULT" -eq "0" ] ; then + echo "$TEST: SUCCESS" + else + echo "$TEST: FAIL" + fi done | sort if [ "$FAILURES" -eq 0 ] ; then - echo -e "\nALL $COUNT TESTS PASSED" + echo -e "\nALL $COUNT TESTS PASSED" else - echo -e "\nTOTAL FAILURES: $FAILURES OF $COUNT" + echo -e "\nTOTAL FAILURES: $FAILURES OF $COUNT" fi exit "$FAILURES" diff --git a/test/test-efi-create-disk.sh b/test/test-efi-create-disk.sh index 0216c83c12..592b20afcf 100755 --- a/test/test-efi-create-disk.sh +++ b/test/test-efi-create-disk.sh @@ -5,7 +5,7 @@ systemd_efi="$2" boot_stub="$3" splash_bmp="$4" if [ -z "$out" -o -z "$systemd_efi" -o -z "$boot_stub" -o -z "$splash_bmp" ]; then - exit 1 + exit 1 fi # create GPT table with EFI System Partition @@ -27,12 +27,12 @@ cp "$systemd_efi" mnt/EFI/BOOT/BOOTX64.efi mkdir mnt/EFI/Linux echo -n "foo=yes bar=no root=/dev/fakeroot debug rd.break=initqueue" >mnt/cmdline.txt objcopy \ - --add-section .osrel=/etc/os-release --change-section-vma .osrel=0x20000 \ - --add-section .cmdline=mnt/cmdline.txt --change-section-vma .cmdline=0x30000 \ - --add-section .splash="$splash_bmp" --change-section-vma .splash=0x40000 \ - --add-section .linux=/boot/$(cat /etc/machine-id)/$(uname -r)/linux --change-section-vma .linux=0x2000000 \ - --add-section .initrd=/boot/$(cat /etc/machine-id)/$(uname -r)/initrd --change-section-vma .initrd=0x3000000 \ - "$boot_stub" mnt/EFI/Linux/linux-test.efi + --add-section .osrel=/etc/os-release --change-section-vma .osrel=0x20000 \ + --add-section .cmdline=mnt/cmdline.txt --change-section-vma .cmdline=0x30000 \ + --add-section .splash="$splash_bmp" --change-section-vma .splash=0x40000 \ + --add-section .linux=/boot/$(cat /etc/machine-id)/$(uname -r)/linux --change-section-vma .linux=0x2000000 \ + --add-section .initrd=/boot/$(cat /etc/machine-id)/$(uname -r)/initrd --change-section-vma .initrd=0x3000000 \ + "$boot_stub" mnt/EFI/Linux/linux-test.efi # install entries mkdir -p mnt/loader/entries diff --git a/test/test-functions b/test/test-functions index 6016fd21ac..50c6e96902 100644 --- a/test/test-functions +++ b/test/test-functions @@ -159,15 +159,15 @@ run_qemu() { exit 1 fi -if [[ "$LOOKS_LIKE_SUSE" ]]; then - PARAMS+="rd.hostonly=0" -elif [[ "$LOOKS_LIKE_ARCH" ]]; then - PARAMS+="rw" -else - PARAMS+="ro" -fi + if [[ "$LOOKS_LIKE_SUSE" ]]; then + PARAMS+="rd.hostonly=0" + elif [[ "$LOOKS_LIKE_ARCH" ]]; then + PARAMS+="rw" + else + PARAMS+="ro" + fi -KERNEL_APPEND="$PARAMS \ + KERNEL_APPEND="$PARAMS \ root=/dev/sda1 \ raid=noautodetect \ loglevel=2 \ @@ -1639,7 +1639,7 @@ do_test() { exit 0 fi -# Detect lib paths + # Detect lib paths [[ $libdir ]] || for libdir in /lib64 /lib; do [[ -d $libdir ]] && libdirs+=" $libdir" && break done |