diff options
88 files changed, 806 insertions, 881 deletions
diff --git a/.dir-locals.el b/.dir-locals.el index 815afe172a..fde58d65bd 100644 --- a/.dir-locals.el +++ b/.dir-locals.el @@ -20,8 +20,8 @@ (nxml-mode . ((nxml-child-indent . 2) (fill-column . 109))) (meson-mode . ((meson-indent-basic . 8))) - (sh-mode . ((sh-basic-offset . 8) - (sh-indentation . 8))) + (sh-mode . ((sh-basic-offset . 4) + (sh-indentation . 4))) (awk-mode . ((c-basic-offset . 8))) (nil . ((indent-tabs-mode . nil) (tab-width . 8) diff --git a/.editorconfig b/.editorconfig index 67d848b68d..63b1d749cb 100644 --- a/.editorconfig +++ b/.editorconfig @@ -19,6 +19,10 @@ charset = utf-8 indent_style = space indent_size = 8 +[*.sh] +indent_style = space +indent_size = 4 + [meson.build] indent_style = space indent_size = 8 @@ -17,4 +17,5 @@ set expandtab set makeprg=GCC_COLORS=\ make set tw=79 au BufRead,BufNewFile *.xml set tw=109 shiftwidth=2 smarttab +au FileType sh set tw=80 shiftwidth=4 smarttab au FileType c set tw=109 diff --git a/coccinelle/run-coccinelle.sh b/coccinelle/run-coccinelle.sh index 22ab66d3dd..520de0ac42 100755 --- a/coccinelle/run-coccinelle.sh +++ b/coccinelle/run-coccinelle.sh @@ -5,23 +5,23 @@ files="$(git ls-files ':/*.[ch]')" args= case "$1" in - -i) - args="$args --in-place" - shift - ;; + -i) + args="$args --in-place" + shift + ;; esac if ! parallel -h >/dev/null; then - echo 'Please install GNU parallel (package "parallel")' - exit 1 + echo 'Please install GNU parallel (package "parallel")' + exit 1 fi for SCRIPT in ${@-$top/coccinelle/*.cocci} ; do - echo "--x-- Processing $SCRIPT --x--" - TMPFILE=`mktemp` - echo "+ spatch --sp-file $SCRIPT $args ..." - parallel --halt now,fail=1 --keep-order --noswap --max-args=20 \ - spatch --sp-file $SCRIPT $args ::: $files \ - 2>"$TMPFILE" || cat "$TMPFILE" - echo -e "--x-- Processed $SCRIPT --x--\n" + echo "--x-- Processing $SCRIPT --x--" + TMPFILE=`mktemp` + echo "+ spatch --sp-file $SCRIPT $args ..." + parallel --halt now,fail=1 --keep-order --noswap --max-args=20 \ + spatch --sp-file $SCRIPT $args ::: $files \ + 2>"$TMPFILE" || cat "$TMPFILE" + echo -e "--x-- Processed $SCRIPT --x--\n" done diff --git a/man/50-xdg-data-dirs.sh b/man/50-xdg-data-dirs.sh index 073174cb40..89e9fbb599 100755 --- a/man/50-xdg-data-dirs.sh +++ b/man/50-xdg-data-dirs.sh @@ -5,7 +5,7 @@ XDG_DATA_DIRS="${XDG_DATA_DIRS:-/usr/local/share/:/usr/share}" # add a directory if it exists if [[ -d /opt/foo/share ]]; then - XDG_DATA_DIRS=/opt/foo/share:${XDG_DATA_DIRS} + XDG_DATA_DIRS=/opt/foo/share:${XDG_DATA_DIRS} fi # write our output diff --git a/semaphoreci/gcc-compilation.sh b/semaphoreci/gcc-compilation.sh index 8755b850b6..ef499b8a35 100755 --- a/semaphoreci/gcc-compilation.sh +++ b/semaphoreci/gcc-compilation.sh @@ -1,5 +1,4 @@ #!/bin/bash - set -ex # keep this in sync with setup.sh @@ -40,4 +39,9 @@ dpkg-buildpackage -S -I -I$(basename "$SEMAPHORE_CACHE_DIR") -d -us -uc -nc # now build the package and run the tests rm -rf "$ARTIFACTS_DIR" # autopkgtest exits with 2 for "some tests skipped", accept that -$AUTOPKGTESTDIR/runner/autopkgtest --apt-upgrade --env DEB_BUILD_OPTIONS=noudeb --env TEST_UPSTREAM=1 ../systemd_*.dsc -o "$ARTIFACTS_DIR" -- lxc -s $CONTAINER || [ $? -eq 2 ] +$AUTOPKGTESTDIR/runner/autopkgtest --apt-upgrade \ + --env DEB_BUILD_OPTIONS=noudeb \ + --env TEST_UPSTREAM=1 ../systemd_*.dsc \ + -o "$ARTIFACTS_DIR" \ + -- lxc -s $CONTAINER \ + || [ $? -eq 2 ] diff --git a/semaphoreci/setup.sh b/semaphoreci/setup.sh index c904a300a1..c39238a4e9 100755 --- a/semaphoreci/setup.sh +++ b/semaphoreci/setup.sh @@ -1,5 +1,4 @@ #!/bin/bash - set -ex # default to Debian testing diff --git a/src/basic/generate-af-list.sh b/src/basic/generate-af-list.sh index 5bf244c49d..6987877ebf 100755 --- a/src/basic/generate-af-list.sh +++ b/src/basic/generate-af-list.sh @@ -2,5 +2,5 @@ set -eu $1 -E -dM -include sys/socket.h -include "$2" -include "$3" - </dev/null | \ - grep -Ev 'AF_UNSPEC|AF_MAX' | \ - awk '/^#define[ \t]+AF_[^ \t]+[ \t]+[AP]F_[^ \t]/ { print $2; }' + grep -Ev 'AF_UNSPEC|AF_MAX' | \ + awk '/^#define[ \t]+AF_[^ \t]+[ \t]+[AP]F_[^ \t]/ { print $2; }' diff --git a/src/basic/generate-arphrd-list.sh b/src/basic/generate-arphrd-list.sh index 6db931c52b..93cef47aa1 100755 --- a/src/basic/generate-arphrd-list.sh +++ b/src/basic/generate-arphrd-list.sh @@ -2,5 +2,5 @@ set -eu $1 -dM -include linux/if_arp.h -include "$2" - </dev/null | \ - awk '/^#define[ \t]+ARPHRD_[^ \t]+[ \t]+[^ \t]/ { print $2; }' | \ - sed -e 's/ARPHRD_//' + awk '/^#define[ \t]+ARPHRD_[^ \t]+[ \t]+[^ \t]/ { print $2; }' | \ + sed -e 's/ARPHRD_//' diff --git a/src/basic/generate-cap-list.sh b/src/basic/generate-cap-list.sh index 0628d2425f..b814fa8593 100755 --- a/src/basic/generate-cap-list.sh +++ b/src/basic/generate-cap-list.sh @@ -2,5 +2,5 @@ set -eu $1 -dM -include linux/capability.h -include "$2" -include "$3" - </dev/null | \ - awk '/^#define[ \t]+CAP_[A-Z_]+[ \t]+/ { print $2; }' | \ - grep -v CAP_LAST_CAP + awk '/^#define[ \t]+CAP_[A-Z_]+[ \t]+/ { print $2; }' | \ + grep -v CAP_LAST_CAP diff --git a/src/basic/generate-errno-list.sh b/src/basic/generate-errno-list.sh index 953d5e37b8..a4bb4d285d 100755 --- a/src/basic/generate-errno-list.sh +++ b/src/basic/generate-errno-list.sh @@ -2,4 +2,4 @@ set -eu $1 -dM -include errno.h - </dev/null | \ - awk '/^#define[ \t]+E[^ _]+[ \t]+/ { print $2; }' + awk '/^#define[ \t]+E[^ _]+[ \t]+/ { print $2; }' diff --git a/src/boot/efi/no-undefined-symbols.sh b/src/boot/efi/no-undefined-symbols.sh index 8572ceedfa..84cbd5b42b 100755 --- a/src/boot/efi/no-undefined-symbols.sh +++ b/src/boot/efi/no-undefined-symbols.sh @@ -2,6 +2,6 @@ set -eu if nm -D -u "$1" | grep ' U '; then - echo "Undefined symbols detected!" - exit 1 + echo "Undefined symbols detected!" + exit 1 fi diff --git a/src/journal/generate-audit_type-list.sh b/src/journal/generate-audit_type-list.sh index 2445a02668..912d0c9905 100755 --- a/src/journal/generate-audit_type-list.sh +++ b/src/journal/generate-audit_type-list.sh @@ -6,10 +6,10 @@ shift includes="" for i in "$@"; do - includes="$includes -include $i" + includes="$includes -include $i" done $cpp -dM $includes - </dev/null | \ - grep -vE 'AUDIT_.*(FIRST|LAST)_' | \ - sed -r -n 's/^#define\s+AUDIT_(\w+)\s+([0-9]{4})\s*$$/\1\t\2/p' | \ - sort -k2 + grep -vE 'AUDIT_.*(FIRST|LAST)_' | \ + sed -r -n 's/^#define\s+AUDIT_(\w+)\s+([0-9]{4})\s*$$/\1\t\2/p' | \ + sort -k2 diff --git a/src/shared/generate-ip-protocol-list.sh b/src/shared/generate-ip-protocol-list.sh index a9b1e0fb57..3f9197949f 100755 --- a/src/shared/generate-ip-protocol-list.sh +++ b/src/shared/generate-ip-protocol-list.sh @@ -2,5 +2,5 @@ set -eu $1 -dM -include netinet/in.h - </dev/null | \ - awk '/^#define[ \t]+IPPROTO_[^ \t]+[ \t]+[^ \t]/ { print $2; }' | \ - sed -e 's/IPPROTO_//' + awk '/^#define[ \t]+IPPROTO_[^ \t]+[ \t]+[^ \t]/ { print $2; }' | \ + sed -e 's/IPPROTO_//' diff --git a/src/udev/generate-keyboard-keys-gperf.sh b/src/udev/generate-keyboard-keys-gperf.sh index efb0da2a84..c78652a8e9 100755 --- a/src/udev/generate-keyboard-keys-gperf.sh +++ b/src/udev/generate-keyboard-keys-gperf.sh @@ -1,16 +1,18 @@ #!/bin/sh set -eu -awk ' BEGIN { - print "%{\n\ + +awk ' + BEGIN { + print "%{\n\ #if __GNUC__ >= 7\n\ _Pragma(\"GCC diagnostic ignored \\\"-Wimplicit-fallthrough\\\"\")\n\ #endif\n\ %}" - print "struct key_name { const char* name; unsigned short id; };" - print "%null-strings" - print "%%" - } + print "struct key_name { const char* name; unsigned short id; };" + print "%null-strings" + print "%%" + } - /^KEY_/ { print tolower(substr($1 ,5)) ", " $1 } - { print tolower($1) ", " $1 } + /^KEY_/ { print tolower(substr($1 ,5)) ", " $1 } + { print tolower($1) ", " $1 } ' < "$1" diff --git a/src/udev/generate-keyboard-keys-list.sh b/src/udev/generate-keyboard-keys-list.sh index c055f7c756..aa00c15c16 100755 --- a/src/udev/generate-keyboard-keys-list.sh +++ b/src/udev/generate-keyboard-keys-list.sh @@ -2,6 +2,6 @@ set -eu $1 -dM -include linux/input.h - </dev/null | awk ' - /\<(KEY_(MAX|MIN_INTERESTING))|(BTN_(MISC|MOUSE|JOYSTICK|GAMEPAD|DIGI|WHEEL|TRIGGER_HAPPY))\>/ { next } - /^#define[ \t]+(KEY|BTN)_[^ ]+[ \t]+[0-9BK]/ { print $2 } + /\<(KEY_(MAX|MIN_INTERESTING))|(BTN_(MISC|MOUSE|JOYSTICK|GAMEPAD|DIGI|WHEEL|TRIGGER_HAPPY))\>/ { next } + /^#define[ \t]+(KEY|BTN)_[^ ]+[ \t]+[0-9BK]/ { print $2 } ' 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 diff --git a/tools/add-git-hook.sh b/tools/add-git-hook.sh index c1db99b18a..5b1bf17219 100755 --- a/tools/add-git-hook.sh +++ b/tools/add-git-hook.sh @@ -4,7 +4,7 @@ set -eu cd "$MESON_SOURCE_ROOT" if [ ! -f .git/hooks/pre-commit.sample -o -f .git/hooks/pre-commit ]; then - exit 2 # not needed + exit 2 # not needed fi cp -p .git/hooks/pre-commit.sample .git/hooks/pre-commit diff --git a/tools/check-directives.sh b/tools/check-directives.sh index 99f8f9d451..e8c6e60040 100755 --- a/tools/check-directives.sh +++ b/tools/check-directives.sh @@ -1,5 +1,4 @@ #!/bin/bash - set -e function generate_directives() { @@ -12,18 +11,18 @@ function generate_directives() { ret=0 if [[ $(generate_directives src/network/networkd-network-gperf.gperf | wc -l) -ne $(wc -l <test/fuzz/fuzz-network-parser/directives.network) ]]; then - echo "Looks like test/fuzz/fuzz-network-parser/directives.network hasn't been updated" - ret=1 + echo "Looks like test/fuzz/fuzz-network-parser/directives.network hasn't been updated" + ret=1 fi if [[ $(generate_directives src/network/netdev/netdev-gperf.gperf | wc -l) -ne $(wc -l <test/fuzz/fuzz-netdev-parser/directives.netdev) ]]; then - echo "Looks like test/fuzz/fuzz-netdev-parser/directives.netdev hasn't been updated" - ret=1 + echo "Looks like test/fuzz/fuzz-netdev-parser/directives.netdev hasn't been updated" + ret=1 fi if [[ $(generate_directives src/udev/net/link-config-gperf.gperf | wc -l) -ne $(wc -l <test/fuzz/fuzz-link-parser/directives.link) ]]; then - echo "Looks like test/fuzz/fuzz-link-parser/directives.link hasn't been updated" - ret=1 + echo "Looks like test/fuzz/fuzz-link-parser/directives.link hasn't been updated" + ret=1 fi exit $ret diff --git a/tools/choose-default-locale.sh b/tools/choose-default-locale.sh index 3b3003835c..da9768ad7c 100755 --- a/tools/choose-default-locale.sh +++ b/tools/choose-default-locale.sh @@ -1,12 +1,11 @@ #!/bin/sh - set -e # Fedora uses C.utf8 but Debian uses C.UTF-8 if locale -a | grep -xq -E 'C\.(utf8|UTF-8)'; then - echo 'C.UTF-8' + echo 'C.UTF-8' elif locale -a | grep -xqF 'en_US.utf8'; then - echo 'en_US.UTF-8' + echo 'en_US.UTF-8' else - echo 'C' + echo 'C' fi diff --git a/tools/coverity.sh b/tools/coverity.sh index af4c920cd2..5842eeb81f 100755 --- a/tools/coverity.sh +++ b/tools/coverity.sh @@ -1,4 +1,4 @@ -#!/bin/env bash +#!/bin/bash # The official unmodified version of the script can be found at # https://scan.coverity.com/scripts/travisci_build_coverity_scan.sh @@ -24,32 +24,32 @@ echo -e "\033[33;1mNote: COVERITY_SCAN_PROJECT_NAME and COVERITY_SCAN_TOKEN are # Do not run on pull requests if [ "${TRAVIS_PULL_REQUEST}" = "true" ]; then - echo -e "\033[33;1mINFO: Skipping Coverity Analysis: branch is a pull request.\033[0m" - exit 0 + echo -e "\033[33;1mINFO: Skipping Coverity Analysis: branch is a pull request.\033[0m" + exit 0 fi # Verify this branch should run if [[ "${TRAVIS_BRANCH^^}" =~ "${COVERITY_SCAN_BRANCH_PATTERN^^}" ]]; then - echo -e "\033[33;1mCoverity Scan configured to run on branch ${TRAVIS_BRANCH}\033[0m" + echo -e "\033[33;1mCoverity Scan configured to run on branch ${TRAVIS_BRANCH}\033[0m" else - echo -e "\033[33;1mCoverity Scan NOT configured to run on branch ${TRAVIS_BRANCH}\033[0m" - exit 1 + echo -e "\033[33;1mCoverity Scan NOT configured to run on branch ${TRAVIS_BRANCH}\033[0m" + exit 1 fi # Verify upload is permitted AUTH_RES=`curl -s --form project="$COVERITY_SCAN_PROJECT_NAME" --form token="$COVERITY_SCAN_TOKEN" $SCAN_URL/api/upload_permitted` if [ "$AUTH_RES" = "Access denied" ]; then - echo -e "\033[33;1mCoverity Scan API access denied. Check COVERITY_SCAN_PROJECT_NAME and COVERITY_SCAN_TOKEN.\033[0m" - exit 1 -else - AUTH=`echo $AUTH_RES | python -c "import sys, json; print(json.load(sys.stdin)['upload_permitted'])"` - if [ "$AUTH" = "True" ]; then - echo -e "\033[33;1mCoverity Scan analysis authorized per quota.\033[0m" - else - WHEN=`echo $AUTH_RES | python -c "import sys, json; print(json.load(sys.stdin)['next_upload_permitted_at'])"` - echo -e "\033[33;1mCoverity Scan analysis NOT authorized until $WHEN.\033[0m" + echo -e "\033[33;1mCoverity Scan API access denied. Check COVERITY_SCAN_PROJECT_NAME and COVERITY_SCAN_TOKEN.\033[0m" exit 1 - fi +else + AUTH=`echo $AUTH_RES | python -c "import sys, json; print(json.load(sys.stdin)['upload_permitted'])"` + if [ "$AUTH" = "True" ]; then + echo -e "\033[33;1mCoverity Scan analysis authorized per quota.\033[0m" + else + WHEN=`echo $AUTH_RES | python -c "import sys, json; print(json.load(sys.stdin)['next_upload_permitted_at'])"` + echo -e "\033[33;1mCoverity Scan analysis NOT authorized until $WHEN.\033[0m" + exit 1 + fi fi TOOL_DIR=`find $TOOL_BASE -type d -name 'cov-analysis*'` @@ -62,8 +62,8 @@ export CCACHE_DISABLE=1 # -------------------- _help() { - # displays help and exits - cat <<-EOF + # displays help and exits + cat <<-EOF USAGE: $0 [CMD] [OPTIONS] CMD @@ -87,98 +87,98 @@ _help() -t, --tar ARCHIVE Use custom .tgz archive instead of intermediate directory or pre-archived .tgz (by default 'analysis-result.tgz' EOF - return; + return; } _pack() { - RESULTS_ARCHIVE=${RESULTS_ARCHIVE:-'analysis-results.tgz'} + RESULTS_ARCHIVE=${RESULTS_ARCHIVE:-'analysis-results.tgz'} - echo -e "\033[33;1mTarring Coverity Scan Analysis results...\033[0m" - tar czf $RESULTS_ARCHIVE $RESULTS_DIR - SHA=`git rev-parse --short HEAD` + echo -e "\033[33;1mTarring Coverity Scan Analysis results...\033[0m" + tar czf $RESULTS_ARCHIVE $RESULTS_DIR + SHA=`git rev-parse --short HEAD` - PACKED=true + PACKED=true } _build() { - echo -e "\033[33;1mRunning Coverity Scan Analysis Tool...\033[0m" - local _cov_build_options="" - #local _cov_build_options="--return-emit-failures 8 --parse-error-threshold 85" - eval "${COVERITY_SCAN_BUILD_COMMAND_PREPEND}" - COVERITY_UNSUPPORTED=1 cov-build --dir $RESULTS_DIR $_cov_build_options sh -c "$COVERITY_SCAN_BUILD_COMMAND" - cov-import-scm --dir $RESULTS_DIR --scm git --log $RESULTS_DIR/scm_log.txt - - if [ $? != 0 ]; then - echo -e "\033[33;1mCoverity Scan Build failed: $TEXT.\033[0m" - return 1 - fi - - [ -z $TAR ] || [ $TAR = false ] && return 0 - - if [ "$TAR" = true ]; then - _pack - fi + echo -e "\033[33;1mRunning Coverity Scan Analysis Tool...\033[0m" + local _cov_build_options="" + #local _cov_build_options="--return-emit-failures 8 --parse-error-threshold 85" + eval "${COVERITY_SCAN_BUILD_COMMAND_PREPEND}" + COVERITY_UNSUPPORTED=1 cov-build --dir $RESULTS_DIR $_cov_build_options sh -c "$COVERITY_SCAN_BUILD_COMMAND" + cov-import-scm --dir $RESULTS_DIR --scm git --log $RESULTS_DIR/scm_log.txt + + if [ $? != 0 ]; then + echo -e "\033[33;1mCoverity Scan Build failed: $TEXT.\033[0m" + return 1 + fi + + [ -z $TAR ] || [ $TAR = false ] && return 0 + + if [ "$TAR" = true ]; then + _pack + fi } _upload() { - # pack results - [ -z $PACKED ] || [ $PACKED = false ] && _pack - - # Upload results - echo -e "\033[33;1mUploading Coverity Scan Analysis results...\033[0m" - response=$(curl \ - --silent --write-out "\n%{http_code}\n" \ - --form project=$COVERITY_SCAN_PROJECT_NAME \ - --form token=$COVERITY_SCAN_TOKEN \ - --form email=$COVERITY_SCAN_NOTIFICATION_EMAIL \ - --form file=@$RESULTS_ARCHIVE \ - --form version=$SHA \ - --form description="Travis CI build" \ - $UPLOAD_URL) - printf "\033[33;1mThe response is\033[0m\n%s\n" "$response" - status_code=$(echo "$response" | sed -n '$p') - # Coverity Scan used to respond with 201 on successfully receieving analysis results. - # Now for some reason it sends 200 and may change back in the foreseeable future. - # See https://github.com/pmem/pmdk/commit/7b103fd2dd54b2e5974f71fb65c81ab3713c12c5 - if [ "$status_code" != "200" ]; then - TEXT=$(echo "$response" | sed '$d') - echo -e "\033[33;1mCoverity Scan upload failed: $TEXT.\033[0m" - exit 1 - fi - - echo -e "\n\033[33;1mCoverity Scan Analysis completed succesfully.\033[0m" - exit 0 + # pack results + [ -z $PACKED ] || [ $PACKED = false ] && _pack + + # Upload results + echo -e "\033[33;1mUploading Coverity Scan Analysis results...\033[0m" + response=$(curl \ + --silent --write-out "\n%{http_code}\n" \ + --form project=$COVERITY_SCAN_PROJECT_NAME \ + --form token=$COVERITY_SCAN_TOKEN \ + --form email=$COVERITY_SCAN_NOTIFICATION_EMAIL \ + --form file=@$RESULTS_ARCHIVE \ + --form version=$SHA \ + --form description="Travis CI build" \ + $UPLOAD_URL) + printf "\033[33;1mThe response is\033[0m\n%s\n" "$response" + status_code=$(echo "$response" | sed -n '$p') + # Coverity Scan used to respond with 201 on successfully receieving analysis results. + # Now for some reason it sends 200 and may change back in the foreseeable future. + # See https://github.com/pmem/pmdk/commit/7b103fd2dd54b2e5974f71fb65c81ab3713c12c5 + if [ "$status_code" != "200" ]; then + TEXT=$(echo "$response" | sed '$d') + echo -e "\033[33;1mCoverity Scan upload failed: $TEXT.\033[0m" + exit 1 + fi + + echo -e "\n\033[33;1mCoverity Scan Analysis completed succesfully.\033[0m" + exit 0 } # PARSE COMMAND LINE OPTIONS # -------------------------- case $1 in - -h|--help) - _help - exit 0 - ;; - build) - CMD='build' - TEMP=`getopt -o ho:t --long help,out-dir:,tar -n '$0' -- "$@"` - _ec=$? - [[ $_ec -gt 0 ]] && _help && exit $_ec - shift - ;; - upload) - CMD='upload' - TEMP=`getopt -o hd:t: --long help,result-dir:tar: -n '$0' -- "$@"` - _ec=$? - [[ $_ec -gt 0 ]] && _help && exit $_ec - shift - ;; - *) - _help && exit 1 ;; + -h|--help) + _help + exit 0 + ;; + build) + CMD='build' + TEMP=`getopt -o ho:t --long help,out-dir:,tar -n '$0' -- "$@"` + _ec=$? + [[ $_ec -gt 0 ]] && _help && exit $_ec + shift + ;; + upload) + CMD='upload' + TEMP=`getopt -o hd:t: --long help,result-dir:tar: -n '$0' -- "$@"` + _ec=$? + [[ $_ec -gt 0 ]] && _help && exit $_ec + shift + ;; + *) + _help && exit 1 ;; esac RESULTS_DIR='cov-int' @@ -188,46 +188,46 @@ if [ $? != 0 ] ; then exit 1 ; fi # extract options and their arguments into variables. if [[ $CMD == 'build' ]]; then - TAR=false - while true ; do - case $1 in - -h|--help) - _help - exit 0 - ;; - -o|--out-dir) - RESULTS_DIR="$2" - shift 2 - ;; - -t|--tar) - TAR=true - shift - ;; - --) _build; shift ; break ;; - *) echo "Internal error" ; _help && exit 6 ;; - esac - done + TAR=false + while true ; do + case $1 in + -h|--help) + _help + exit 0 + ;; + -o|--out-dir) + RESULTS_DIR="$2" + shift 2 + ;; + -t|--tar) + TAR=true + shift + ;; + --) _build; shift ; break ;; + *) echo "Internal error" ; _help && exit 6 ;; + esac + done elif [[ $CMD == 'upload' ]]; then - while true ; do - case $1 in - -h|--help) - _help - exit 0 - ;; - -d|--result-dir) - CHANGE_DEFAULT_DIR=true - RESULTS_DIR="$2" - shift 2 - ;; - -t|--tar) - RESULTS_ARCHIVE="$2" - [ -z $CHANGE_DEFAULT_DIR ] || [ $CHANGE_DEFAULT_DIR = false ] && PACKED=true - shift 2 - ;; - --) _upload; shift ; break ;; - *) echo "Internal error" ; _help && exit 6 ;; - esac - done + while true ; do + case $1 in + -h|--help) + _help + exit 0 + ;; + -d|--result-dir) + CHANGE_DEFAULT_DIR=true + RESULTS_DIR="$2" + shift 2 + ;; + -t|--tar) + RESULTS_ARCHIVE="$2" + [ -z $CHANGE_DEFAULT_DIR ] || [ $CHANGE_DEFAULT_DIR = false ] && PACKED=true + shift 2 + ;; + --) _upload; shift ; break ;; + *) echo "Internal error" ; _help && exit 6 ;; + esac + done fi diff --git a/tools/find-build-dir.sh b/tools/find-build-dir.sh index 06b6297ea5..fb8a1c17a3 100755 --- a/tools/find-build-dir.sh +++ b/tools/find-build-dir.sh @@ -5,28 +5,28 @@ set -e # we look for subdirectories of the parent directory that look like ninja build dirs. if [ -n "$BUILD_DIR" ]; then - echo "$(realpath "$BUILD_DIR")" - exit 0 + echo "$(realpath "$BUILD_DIR")" + exit 0 fi root="$(dirname "$(realpath "$0")")" found= for i in "$root"/../*/build.ninja; do - c="$(dirname $i)" - [ -d "$c" ] || continue - [ "$(basename "$c")" != mkosi.builddir ] || continue + c="$(dirname $i)" + [ -d "$c" ] || continue + [ "$(basename "$c")" != mkosi.builddir ] || continue - if [ -n "$found" ]; then - echo 'Found multiple candidates, specify build directory with $BUILD_DIR' >&2 - exit 2 - fi - found="$c" + if [ -n "$found" ]; then + echo 'Found multiple candidates, specify build directory with $BUILD_DIR' >&2 + exit 2 + fi + found="$c" done if [ -z "$found" ]; then - echo 'Specify build directory with $BUILD_DIR' >&2 - exit 1 + echo 'Specify build directory with $BUILD_DIR' >&2 + exit 1 fi echo "$(realpath $found)" diff --git a/tools/find-double-newline.sh b/tools/find-double-newline.sh index 6a6790b4b2..51204eb7c9 100755 --- a/tools/find-double-newline.sh +++ b/tools/find-double-newline.sh @@ -4,39 +4,38 @@ TOP=`git rev-parse --show-toplevel` case "$1" in - - recdiff) - if [ "$2" = "" ] ; then - DIR="$TOP" - else - DIR="$2" - fi - - find $DIR -type f \( -name '*.[ch]' -o -name '*.xml' \) -exec $0 diff \{\} \; - ;; - - recpatch) - if [ "$2" = "" ] ; then - DIR="$TOP" - else - DIR="$2" - fi - - find $DIR -type f \( -name '*.[ch]' -o -name '*.xml' \) -exec $0 patch \{\} \; - ;; - - diff) - T=`mktemp` - sed '/^$/N;/^\n$/D' < "$2" > "$T" - diff -u "$2" "$T" - rm -f "$T" - ;; - - patch) - sed -i '/^$/N;/^\n$/D' "$2" - ;; - - *) - echo "Expected recdiff|recpatch|diff|patch as verb." >&2 - ;; + recdiff) + if [ "$2" = "" ] ; then + DIR="$TOP" + else + DIR="$2" + fi + + find $DIR -type f \( -name '*.[ch]' -o -name '*.xml' \) -exec $0 diff \{\} \; + ;; + + recpatch) + if [ "$2" = "" ] ; then + DIR="$TOP" + else + DIR="$2" + fi + + find $DIR -type f \( -name '*.[ch]' -o -name '*.xml' \) -exec $0 patch \{\} \; + ;; + + diff) + T=`mktemp` + sed '/^$/N;/^\n$/D' < "$2" > "$T" + diff -u "$2" "$T" + rm -f "$T" + ;; + + patch) + sed -i '/^$/N;/^\n$/D' "$2" + ;; + + *) + echo "Expected recdiff|recpatch|diff|patch as verb." >&2 + ;; esac diff --git a/tools/find-tabs.sh b/tools/find-tabs.sh index e32eac8f32..95249f9c9c 100755 --- a/tools/find-tabs.sh +++ b/tools/find-tabs.sh @@ -4,39 +4,38 @@ TOP=`git rev-parse --show-toplevel` case "$1" in - - recdiff) - if [ "$2" = "" ] ; then - DIR="$TOP" - else - DIR="$2" - fi - - find $DIR -type f \( -name '*.[ch]' -o -name '*.xml' \) -exec $0 diff \{\} \; - ;; - - recpatch) - if [ "$2" = "" ] ; then - DIR="$TOP" - else - DIR="$2" - fi - - find $DIR -type f \( -name '*.[ch]' -o -name '*.xml' \) -exec $0 patch \{\} \; - ;; - - diff) - T=`mktemp` - sed 's/\t/ /g' < "$2" > "$T" - diff -u "$2" "$T" - rm -f "$T" - ;; - - patch) - sed -i 's/\t/ /g' "$2" - ;; - - *) - echo "Expected recdiff|recpatch|diff|patch as verb." >&2 - ;; + recdiff) + if [ "$2" = "" ] ; then + DIR="$TOP" + else + DIR="$2" + fi + + find $DIR -type f \( -name '*.[ch]' -o -name '*.xml' \) -exec $0 diff \{\} \; + ;; + + recpatch) + if [ "$2" = "" ] ; then + DIR="$TOP" + else + DIR="$2" + fi + + find $DIR -type f \( -name '*.[ch]' -o -name '*.xml' \) -exec $0 patch \{\} \; + ;; + + diff) + T=`mktemp` + sed 's/\t/ /g' < "$2" > "$T" + diff -u "$2" "$T" + rm -f "$T" + ;; + + patch) + sed -i 's/\t/ /g' "$2" + ;; + + *) + echo "Expected recdiff|recpatch|diff|patch as verb." >&2 + ;; esac diff --git a/tools/meson-apply-m4.sh b/tools/meson-apply-m4.sh index 6abe177ac5..5fad8cd94f 100755 --- a/tools/meson-apply-m4.sh +++ b/tools/meson-apply-m4.sh @@ -5,18 +5,18 @@ CONFIG=$1 TARGET=$2 if [ $# -ne 2 ]; then - echo 'Invalid number of arguments.' - exit 1 + echo 'Invalid number of arguments.' + exit 1 fi if [ ! -f $CONFIG ]; then - echo "$CONFIG not found." - exit 2 + echo "$CONFIG not found." + exit 2 fi if [ ! -f $TARGET ]; then - echo "$TARGET not found." - exit 3 + echo "$TARGET not found." + exit 3 fi DEFINES=$(awk '$1 == "#define" && $3 == "1" { printf "-D%s ", $2 }' $CONFIG) diff --git a/tools/meson-check-api-docs.sh b/tools/meson-check-api-docs.sh index a654368f9e..bd320562ad 100755 --- a/tools/meson-check-api-docs.sh +++ b/tools/meson-check-api-docs.sh @@ -1,5 +1,4 @@ #!/bin/sh - set -eu sd_good=0 @@ -8,27 +7,27 @@ udev_good=0 udev_total=0 for symbol in `nm -g --defined-only "$@" | grep " T " | cut -d" " -f3 | sort -u` ; do - if test -f ${MESON_BUILD_ROOT}/man/$symbol.3 ; then - echo "✓ Symbol $symbol() is documented." - good=1 - else - printf " \x1b[1;31mSymbol $symbol() lacks documentation.\x1b[0m\n" - good=0 - fi + if test -f ${MESON_BUILD_ROOT}/man/$symbol.3 ; then + echo "✓ Symbol $symbol() is documented." + good=1 + else + printf " \x1b[1;31mSymbol $symbol() lacks documentation.\x1b[0m\n" + good=0 + fi - case $symbol in - sd_*) - ((sd_good+=good)) - ((sd_total+=1)) - ;; - udev_*) - ((udev_good+=good)) - ((udev_total+=1)) - ;; - *) - echo 'unknown symbol prefix' - exit 1 - esac + case $symbol in + sd_*) + ((sd_good+=good)) + ((sd_total+=1)) + ;; + udev_*) + ((udev_good+=good)) + ((udev_total+=1)) + ;; + *) + echo 'unknown symbol prefix' + exit 1 + esac done echo "libsystemd: $sd_good/$sd_total libudev: $udev_good/$udev_total" diff --git a/tools/meson-check-help.sh b/tools/meson-check-help.sh index 69157105f2..a0e304ca9c 100755 --- a/tools/meson-check-help.sh +++ b/tools/meson-check-help.sh @@ -5,19 +5,19 @@ export SYSTEMD_LOG_LEVEL=info # output width if "$1" --help | grep -v 'default:' | grep -E -q '.{80}.'; then - echo "$(basename "$1") --help output is too wide:" - "$1" --help | awk 'length > 80' | grep -E --color=yes '.{80}' - exit 1 + echo "$(basename "$1") --help output is too wide:" + "$1" --help | awk 'length > 80' | grep -E --color=yes '.{80}' + exit 1 fi # no --help output to stdout if "$1" --help 2>&1 1>/dev/null | grep .; then - echo "$(basename "$1") --help prints to stderr" - exit 2 + echo "$(basename "$1") --help prints to stderr" + exit 2 fi # error output to stderr if ! "$1" --no-such-parameter 2>&1 1>/dev/null | grep -q .; then - echo "$(basename "$1") with an unknown parameter does not print to stderr" - exit 3 + echo "$(basename "$1") with an unknown parameter does not print to stderr" + exit 3 fi diff --git a/tools/meson-git-contrib.sh b/tools/meson-git-contrib.sh index 514daa0949..b40e97ba62 100755 --- a/tools/meson-git-contrib.sh +++ b/tools/meson-git-contrib.sh @@ -2,8 +2,8 @@ set -eu git shortlog -s `git describe --abbrev=0`.. | \ - cut -c8- | \ - sed 's/ / /g' | \ - awk '{ print $$0 "," }' | \ - sed -e 's/ / /g' | \ - sort -u + cut -c8- | \ + sed 's/ / /g' | \ + awk '{ print $$0 "," }' | \ + sed -e 's/ / /g' | \ + sort -u diff --git a/tools/meson-hwdb-update.sh b/tools/meson-hwdb-update.sh index 8bdc58ac7f..39efd75192 100755 --- a/tools/meson-hwdb-update.sh +++ b/tools/meson-hwdb-update.sh @@ -5,23 +5,23 @@ cd "$1" unset permissive if [ "${2:-}" = "-p" ]; then - permissive=1 - shift + permissive=1 + shift else - permissive=0 + permissive=0 fi if [ "${2:-}" != "-n" ]; then ( - [ -z "$permissive" ] || set +e - set -x + [ -z "$permissive" ] || set +e + set -x - curl -L -o usb.ids 'http://www.linux-usb.org/usb.ids' - curl -L -o pci.ids 'http://pci-ids.ucw.cz/v2.2/pci.ids' - curl -L -o ma-large.txt 'http://standards-oui.ieee.org/oui/oui.txt' - curl -L -o ma-medium.txt 'http://standards-oui.ieee.org/oui28/mam.txt' - curl -L -o ma-small.txt 'http://standards-oui.ieee.org/oui36/oui36.txt' - curl -L -o pnp_id_registry.html 'https://uefi.org/uefi-pnp-export' - curl -L -o acpi_id_registry.html 'https://uefi.org/uefi-acpi-export' + curl -L -o usb.ids 'http://www.linux-usb.org/usb.ids' + curl -L -o pci.ids 'http://pci-ids.ucw.cz/v2.2/pci.ids' + curl -L -o ma-large.txt 'http://standards-oui.ieee.org/oui/oui.txt' + curl -L -o ma-medium.txt 'http://standards-oui.ieee.org/oui28/mam.txt' + curl -L -o ma-small.txt 'http://standards-oui.ieee.org/oui36/oui36.txt' + curl -L -o pnp_id_registry.html 'https://uefi.org/uefi-pnp-export' + curl -L -o acpi_id_registry.html 'https://uefi.org/uefi-acpi-export' ) fi set -x diff --git a/tools/meson-make-symlink.sh b/tools/meson-make-symlink.sh index 501cd43d47..da0d13a341 100755 --- a/tools/meson-make-symlink.sh +++ b/tools/meson-make-symlink.sh @@ -6,7 +6,7 @@ set -eu mkdir -vp "$(dirname "${DESTDIR:-}$2")" if [ "$(dirname $1)" = . ]; then - ln -vfs -T "$1" "${DESTDIR:-}$2" + ln -vfs -T "$1" "${DESTDIR:-}$2" else - ln -vfs -T --relative "${DESTDIR:-}$1" "${DESTDIR:-}$2" + ln -vfs -T --relative "${DESTDIR:-}$1" "${DESTDIR:-}$2" fi diff --git a/tools/meson-vcs-tag.sh b/tools/meson-vcs-tag.sh index c8033d00a1..a8605b6bc9 100755 --- a/tools/meson-vcs-tag.sh +++ b/tools/meson-vcs-tag.sh @@ -8,8 +8,8 @@ tag="$2" fallback="$3" if [ -n "$tag" ]; then - echo "$tag" - exit 0 + echo "$tag" + exit 0 fi # Apparently git describe has a bug where it always considers the work-tree diff --git a/tools/oss-fuzz.sh b/tools/oss-fuzz.sh index 9a116be114..610bb9c235 100755 --- a/tools/oss-fuzz.sh +++ b/tools/oss-fuzz.sh @@ -29,7 +29,7 @@ mkdir -p $build fuzzflag="oss-fuzz=true" if [ -z "$FUZZING_ENGINE" ]; then - fuzzflag="llvm-fuzz=true" + fuzzflag="llvm-fuzz=true" fi meson $build -D$fuzzflag -Db_lundef=false @@ -38,7 +38,7 @@ ninja -C $build fuzzers # The seed corpus is a separate flat archive for each fuzzer, # with a fixed name ${fuzzer}_seed_corpus.zip. for d in "$(dirname "$0")/../test/fuzz/fuzz-"*; do - zip -jqr $OUT/$(basename "$d")_seed_corpus.zip "$d" + zip -jqr $OUT/$(basename "$d")_seed_corpus.zip "$d" done # get fuzz-dns-packet corpus diff --git a/travis-ci/managers/travis_wait.bash b/travis-ci/managers/travis_wait.bash index acf6ad15e4..59de6638d6 100644 --- a/travis-ci/managers/travis_wait.bash +++ b/travis-ci/managers/travis_wait.bash @@ -3,59 +3,59 @@ # as soon as Travis CI has started to provide an easy way to export the functions to bash scripts. travis_jigger() { - local cmd_pid="${1}" - shift - local timeout="${1}" - shift - local count=0 - - echo -e "\\n" - - while [[ "${count}" -lt "${timeout}" ]]; do - count="$((count + 1))" - echo -ne "Still running (${count} of ${timeout}): ${*}\\r" - sleep 60 - done - - echo -e "\\n${ANSI_RED}Timeout (${timeout} minutes) reached. Terminating \"${*}\"${ANSI_RESET}\\n" - kill -9 "${cmd_pid}" + local cmd_pid="${1}" + shift + local timeout="${1}" + shift + local count=0 + + echo -e "\\n" + + while [[ "${count}" -lt "${timeout}" ]]; do + count="$((count + 1))" + echo -ne "Still running (${count} of ${timeout}): ${*}\\r" + sleep 60 + done + + echo -e "\\n${ANSI_RED}Timeout (${timeout} minutes) reached. Terminating \"${*}\"${ANSI_RESET}\\n" + kill -9 "${cmd_pid}" } travis_wait() { - local timeout="${1}" - - if [[ "${timeout}" =~ ^[0-9]+$ ]]; then - shift - else - timeout=20 - fi - - local cmd=("${@}") - local log_file="travis_wait_${$}.log" - - "${cmd[@]}" &>"${log_file}" & - local cmd_pid="${!}" - - travis_jigger "${!}" "${timeout}" "${cmd[@]}" & - local jigger_pid="${!}" - local result - - { - set +e - wait "${cmd_pid}" 2>/dev/null - result="${?}" - ps -p"${jigger_pid}" &>/dev/null && kill "${jigger_pid}" - set -e - } - - if [[ "${result}" -eq 0 ]]; then - echo -e "\\n${ANSI_GREEN}The command ${cmd[*]} exited with ${result}.${ANSI_RESET}" - else - echo -e "\\n${ANSI_RED}The command ${cmd[*]} exited with ${result}.${ANSI_RESET}" - fi - - echo -e "\\n${ANSI_GREEN}Log:${ANSI_RESET}\\n" - cat "${log_file}" - - return "${result}" + local timeout="${1}" + + if [[ "${timeout}" =~ ^[0-9]+$ ]]; then + shift + else + timeout=20 + fi + + local cmd=("${@}") + local log_file="travis_wait_${$}.log" + + "${cmd[@]}" &>"${log_file}" & + local cmd_pid="${!}" + + travis_jigger "${!}" "${timeout}" "${cmd[@]}" & + local jigger_pid="${!}" + local result + + { + set +e + wait "${cmd_pid}" 2>/dev/null + result="${?}" + ps -p"${jigger_pid}" &>/dev/null && kill "${jigger_pid}" + set -e + } + + if [[ "${result}" -eq 0 ]]; then + echo -e "\\n${ANSI_GREEN}The command ${cmd[*]} exited with ${result}.${ANSI_RESET}" + else + echo -e "\\n${ANSI_RED}The command ${cmd[*]} exited with ${result}.${ANSI_RESET}" + fi + + echo -e "\\n${ANSI_GREEN}Log:${ANSI_RESET}\\n" + cat "${log_file}" + + return "${result}" } diff --git a/travis-ci/managers/xenial.sh b/travis-ci/managers/xenial.sh index af60114d34..4822bdd4b7 100755 --- a/travis-ci/managers/xenial.sh +++ b/travis-ci/managers/xenial.sh @@ -1,5 +1,4 @@ #!/bin/bash - set -e set -x diff --git a/travis-ci/scripts/build-docker-image.sh b/travis-ci/scripts/build-docker-image.sh index a18bf5fa85..69f9d69ce7 100755 --- a/travis-ci/scripts/build-docker-image.sh +++ b/travis-ci/scripts/build-docker-image.sh @@ -7,7 +7,7 @@ echo -e "\n\033[33;1mBuilding docker image: coverity-$TRAVIS_COMMIT.\033[0m" docker build \ ---build-arg DOCKER_USER=$USER \ ---build-arg DOCKER_USER_UID=`id -u` \ ---build-arg DOCKER_USER_GID=`id -g` \ ---force-rm -t coverity-${TRAVIS_COMMIT} --pull=true . + --build-arg DOCKER_USER=$USER \ + --build-arg DOCKER_USER_UID=`id -u` \ + --build-arg DOCKER_USER_GID=`id -g` \ + --force-rm -t coverity-${TRAVIS_COMMIT} --pull=true . diff --git a/travis-ci/tools/get-coverity.sh b/travis-ci/tools/get-coverity.sh index d364b541e2..3634e57ad6 100755 --- a/travis-ci/tools/get-coverity.sh +++ b/travis-ci/tools/get-coverity.sh @@ -18,18 +18,18 @@ sudo apt-get update && sudo apt-get -y install wget # Get coverity tool if [ ! -d $TOOL_BASE ]; then - # Download Coverity Scan Analysis Tool - if [ ! -e $TOOL_ARCHIVE ]; then - echo -e "\033[33;1mDownloading Coverity Scan Analysis Tool...\033[0m" - wget -nv -O $TOOL_ARCHIVE $TOOL_URL --post-data "project=$COVERITY_SCAN_PROJECT_NAME&token=$COVERITY_SCAN_TOKEN" - fi - - # Extract Coverity Scan Analysis Tool - echo -e "\033[33;1mExtracting Coverity Scan Analysis Tool...\033[0m" - mkdir -p $TOOL_BASE - pushd $TOOL_BASE - tar xzf $TOOL_ARCHIVE - popd + # Download Coverity Scan Analysis Tool + if [ ! -e $TOOL_ARCHIVE ]; then + echo -e "\033[33;1mDownloading Coverity Scan Analysis Tool...\033[0m" + wget -nv -O $TOOL_ARCHIVE $TOOL_URL --post-data "project=$COVERITY_SCAN_PROJECT_NAME&token=$COVERITY_SCAN_TOKEN" + fi + + # Extract Coverity Scan Analysis Tool + echo -e "\033[33;1mExtracting Coverity Scan Analysis Tool...\033[0m" + mkdir -p $TOOL_BASE + pushd $TOOL_BASE + tar xzf $TOOL_ARCHIVE + popd fi echo -e "\033[33;1mCoverity Scan Analysis Tool can be found at $TOOL_BASE ...\033[0m" diff --git a/units/meson-add-wants.sh b/units/meson-add-wants.sh index e2b260398c..a483d75b86 100755 --- a/units/meson-add-wants.sh +++ b/units/meson-add-wants.sh @@ -6,23 +6,23 @@ target="$2" unit="$3" case "$target" in - */?*) # a path, but not just a slash at the end - dir="${DESTDIR:-}${target}" - ;; - *) - dir="${DESTDIR:-}${unitdir}/${target}" - ;; + */?*) # a path, but not just a slash at the end + dir="${DESTDIR:-}${target}" + ;; + *) + dir="${DESTDIR:-}${unitdir}/${target}" + ;; esac unitpath="${DESTDIR:-}${unitdir}/${unit}" case "$target" in - */) - mkdir -vp -m 0755 "$dir" - ;; - *) - mkdir -vp -m 0755 "$(dirname "$dir")" - ;; + */) + mkdir -vp -m 0755 "$dir" + ;; + *) + mkdir -vp -m 0755 "$(dirname "$dir")" + ;; esac ln -vfs --relative "$unitpath" "$dir" diff --git a/xorg/50-systemd-user.sh b/xorg/50-systemd-user.sh index 5588185c50..bfee5f691c 100755 --- a/xorg/50-systemd-user.sh +++ b/xorg/50-systemd-user.sh @@ -3,5 +3,5 @@ systemctl --user import-environment DISPLAY XAUTHORITY if command -v dbus-update-activation-environment >/dev/null 2>&1; then - dbus-update-activation-environment DISPLAY XAUTHORITY + dbus-update-activation-environment DISPLAY XAUTHORITY fi |