scripts: use 4 space indentation

We had all kinds of indentation: 2 sp, 3 sp, 4 sp, 8 sp, and mixed.
4 sp was the most common, in particular the majority of scripts under test/
used that. Let's standarize on 4 sp, because many commandlines are long and
there's a lot of nesting, and with 8sp indentation less stuff fits. 4 sp
also seems to be the default indentation, so this will make it less likely
that people will mess up if they don't load the editor config. (I think people
often use vi, and vi has no support to load project-wide configuration
automatically. We distribute a .vimrc file, but it is not loaded by default,
and even the instructions in it seem to discourage its use for security
reasons.)

Also remove the few vim config lines that were left. We should either have them
on all files, or none.

Also remove some strange stuff like '#!/bin/env bash', yikes.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2019-04-04 14:10:42 +02:00
parent 408c9a07e5
commit cc5549ca12
88 changed files with 740 additions and 815 deletions

View File

@ -20,8 +20,8 @@
(nxml-mode . ((nxml-child-indent . 2) (nxml-mode . ((nxml-child-indent . 2)
(fill-column . 109))) (fill-column . 109)))
(meson-mode . ((meson-indent-basic . 8))) (meson-mode . ((meson-indent-basic . 8)))
(sh-mode . ((sh-basic-offset . 8) (sh-mode . ((sh-basic-offset . 4)
(sh-indentation . 8))) (sh-indentation . 4)))
(awk-mode . ((c-basic-offset . 8))) (awk-mode . ((c-basic-offset . 8)))
(nil . ((indent-tabs-mode . nil) (nil . ((indent-tabs-mode . nil)
(tab-width . 8) (tab-width . 8)

View File

@ -19,6 +19,10 @@ charset = utf-8
indent_style = space indent_style = space
indent_size = 8 indent_size = 8
[*.sh]
indent_style = space
indent_size = 4
[meson.build] [meson.build]
indent_style = space indent_style = space
indent_size = 8 indent_size = 8

1
.vimrc
View File

@ -17,4 +17,5 @@ set expandtab
set makeprg=GCC_COLORS=\ make set makeprg=GCC_COLORS=\ make
set tw=79 set tw=79
au BufRead,BufNewFile *.xml set tw=109 shiftwidth=2 smarttab 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 au FileType c set tw=109

View File

@ -5,23 +5,23 @@ files="$(git ls-files ':/*.[ch]')"
args= args=
case "$1" in case "$1" in
-i) -i)
args="$args --in-place" args="$args --in-place"
shift shift
;; ;;
esac esac
if ! parallel -h >/dev/null; then if ! parallel -h >/dev/null; then
echo 'Please install GNU parallel (package "parallel")' echo 'Please install GNU parallel (package "parallel")'
exit 1 exit 1
fi fi
for SCRIPT in ${@-$top/coccinelle/*.cocci} ; do for SCRIPT in ${@-$top/coccinelle/*.cocci} ; do
echo "--x-- Processing $SCRIPT --x--" echo "--x-- Processing $SCRIPT --x--"
TMPFILE=`mktemp` TMPFILE=`mktemp`
echo "+ spatch --sp-file $SCRIPT $args ..." echo "+ spatch --sp-file $SCRIPT $args ..."
parallel --halt now,fail=1 --keep-order --noswap --max-args=20 \ parallel --halt now,fail=1 --keep-order --noswap --max-args=20 \
spatch --sp-file $SCRIPT $args ::: $files \ spatch --sp-file $SCRIPT $args ::: $files \
2>"$TMPFILE" || cat "$TMPFILE" 2>"$TMPFILE" || cat "$TMPFILE"
echo -e "--x-- Processed $SCRIPT --x--\n" echo -e "--x-- Processed $SCRIPT --x--\n"
done done

View File

@ -5,7 +5,7 @@ XDG_DATA_DIRS="${XDG_DATA_DIRS:-/usr/local/share/:/usr/share}"
# add a directory if it exists # add a directory if it exists
if [[ -d /opt/foo/share ]]; then 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 fi
# write our output # write our output

View File

@ -1,5 +1,4 @@
#!/bin/bash #!/bin/bash
set -ex set -ex
# keep this in sync with setup.sh # 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 # now build the package and run the tests
rm -rf "$ARTIFACTS_DIR" rm -rf "$ARTIFACTS_DIR"
# autopkgtest exits with 2 for "some tests skipped", accept that # 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 ]

View File

@ -1,5 +1,4 @@
#!/bin/bash #!/bin/bash
set -ex set -ex
# default to Debian testing # default to Debian testing

View File

@ -2,5 +2,5 @@
set -eu set -eu
$1 -E -dM -include sys/socket.h -include "$2" -include "$3" - </dev/null | \ $1 -E -dM -include sys/socket.h -include "$2" -include "$3" - </dev/null | \
grep -Ev 'AF_UNSPEC|AF_MAX' | \ grep -Ev 'AF_UNSPEC|AF_MAX' | \
awk '/^#define[ \t]+AF_[^ \t]+[ \t]+[AP]F_[^ \t]/ { print $2; }' awk '/^#define[ \t]+AF_[^ \t]+[ \t]+[AP]F_[^ \t]/ { print $2; }'

View File

@ -2,5 +2,5 @@
set -eu set -eu
$1 -dM -include linux/if_arp.h -include "$2" - </dev/null | \ $1 -dM -include linux/if_arp.h -include "$2" - </dev/null | \
awk '/^#define[ \t]+ARPHRD_[^ \t]+[ \t]+[^ \t]/ { print $2; }' | \ awk '/^#define[ \t]+ARPHRD_[^ \t]+[ \t]+[^ \t]/ { print $2; }' | \
sed -e 's/ARPHRD_//' sed -e 's/ARPHRD_//'

View File

@ -2,5 +2,5 @@
set -eu set -eu
$1 -dM -include linux/capability.h -include "$2" -include "$3" - </dev/null | \ $1 -dM -include linux/capability.h -include "$2" -include "$3" - </dev/null | \
awk '/^#define[ \t]+CAP_[A-Z_]+[ \t]+/ { print $2; }' | \ awk '/^#define[ \t]+CAP_[A-Z_]+[ \t]+/ { print $2; }' | \
grep -v CAP_LAST_CAP grep -v CAP_LAST_CAP

View File

@ -2,4 +2,4 @@
set -eu set -eu
$1 -dM -include errno.h - </dev/null | \ $1 -dM -include errno.h - </dev/null | \
awk '/^#define[ \t]+E[^ _]+[ \t]+/ { print $2; }' awk '/^#define[ \t]+E[^ _]+[ \t]+/ { print $2; }'

View File

@ -2,6 +2,6 @@
set -eu set -eu
if nm -D -u "$1" | grep ' U '; then if nm -D -u "$1" | grep ' U '; then
echo "Undefined symbols detected!" echo "Undefined symbols detected!"
exit 1 exit 1
fi fi

View File

@ -6,10 +6,10 @@ shift
includes="" includes=""
for i in "$@"; do for i in "$@"; do
includes="$includes -include $i" includes="$includes -include $i"
done done
$cpp -dM $includes - </dev/null | \ $cpp -dM $includes - </dev/null | \
grep -vE 'AUDIT_.*(FIRST|LAST)_' | \ grep -vE 'AUDIT_.*(FIRST|LAST)_' | \
sed -r -n 's/^#define\s+AUDIT_(\w+)\s+([0-9]{4})\s*$$/\1\t\2/p' | \ sed -r -n 's/^#define\s+AUDIT_(\w+)\s+([0-9]{4})\s*$$/\1\t\2/p' | \
sort -k2 sort -k2

View File

@ -2,5 +2,5 @@
set -eu set -eu
$1 -dM -include netinet/in.h - </dev/null | \ $1 -dM -include netinet/in.h - </dev/null | \
awk '/^#define[ \t]+IPPROTO_[^ \t]+[ \t]+[^ \t]/ { print $2; }' | \ awk '/^#define[ \t]+IPPROTO_[^ \t]+[ \t]+[^ \t]/ { print $2; }' | \
sed -e 's/IPPROTO_//' sed -e 's/IPPROTO_//'

View File

@ -1,16 +1,18 @@
#!/bin/sh #!/bin/sh
set -eu set -eu
awk ' BEGIN {
print "%{\n\ awk '
BEGIN {
print "%{\n\
#if __GNUC__ >= 7\n\ #if __GNUC__ >= 7\n\
_Pragma(\"GCC diagnostic ignored \\\"-Wimplicit-fallthrough\\\"\")\n\ _Pragma(\"GCC diagnostic ignored \\\"-Wimplicit-fallthrough\\\"\")\n\
#endif\n\ #endif\n\
%}" %}"
print "struct key_name { const char* name; unsigned short id; };" print "struct key_name { const char* name; unsigned short id; };"
print "%null-strings" print "%null-strings"
print "%%" print "%%"
} }
/^KEY_/ { print tolower(substr($1 ,5)) ", " $1 } /^KEY_/ { print tolower(substr($1 ,5)) ", " $1 }
{ print tolower($1) ", " $1 } { print tolower($1) ", " $1 }
' < "$1" ' < "$1"

View File

@ -2,6 +2,6 @@
set -eu set -eu
$1 -dM -include linux/input.h - </dev/null | awk ' $1 -dM -include linux/input.h - </dev/null | awk '
/\<(KEY_(MAX|MIN_INTERESTING))|(BTN_(MISC|MOUSE|JOYSTICK|GAMEPAD|DIGI|WHEEL|TRIGGER_HAPPY))\>/ { next } /\<(KEY_(MAX|MIN_INTERESTING))|(BTN_(MISC|MOUSE|JOYSTICK|GAMEPAD|DIGI|WHEEL|TRIGGER_HAPPY))\>/ { next }
/^#define[ \t]+(KEY|BTN)_[^ ]+[ \t]+[0-9BK]/ { print $2 } /^#define[ \t]+(KEY|BTN)_[^ ]+[ \t]+[0-9BK]/ { print $2 }
' '

View File

@ -1,6 +1,4 @@
#!/bin/bash #!/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 set -e
TEST_DESCRIPTION="Basic systemd setup" TEST_DESCRIPTION="Basic systemd setup"
RUN_IN_UNPRIVILEGED_CONTAINER=${RUN_IN_UNPRIVILEGED_CONTAINER:-yes} RUN_IN_UNPRIVILEGED_CONTAINER=${RUN_IN_UNPRIVILEGED_CONTAINER:-yes}

View File

@ -1,6 +1,4 @@
#!/bin/bash #!/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 set -e
TEST_DESCRIPTION="cryptsetup systemd setup" TEST_DESCRIPTION="cryptsetup systemd setup"
TEST_NO_NSPAWN=1 TEST_NO_NSPAWN=1

View File

@ -1,6 +1,4 @@
#!/bin/bash #!/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 set -e
TEST_DESCRIPTION="Job-related tests" TEST_DESCRIPTION="Job-related tests"
TEST_NO_QEMU=1 TEST_NO_QEMU=1

View File

@ -1,5 +1,4 @@
#!/bin/bash #!/bin/bash
set -x set -x
set -e set -e
set -o pipefail set -o pipefail

View File

@ -1,6 +1,4 @@
#!/bin/bash #!/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 set -e
TEST_DESCRIPTION="Journal-related tests" TEST_DESCRIPTION="Journal-related tests"

View File

@ -1,5 +1,4 @@
#!/bin/bash #!/bin/bash
set -x set -x
set -e set -e
set -o pipefail set -o pipefail

View File

@ -1,6 +1,4 @@
#!/bin/bash #!/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 set -e
TEST_DESCRIPTION="Resource limits-related tests" TEST_DESCRIPTION="Resource limits-related tests"

View File

@ -1,5 +1,4 @@
#!/bin/bash #!/bin/bash
set -x set -x
set -e set -e
set -o pipefail set -o pipefail

View File

@ -1,6 +1,4 @@
#!/bin/bash #!/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 set -e
TEST_DESCRIPTION="SELinux tests" TEST_DESCRIPTION="SELinux tests"
TEST_NO_NSPAWN=1 TEST_NO_NSPAWN=1

View File

@ -1,5 +1,4 @@
#!/bin/bash #!/bin/bash
set -x set -x
set -e set -e

View File

@ -1,6 +1,4 @@
#!/bin/bash #!/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 set -e
TEST_DESCRIPTION="https://github.com/systemd/systemd/issues/1981" TEST_DESCRIPTION="https://github.com/systemd/systemd/issues/1981"
TEST_NO_QEMU=1 TEST_NO_QEMU=1

View File

@ -1,6 +1,4 @@
#!/bin/bash #!/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 set -e
TEST_DESCRIPTION="https://github.com/systemd/systemd/issues/2730" TEST_DESCRIPTION="https://github.com/systemd/systemd/issues/2730"
TEST_NO_NSPAWN=1 TEST_NO_NSPAWN=1

View File

@ -1,6 +1,4 @@
#!/bin/bash #!/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 set -e
TEST_DESCRIPTION="https://github.com/systemd/systemd/issues/2691" TEST_DESCRIPTION="https://github.com/systemd/systemd/issues/2691"
TEST_NO_NSPAWN=1 TEST_NO_NSPAWN=1

View File

@ -1,6 +1,4 @@
#!/bin/bash #!/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 set -e
TEST_DESCRIPTION="https://github.com/systemd/systemd/issues/2467" TEST_DESCRIPTION="https://github.com/systemd/systemd/issues/2467"

View File

@ -1,6 +1,4 @@
#!/bin/bash #!/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 set -e
TEST_DESCRIPTION="https://github.com/systemd/systemd/issues/3166" TEST_DESCRIPTION="https://github.com/systemd/systemd/issues/3166"
TEST_NO_NSPAWN=1 TEST_NO_NSPAWN=1

View File

@ -1,6 +1,4 @@
#!/bin/bash #!/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 set -e
TEST_DESCRIPTION="https://github.com/systemd/systemd/issues/3171" TEST_DESCRIPTION="https://github.com/systemd/systemd/issues/3171"
TEST_NO_QEMU=1 TEST_NO_QEMU=1

View File

@ -1,6 +1,4 @@
#!/bin/bash #!/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 set -e
TEST_DESCRIPTION="systemd-nspawn smoke test" TEST_DESCRIPTION="systemd-nspawn smoke test"
TEST_NO_NSPAWN=1 TEST_NO_NSPAWN=1

View File

@ -1,6 +1,4 @@
#!/bin/bash #!/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 set -e
TEST_DESCRIPTION="/etc/machine-id testing" TEST_DESCRIPTION="/etc/machine-id testing"
TEST_NO_NSPAWN=1 TEST_NO_NSPAWN=1

View File

@ -1,279 +1,278 @@
#! /bin/bash #! /bin/bash
set -e set -e
set -x set -x
_clear_service () { _clear_service () {
systemctl stop $1.service 2>/dev/null || : systemctl stop $1.service 2>/dev/null || :
rm -f /{etc,run,usr/lib}/systemd/system/$1.service 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.d
rm -fr /{etc,run,usr/lib}/systemd/system/$1.service.{wants,requires} rm -fr /{etc,run,usr/lib}/systemd/system/$1.service.{wants,requires}
} }
clear_services () { clear_services () {
for u in $*; do for u in $*; do
_clear_service $u _clear_service $u
done done
systemctl daemon-reload systemctl daemon-reload
} }
create_service () { create_service () {
clear_services $1 clear_services $1
cat >/etc/systemd/system/$1.service<<EOF cat >/etc/systemd/system/$1.service<<EOF
[Unit] [Unit]
Description=$1 unit Description=$1 unit
[Service] [Service]
ExecStart=/bin/sleep 100000 ExecStart=/bin/sleep 100000
EOF EOF
mkdir -p /{etc,run,usr/lib}/systemd/system/$1.service.d mkdir -p /{etc,run,usr/lib}/systemd/system/$1.service.d
mkdir -p /etc/systemd/system/$1.service.{wants,requires} mkdir -p /etc/systemd/system/$1.service.{wants,requires}
mkdir -p /run/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 /usr/lib/systemd/system/$1.service.{wants,requires}
} }
create_services () { create_services () {
for u in $*; do for u in $*; do
create_service $u create_service $u
done done
} }
check_ok () { check_ok () {
[ $# -eq 3 ] || return [ $# -eq 3 ] || return
x="$(systemctl show --value -p $2 $1)" x="$(systemctl show --value -p $2 $1)"
case "$x" in case "$x" in
*$3*) return 0 ;; *$3*) return 0 ;;
*) return 1 *) return 1 ;;
esac esac
} }
check_ko () { check_ko () {
! check_ok "$@" ! check_ok "$@"
} }
test_basic_dropins () { test_basic_dropins () {
echo "Testing basic dropins..." echo "Testing basic dropins..."
echo "*** test a wants b wants c" echo "*** test a wants b wants c"
create_services a b c create_services a b c
ln -s ../b.service /etc/systemd/system/a.service.wants/ ln -s ../b.service /etc/systemd/system/a.service.wants/
ln -s ../c.service /etc/systemd/system/b.service.wants/ ln -s ../c.service /etc/systemd/system/b.service.wants/
check_ok a Wants b.service check_ok a Wants b.service
check_ok b Wants c.service check_ok b Wants c.service
echo "*** test a wants,requires b" echo "*** test a wants,requires b"
create_services a b c create_services a b c
ln -s ../b.service /etc/systemd/system/a.service.wants/ ln -s ../b.service /etc/systemd/system/a.service.wants/
ln -s ../b.service /etc/systemd/system/a.service.requires/ ln -s ../b.service /etc/systemd/system/a.service.requires/
check_ok a Wants b.service check_ok a Wants b.service
check_ok a Requires b.service check_ok a Requires b.service
echo "*** test a wants nonexistent" echo "*** test a wants nonexistent"
create_service a create_service a
ln -s ../nonexistent.service /etc/systemd/system/a.service.wants/ ln -s ../nonexistent.service /etc/systemd/system/a.service.wants/
check_ok a Wants nonexistent.service check_ok a Wants nonexistent.service
systemctl start a systemctl start a
systemctl stop a systemctl stop a
echo "*** test a requires nonexistent" echo "*** test a requires nonexistent"
ln -sf ../nonexistent.service /etc/systemd/system/a.service.requires/ ln -sf ../nonexistent.service /etc/systemd/system/a.service.requires/
systemctl daemon-reload systemctl daemon-reload
check_ok a Requires nonexistent.service check_ok a Requires nonexistent.service
# 'b' is already loaded when 'c' pulls it in via a dropin. # 'b' is already loaded when 'c' pulls it in via a dropin.
echo "*** test a,c require b" echo "*** test a,c require b"
create_services a b c create_services a b c
ln -sf ../b.service /etc/systemd/system/a.service.requires/ ln -sf ../b.service /etc/systemd/system/a.service.requires/
ln -sf ../b.service /etc/systemd/system/c.service.requires/ ln -sf ../b.service /etc/systemd/system/c.service.requires/
systemctl start a systemctl start a
check_ok c Requires b.service check_ok c Requires b.service
systemctl stop a b systemctl stop a b
# 'b' is already loaded when 'c' pulls it in via an alias dropin. # 'b' is already loaded when 'c' pulls it in via an alias dropin.
echo "*** test a wants alias" echo "*** test a wants alias"
create_services a b c create_services a b c
ln -sf c.service /etc/systemd/system/c1.service ln -sf c.service /etc/systemd/system/c1.service
ln -sf ../c.service /etc/systemd/system/a.service.wants/ ln -sf ../c.service /etc/systemd/system/a.service.wants/
ln -sf ../c1.service /etc/systemd/system/b.service.wants/ ln -sf ../c1.service /etc/systemd/system/b.service.wants/
systemctl start a systemctl start a
check_ok a Wants c.service check_ok a Wants c.service
check_ok b Wants c.service check_ok b Wants c.service
systemctl stop a c systemctl stop a c
clear_services a b c clear_services a b c
} }
test_template_dropins () { 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 ln -s /etc/systemd/system/bar@.service /etc/systemd/system/foo.service.wants/bar@1.service
check_ok foo Wants bar@1.service check_ok foo Wants bar@1.service
clear_services foo bar@ yup@ clear_services foo bar@ yup@
} }
test_alias_dropins () { test_alias_dropins () {
echo "Testing alias dropins..." echo "Testing alias dropins..."
echo "*** test a wants b1 alias of b" echo "*** test a wants b1 alias of b"
create_services a b create_services a b
ln -sf b.service /etc/systemd/system/b1.service ln -sf b.service /etc/systemd/system/b1.service
ln -sf ../b1.service /etc/systemd/system/a.service.wants/ ln -sf ../b1.service /etc/systemd/system/a.service.wants/
check_ok a Wants b.service check_ok a Wants b.service
systemctl start a systemctl start a
systemctl --quiet is-active b systemctl --quiet is-active b
systemctl stop a b systemctl stop a b
rm /etc/systemd/system/b1.service rm /etc/systemd/system/b1.service
clear_services a b clear_services a b
# A weird behavior: the dependencies for 'a' may vary. It can be # A weird behavior: the dependencies for 'a' may vary. It can be
# changed by loading an alias... # changed by loading an alias...
# #
# [1] 'a1' is loaded and then "renamed" into 'a'. 'a1' is therefore # [1] 'a1' is loaded and then "renamed" into 'a'. 'a1' is therefore
# part of the names set so all its specific dropins are loaded. # 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 # [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). # none of its dropins are loaded ('y' is missing from the deps).
echo "*** test 2" echo "*** test 2"
create_services a x y create_services a x y
mkdir -p /etc/systemd/system/a1.service.wants/ mkdir -p /etc/systemd/system/a1.service.wants/
ln -sf a.service /etc/systemd/system/a1.service ln -sf a.service /etc/systemd/system/a1.service
ln -sf ../x.service /etc/systemd/system/a.service.wants/ ln -sf ../x.service /etc/systemd/system/a.service.wants/
ln -sf ../y.service /etc/systemd/system/a1.service.wants/ ln -sf ../y.service /etc/systemd/system/a1.service.wants/
check_ok a1 Wants x.service # see [1] check_ok a1 Wants x.service # see [1]
check_ok a1 Wants y.service check_ok a1 Wants y.service
systemctl start a systemctl start a
check_ok a1 Wants x.service # see [2] check_ok a1 Wants x.service # see [2]
check_ko a1 Wants y.service check_ko a1 Wants y.service
systemctl stop a x y systemctl stop a x y
rm /etc/systemd/system/a1.service rm /etc/systemd/system/a1.service
clear_services a x y clear_services a x y
} }
test_masked_dropins () { test_masked_dropins () {
echo "Testing masked dropins..." echo "Testing masked dropins..."
create_services a b create_services a b
# 'b' is masked for both deps # 'b' is masked for both deps
echo "*** test a wants,requires b is masked" 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.wants/b.service
ln -sf /dev/null /etc/systemd/system/a.service.requires/b.service ln -sf /dev/null /etc/systemd/system/a.service.requires/b.service
check_ko a Wants b.service check_ko a Wants b.service
check_ko a Requires b.service check_ko a Requires b.service
# 'a' wants 'b' and 'b' is masked at a lower level # 'a' wants 'b' and 'b' is masked at a lower level
echo "*** test a wants b, mask override" echo "*** test a wants b, mask override"
ln -sf ../b.service /etc/systemd/system/a.service.wants/b.service 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 ln -sf /dev/null /usr/lib/systemd/system/a.service.wants/b.service
check_ok a Wants b.service check_ok a Wants b.service
# 'a' wants 'b' and 'b' is masked at a higher level # 'a' wants 'b' and 'b' is masked at a higher level
echo "*** test a wants b, mask" echo "*** test a wants b, mask"
ln -sf /dev/null /etc/systemd/system/a.service.wants/b.service 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 ln -sf ../b.service /usr/lib/systemd/system/a.service.wants/b.service
check_ko a Wants b.service check_ko a Wants b.service
# 'a' is masked but has an override config file # 'a' is masked but has an override config file
echo "*** test a is masked but has an override" echo "*** test a is masked but has an override"
create_services a b create_services a b
ln -sf /dev/null /etc/systemd/system/a.service ln -sf /dev/null /etc/systemd/system/a.service
cat >/usr/lib/systemd/system/a.service.d/override.conf <<EOF cat >/usr/lib/systemd/system/a.service.d/override.conf <<EOF
[Unit] [Unit]
After=b.service After=b.service
EOF EOF
check_ok a UnitFileState masked check_ok a UnitFileState masked
# 'b1' is an alias for 'b': masking 'b' dep should not influence 'b1' dep # 'b1' is an alias for 'b': masking 'b' dep should not influence 'b1' dep
echo "*** test a wants b, b1, and one is masked" echo "*** test a wants b, b1, and one is masked"
create_services a b create_services a b
ln -sf b.service /etc/systemd/system/b1.service ln -sf b.service /etc/systemd/system/b1.service
ln -sf /dev/null /etc/systemd/system/a.service.wants/b.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 ln -sf ../b1.service /usr/lib/systemd/system/a.service.wants/b1.service
systemctl cat a systemctl cat a
systemctl show -p Wants,Requires a systemctl show -p Wants,Requires a
systemctl cat b1 systemctl cat b1
systemctl show -p Wants,Requires b1 systemctl show -p Wants,Requires b1
check_ok a 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 check_ko a Wants b1.service # the alias does not show up in the list of units
rm /etc/systemd/system/b1.service rm /etc/systemd/system/b1.service
# 'b1' is an alias for 'b': masking 'b1' should not influence 'b' dep # 'b1' is an alias for 'b': masking 'b1' should not influence 'b' dep
echo "*** test a wants b, alias dep is masked" echo "*** test a wants b, alias dep is masked"
create_services a b create_services a b
ln -sf b.service /etc/systemd/system/b1.service ln -sf b.service /etc/systemd/system/b1.service
ln -sf /dev/null /etc/systemd/system/a.service.wants/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 ln -sf ../b.service /usr/lib/systemd/system/a.service.wants/b.service
check_ok a 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 check_ko a Wants b1.service # the alias does not show up in the list of units
rm /etc/systemd/system/b1.service rm /etc/systemd/system/b1.service
# 'a' has Wants=b.service but also has a masking # 'a' has Wants=b.service but also has a masking
# dropin 'b': 'b' should still be pulled in. # dropin 'b': 'b' should still be pulled in.
echo "*** test a wants b both ways" echo "*** test a wants b both ways"
create_services a b create_services a b
ln -sf /dev/null /etc/systemd/system/a.service.wants/b.service ln -sf /dev/null /etc/systemd/system/a.service.wants/b.service
cat >/usr/lib/systemd/system/a.service.d/wants-b.conf<<EOF cat >/usr/lib/systemd/system/a.service.d/wants-b.conf<<EOF
[Unit] [Unit]
Wants=b.service Wants=b.service
EOF EOF
check_ok a Wants b.service check_ok a Wants b.service
# mask a dropin that points to an nonexistent unit. # mask a dropin that points to an nonexistent unit.
echo "*** test a wants nonexistent is masked" echo "*** test a wants nonexistent is masked"
create_services a create_services a
ln -sf /dev/null /etc/systemd/system/a.service.requires/nonexistent.service ln -sf /dev/null /etc/systemd/system/a.service.requires/nonexistent.service
ln -sf ../nonexistent.service /usr/lib/systemd/system/a.service.requires/ ln -sf ../nonexistent.service /usr/lib/systemd/system/a.service.requires/
check_ko a Requires nonexistent.service check_ko a Requires nonexistent.service
# 'b' is already loaded when 'c' pulls it in via a dropin but 'b' is # 'b' is already loaded when 'c' pulls it in via a dropin but 'b' is
# masked at a higher level. # masked at a higher level.
echo "*** test a wants b is masked" echo "*** test a wants b is masked"
create_services a b c create_services a b c
ln -sf ../b.service /etc/systemd/system/a.service.requires/ ln -sf ../b.service /etc/systemd/system/a.service.requires/
ln -sf ../b.service /run/systemd/system/c.service.requires/ ln -sf ../b.service /run/systemd/system/c.service.requires/
ln -sf /dev/null /etc/systemd/system/c.service.requires/b.service ln -sf /dev/null /etc/systemd/system/c.service.requires/b.service
systemctl start a systemctl start a
check_ko c Requires b.service check_ko c Requires b.service
systemctl stop a b systemctl stop a b
# 'b' is already loaded when 'c' pulls it in via a dropin but 'b' is # 'b' is already loaded when 'c' pulls it in via a dropin but 'b' is
# masked at a lower level. # masked at a lower level.
echo "*** test a requires b is masked" echo "*** test a requires b is masked"
create_services a b c create_services a b c
ln -sf ../b.service /etc/systemd/system/a.service.requires/ ln -sf ../b.service /etc/systemd/system/a.service.requires/
ln -sf ../b.service /etc/systemd/system/c.service.requires/ ln -sf ../b.service /etc/systemd/system/c.service.requires/
ln -sf /dev/null /run/systemd/system/c.service.requires/b.service ln -sf /dev/null /run/systemd/system/c.service.requires/b.service
systemctl start a systemctl start a
check_ok c Requires b.service check_ok c Requires b.service
systemctl stop a b systemctl stop a b
# 'a' requires 2 aliases of 'b' and one of them is a mask. # 'a' requires 2 aliases of 'b' and one of them is a mask.
echo "*** test a requires alias of b, other alias masked" echo "*** test a requires alias of b, other alias masked"
create_services a b create_services a b
ln -sf b.service /etc/systemd/system/b1.service ln -sf b.service /etc/systemd/system/b1.service
ln -sf b.service /etc/systemd/system/b2.service ln -sf b.service /etc/systemd/system/b2.service
ln -sf /dev/null /etc/systemd/system/a.service.requires/b1.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 ../b1.service /run/systemd/system/a.service.requires/
ln -sf ../b2.service /usr/lib/systemd/system/a.service.requires/ ln -sf ../b2.service /usr/lib/systemd/system/a.service.requires/
check_ok a Requires b check_ok a Requires b
# Same as above but now 'b' is masked. # Same as above but now 'b' is masked.
echo "*** test a requires alias of b, b dep masked" echo "*** test a requires alias of b, b dep masked"
create_services a b create_services a b
ln -sf b.service /etc/systemd/system/b1.service ln -sf b.service /etc/systemd/system/b1.service
ln -sf b.service /etc/systemd/system/b2.service ln -sf b.service /etc/systemd/system/b2.service
ln -sf ../b1.service /run/systemd/system/a.service.requires/ ln -sf ../b1.service /run/systemd/system/a.service.requires/
ln -sf ../b2.service /usr/lib/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 ln -sf /dev/null /etc/systemd/system/a.service.requires/b.service
check_ok a Requires b check_ok a Requires b
clear_services a b clear_services a b
} }
test_basic_dropins test_basic_dropins

View File

@ -1,6 +1,4 @@
#!/bin/bash #!/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 set -e
TEST_DESCRIPTION="Dropin tests" TEST_DESCRIPTION="Dropin tests"
TEST_NO_QEMU=1 TEST_NO_QEMU=1
@ -8,27 +6,27 @@ TEST_NO_QEMU=1
. $TEST_BASE_DIR/test-functions . $TEST_BASE_DIR/test-functions
test_setup() { test_setup() {
# create the basic filesystem layout # create the basic filesystem layout
setup_basic_environment setup_basic_environment
# mask some services that we do not want to run in these tests # 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-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-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.service
ln -s /dev/null $initdir/etc/systemd/system/systemd-networkd.socket ln -s /dev/null $initdir/etc/systemd/system/systemd-networkd.socket
ln -s /dev/null $initdir/etc/systemd/system/systemd-resolved.service ln -s /dev/null $initdir/etc/systemd/system/systemd-resolved.service
# import the test scripts in the rootfs and plug them in systemd # import the test scripts in the rootfs and plug them in systemd
cp testsuite.service $initdir/etc/systemd/system/ cp testsuite.service $initdir/etc/systemd/system/
cp test-dropin.sh $initdir/ cp test-dropin.sh $initdir/
setup_testsuite setup_testsuite
# create dedicated rootfs for nspawn (located in $TESTDIR/nspawn-root) # create dedicated rootfs for nspawn (located in $TESTDIR/nspawn-root)
setup_nspawn_root setup_nspawn_root
} }
test_cleanup() { test_cleanup() {
return 0 return 0
} }
do_test "$@" do_test "$@"

View File

@ -1,6 +1,4 @@
#!/bin/bash #!/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 set -e
TEST_DESCRIPTION="EXTEND_TIMEOUT_USEC=usec start/runtime/stop tests" TEST_DESCRIPTION="EXTEND_TIMEOUT_USEC=usec start/runtime/stop tests"
SKIP_INITRD=yes SKIP_INITRD=yes

View File

@ -1,6 +1,4 @@
#!/bin/bash #!/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 set -e
TEST_DESCRIPTION="UDEV SYSTEMD_WANTS property" TEST_DESCRIPTION="UDEV SYSTEMD_WANTS property"
TEST_NO_NSPAWN=1 TEST_NO_NSPAWN=1

View File

@ -1,6 +1,4 @@
#!/bin/bash #!/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 -ex
set -o pipefail set -o pipefail

View File

@ -1,6 +1,4 @@
#!/bin/bash #!/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 set -e
TEST_DESCRIPTION="FailureAction= operation" TEST_DESCRIPTION="FailureAction= operation"

View File

@ -1,6 +1,4 @@
#!/bin/bash #!/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 -ex
set -o pipefail set -o pipefail

View File

@ -1,6 +1,4 @@
#!/bin/bash #!/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 set -e
TEST_DESCRIPTION="test cgroup delegation in the unified hierarchy" TEST_DESCRIPTION="test cgroup delegation in the unified hierarchy"
TEST_NO_NSPAWN=1 TEST_NO_NSPAWN=1

View File

@ -1,39 +1,37 @@
#!/bin/bash #!/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 -ex
set -o pipefail set -o pipefail
if grep -q cgroup2 /proc/filesystems ; then if grep -q cgroup2 /proc/filesystems ; then
systemd-run --wait --unit=test0.service -p "DynamicUser=1" -p "Delegate=" \ systemd-run --wait --unit=test0.service -p "DynamicUser=1" -p "Delegate=" \
test -w /sys/fs/cgroup/system.slice/test0.service/ -a \ 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.procs -a \
-w /sys/fs/cgroup/system.slice/test0.service/cgroup.subtree_control -w /sys/fs/cgroup/system.slice/test0.service/cgroup.subtree_control
systemd-run --wait --unit=test1.service -p "DynamicUser=1" -p "Delegate=memory pids" \ 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 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" \ 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 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 # "io" is not among the controllers enabled by default for all units, verify that
grep -qv io /sys/fs/cgroup/system.slice/cgroup.controllers grep -qv io /sys/fs/cgroup/system.slice/cgroup.controllers
# Run a service with "io" enabled, and verify it works # 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" \ 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 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 # We want to check if "io" is removed again from the controllers
# list. However, PID 1 (rightfully) does this asynchronously. In order # list. However, PID 1 (rightfully) does this asynchronously. In order
# to force synchronization on this, let's start a short-lived service # 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 # which requires PID 1 to refresh the cgroup tree, so that we can
# verify that this all works. # verify that this all works.
systemd-run --wait --unit=test4.service true systemd-run --wait --unit=test4.service true
# And now check again, "io" should have vanished # And now check again, "io" should have vanished
grep -qv io /sys/fs/cgroup/system.slice/cgroup.controllers grep -qv io /sys/fs/cgroup/system.slice/cgroup.controllers
else 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 fi
echo OK > /testok echo OK > /testok

View File

@ -1,6 +1,4 @@
#!/bin/bash #!/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 set -e
TEST_DESCRIPTION="test changing main PID" TEST_DESCRIPTION="test changing main PID"

View File

@ -1,6 +1,4 @@
#!/bin/bash #!/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 -ex
set -o pipefail set -o pipefail

View File

@ -1,21 +1,19 @@
#!/bin/bash #!/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 set -e
TEST_DESCRIPTION="Sysuser-related tests" TEST_DESCRIPTION="Sysuser-related tests"
. $TEST_BASE_DIR/test-functions . $TEST_BASE_DIR/test-functions
test_setup() { 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() { prepare_testdir() {
rm -f $TESTDIR/etc/*{passwd,group,shadow} rm -f $TESTDIR/etc/*{passwd,group,shadow}
for i in $1.initial-{passwd,group,shadow}; do for i in $1.initial-{passwd,group,shadow}; do
test -f $i && cp $i $TESTDIR/etc/${i#*.initial-} test -f $i && cp $i $TESTDIR/etc/${i#*.initial-}
done done
return 0 return 0
} }
preprocess() { preprocess() {
@ -30,92 +28,92 @@ preprocess() {
compare() { compare() {
if ! diff -u $TESTDIR/etc/passwd <(preprocess ${1%.*}.expected-passwd); then if ! diff -u $TESTDIR/etc/passwd <(preprocess ${1%.*}.expected-passwd); then
echo "**** Unexpected output for $f" echo "**** Unexpected output for $f"
exit 1 exit 1
fi fi
if ! diff -u $TESTDIR/etc/group <(preprocess ${1%.*}.expected-group); then if ! diff -u $TESTDIR/etc/group <(preprocess ${1%.*}.expected-group); then
echo "**** Unexpected output for $f $2" echo "**** Unexpected output for $f $2"
exit 1 exit 1
fi fi
} }
test_run() { test_run() {
# ensure our build of systemd-sysusers is run # ensure our build of systemd-sysusers is run
PATH=${BUILD_DIR}:$PATH PATH=${BUILD_DIR}:$PATH
rm -f $TESTDIR/etc/sysusers.d/* $TESTDIR/usr/lib/sysusers.d/* rm -f $TESTDIR/etc/sysusers.d/* $TESTDIR/usr/lib/sysusers.d/*
# happy tests # happy tests
for f in test-*.input; do for f in test-*.input; do
echo "*** Running $f" echo "*** Running $f"
prepare_testdir ${f%.input} prepare_testdir ${f%.input}
cp $f $TESTDIR/usr/lib/sysusers.d/test.conf cp $f $TESTDIR/usr/lib/sysusers.d/test.conf
systemd-sysusers --root=$TESTDIR systemd-sysusers --root=$TESTDIR
compare $f "" compare $f ""
done done
for f in test-*.input; do for f in test-*.input; do
echo "*** Running $f on stdin" echo "*** Running $f on stdin"
prepare_testdir ${f%.input} prepare_testdir ${f%.input}
touch $TESTDIR/etc/sysusers.d/test.conf touch $TESTDIR/etc/sysusers.d/test.conf
cat $f | systemd-sysusers --root=$TESTDIR - cat $f | systemd-sysusers --root=$TESTDIR -
compare $f "on stdin" compare $f "on stdin"
done done
for f in test-*.input; do for f in test-*.input; do
echo "*** Running $f on stdin with --replace" echo "*** Running $f on stdin with --replace"
prepare_testdir ${f%.input} prepare_testdir ${f%.input}
touch $TESTDIR/etc/sysusers.d/test.conf touch $TESTDIR/etc/sysusers.d/test.conf
# this overrides test.conf which is masked on disk # this overrides test.conf which is masked on disk
cat $f | systemd-sysusers --root=$TESTDIR --replace=/etc/sysusers.d/test.conf - cat $f | systemd-sysusers --root=$TESTDIR --replace=/etc/sysusers.d/test.conf -
# this should be ignored # this should be ignored
cat test-1.input | systemd-sysusers --root=$TESTDIR --replace=/usr/lib/sysusers.d/test.conf - cat test-1.input | systemd-sysusers --root=$TESTDIR --replace=/usr/lib/sysusers.d/test.conf -
compare $f "on stdin with --replace" compare $f "on stdin with --replace"
done done
# test --inline # test --inline
echo "*** Testing --inline" echo "*** Testing --inline"
prepare_testdir prepare_testdir
# copy a random file to make sure it is ignored # copy a random file to make sure it is ignored
cp $f $TESTDIR/etc/sysusers.d/confuse.conf cp $f $TESTDIR/etc/sysusers.d/confuse.conf
systemd-sysusers --root=$TESTDIR --inline \ systemd-sysusers --root=$TESTDIR --inline \
"u u1 222 - - /bin/zsh" \ "u u1 222 - - /bin/zsh" \
"g g1 111" "g g1 111"
compare inline "(--inline)" compare inline "(--inline)"
# test --replace # test --replace
echo "*** Testing --inline with --replace" echo "*** Testing --inline with --replace"
prepare_testdir prepare_testdir
# copy a random file to make sure it is ignored # copy a random file to make sure it is ignored
cp $f $TESTDIR/etc/sysusers.d/confuse.conf cp $f $TESTDIR/etc/sysusers.d/confuse.conf
systemd-sysusers --root=$TESTDIR \ systemd-sysusers --root=$TESTDIR \
--inline \ --inline \
--replace=/etc/sysusers.d/confuse.conf \ --replace=/etc/sysusers.d/confuse.conf \
"u u1 222 - - /bin/zsh" \ "u u1 222 - - /bin/zsh" \
"g g1 111" "g g1 111"
compare inline "(--inline --replace=…)" compare inline "(--inline --replace=…)"
rm -f $TESTDIR/etc/sysusers.d/* $TESTDIR/usr/lib/sysusers.d/* rm -f $TESTDIR/etc/sysusers.d/* $TESTDIR/usr/lib/sysusers.d/*
# tests for error conditions # tests for error conditions
for f in unhappy-*.input; do for f in unhappy-*.input; do
echo "*** Running test $f" echo "*** Running test $f"
prepare_testdir ${f%.input} prepare_testdir ${f%.input}
cp $f $TESTDIR/usr/lib/sysusers.d/test.conf cp $f $TESTDIR/usr/lib/sysusers.d/test.conf
systemd-sysusers --root=$TESTDIR 2> /dev/null systemd-sysusers --root=$TESTDIR 2> /dev/null
journalctl -t systemd-sysusers -o cat | tail -n1 > $TESTDIR/tmp/err journalctl -t systemd-sysusers -o cat | tail -n1 > $TESTDIR/tmp/err
if ! diff -u $TESTDIR/tmp/err ${f%.*}.expected-err; then if ! diff -u $TESTDIR/tmp/err ${f%.*}.expected-err; then
echo "**** Unexpected error output for $f" echo "**** Unexpected error output for $f"
cat $TESTDIR/tmp/err cat $TESTDIR/tmp/err
exit 1 exit 1
fi fi
done done
} }
do_test "$@" do_test "$@"

View File

@ -1,6 +1,4 @@
#!/bin/bash #!/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 set -e
TEST_DESCRIPTION="Tmpfiles related tests" TEST_DESCRIPTION="Tmpfiles related tests"
TEST_NO_QEMU=1 TEST_NO_QEMU=1

View File

@ -1,6 +1,4 @@
#!/bin/bash #!/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 set -e
TEST_DESCRIPTION="test Type=exec" TEST_DESCRIPTION="test Type=exec"

View File

@ -1,6 +1,4 @@
#!/bin/bash #!/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 -ex
set -o pipefail set -o pipefail

View File

@ -1,6 +1,4 @@
#!/bin/bash #!/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 set -e
TEST_DESCRIPTION="Run unit tests under containers" TEST_DESCRIPTION="Run unit tests under containers"
RUN_IN_UNPRIVILEGED_CONTAINER=yes RUN_IN_UNPRIVILEGED_CONTAINER=yes

View File

@ -1,6 +1,4 @@
#!/bin/bash #!/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 -ex
#set -o pipefail #set -o pipefail

View File

@ -1,6 +1,4 @@
#!/bin/bash #!/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 set -e
TEST_DESCRIPTION="test importd" TEST_DESCRIPTION="test importd"

View File

@ -1,6 +1,4 @@
#!/bin/bash #!/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 -ex
set -o pipefail set -o pipefail

View File

@ -1,6 +1,4 @@
#!/bin/bash #!/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 set -e
TEST_DESCRIPTION="test setenv" TEST_DESCRIPTION="test setenv"

View File

@ -1,6 +1,4 @@
#!/bin/bash #!/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 -ex
set -o pipefail set -o pipefail

View File

@ -1,6 +1,4 @@
#!/bin/bash #!/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 set -e
TEST_DESCRIPTION="test StandardOutput=file:" TEST_DESCRIPTION="test StandardOutput=file:"

View File

@ -1,13 +1,15 @@
#!/bin/bash #!/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 -ex
set -o pipefail set -o pipefail
systemd-analyze log-level debug systemd-analyze log-level debug
systemd-analyze log-target console 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 cmp /tmp/stdout <<EOF
x x
EOF EOF
@ -15,7 +17,11 @@ cmp /tmp/stderr <<EOF
y y
EOF 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 cmp /tmp/stdout <<EOF
z z
EOF EOF
@ -23,7 +29,11 @@ cmp /tmp/stderr <<EOF
a a
EOF 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 cmp /tmp/stdout <<EOF
z z
b b

View File

@ -1,6 +1,4 @@
#!/bin/bash #!/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 set -e
TEST_DESCRIPTION="Ensure %j Wants directives work" TEST_DESCRIPTION="Ensure %j Wants directives work"
RUN_IN_UNPRIVILEGED_CONTAINER=yes RUN_IN_UNPRIVILEGED_CONTAINER=yes

View File

@ -1,6 +1,4 @@
#!/bin/bash #!/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 set -e
TEST_DESCRIPTION="UDEV ID_RENAMING property" TEST_DESCRIPTION="UDEV ID_RENAMING property"
TEST_NO_NSPAWN=1 TEST_NO_NSPAWN=1

View File

@ -1,6 +1,4 @@
#!/bin/bash #!/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 -ex
set -o pipefail set -o pipefail

View File

@ -1,6 +1,4 @@
#!/bin/bash #!/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 set -e
TEST_DESCRIPTION="test OnClockChange= + OnTimezoneChange=" TEST_DESCRIPTION="test OnClockChange= + OnTimezoneChange="
TEST_NO_NSPAWN=1 TEST_NO_NSPAWN=1

View File

@ -1,6 +1,4 @@
#!/bin/bash #!/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 -ex
set -o pipefail set -o pipefail

View File

@ -1,6 +1,4 @@
#!/bin/bash #!/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 set -e
TEST_DESCRIPTION="plugged -> dead -> plugged issue #11997" TEST_DESCRIPTION="plugged -> dead -> plugged issue #11997"
TEST_NO_NSPAWN=1 TEST_NO_NSPAWN=1

View File

@ -1,6 +1,4 @@
#!/bin/bash #!/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 -ex
set -o pipefail set -o pipefail

View File

@ -2,9 +2,9 @@
BUILD_DIR="$($(dirname "$0")/../tools/find-build-dir.sh)" BUILD_DIR="$($(dirname "$0")/../tools/find-build-dir.sh)"
if [ $# -gt 0 ]; then if [ $# -gt 0 ]; then
args="$@" args="$@"
else else
args="clean setup run clean-again" args="clean setup run clean-again"
fi fi
ninja -C "$BUILD_DIR" ninja -C "$BUILD_DIR"
@ -16,35 +16,35 @@ FAILURES=0
cd "$(dirname "$0")" cd "$(dirname "$0")"
for TEST in TEST-??-* ; do for TEST in TEST-??-* ; do
COUNT=$(($COUNT+1)) COUNT=$(($COUNT+1))
echo -e "\n--x-- Running $TEST --x--" echo -e "\n--x-- Running $TEST --x--"
set +e set +e
( set -x ; make -C "$TEST" "BUILD_DIR=$BUILD_DIR" $args ) ( set -x ; make -C "$TEST" "BUILD_DIR=$BUILD_DIR" $args )
RESULT=$? RESULT=$?
set -e set -e
echo "--x-- Result of $TEST: $RESULT --x--" 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 done
echo "" echo ""
for TEST in ${!results[@]}; do for TEST in ${!results[@]}; do
RESULT="${results[$TEST]}" RESULT="${results[$TEST]}"
if [ "$RESULT" -eq "0" ] ; then if [ "$RESULT" -eq "0" ] ; then
echo "$TEST: SUCCESS" echo "$TEST: SUCCESS"
else else
echo "$TEST: FAIL" echo "$TEST: FAIL"
fi fi
done | sort done | sort
if [ "$FAILURES" -eq 0 ] ; then if [ "$FAILURES" -eq 0 ] ; then
echo -e "\nALL $COUNT TESTS PASSED" echo -e "\nALL $COUNT TESTS PASSED"
else else
echo -e "\nTOTAL FAILURES: $FAILURES OF $COUNT" echo -e "\nTOTAL FAILURES: $FAILURES OF $COUNT"
fi fi
exit "$FAILURES" exit "$FAILURES"

View File

@ -5,7 +5,7 @@ systemd_efi="$2"
boot_stub="$3" boot_stub="$3"
splash_bmp="$4" splash_bmp="$4"
if [ -z "$out" -o -z "$systemd_efi" -o -z "$boot_stub" -o -z "$splash_bmp" ]; then if [ -z "$out" -o -z "$systemd_efi" -o -z "$boot_stub" -o -z "$splash_bmp" ]; then
exit 1 exit 1
fi fi
# create GPT table with EFI System Partition # create GPT table with EFI System Partition
@ -27,12 +27,12 @@ cp "$systemd_efi" mnt/EFI/BOOT/BOOTX64.efi
mkdir mnt/EFI/Linux mkdir mnt/EFI/Linux
echo -n "foo=yes bar=no root=/dev/fakeroot debug rd.break=initqueue" >mnt/cmdline.txt echo -n "foo=yes bar=no root=/dev/fakeroot debug rd.break=initqueue" >mnt/cmdline.txt
objcopy \ objcopy \
--add-section .osrel=/etc/os-release --change-section-vma .osrel=0x20000 \ --add-section .osrel=/etc/os-release --change-section-vma .osrel=0x20000 \
--add-section .cmdline=mnt/cmdline.txt --change-section-vma .cmdline=0x30000 \ --add-section .cmdline=mnt/cmdline.txt --change-section-vma .cmdline=0x30000 \
--add-section .splash="$splash_bmp" --change-section-vma .splash=0x40000 \ --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 .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 \ --add-section .initrd=/boot/$(cat /etc/machine-id)/$(uname -r)/initrd --change-section-vma .initrd=0x3000000 \
"$boot_stub" mnt/EFI/Linux/linux-test.efi "$boot_stub" mnt/EFI/Linux/linux-test.efi
# install entries # install entries
mkdir -p mnt/loader/entries mkdir -p mnt/loader/entries

View File

@ -159,15 +159,15 @@ run_qemu() {
exit 1 exit 1
fi fi
if [[ "$LOOKS_LIKE_SUSE" ]]; then if [[ "$LOOKS_LIKE_SUSE" ]]; then
PARAMS+="rd.hostonly=0" PARAMS+="rd.hostonly=0"
elif [[ "$LOOKS_LIKE_ARCH" ]]; then elif [[ "$LOOKS_LIKE_ARCH" ]]; then
PARAMS+="rw" PARAMS+="rw"
else else
PARAMS+="ro" PARAMS+="ro"
fi fi
KERNEL_APPEND="$PARAMS \ KERNEL_APPEND="$PARAMS \
root=/dev/sda1 \ root=/dev/sda1 \
raid=noautodetect \ raid=noautodetect \
loglevel=2 \ loglevel=2 \
@ -1639,7 +1639,7 @@ do_test() {
exit 0 exit 0
fi fi
# Detect lib paths # Detect lib paths
[[ $libdir ]] || for libdir in /lib64 /lib; do [[ $libdir ]] || for libdir in /lib64 /lib; do
[[ -d $libdir ]] && libdirs+=" $libdir" && break [[ -d $libdir ]] && libdirs+=" $libdir" && break
done done

View File

@ -4,7 +4,7 @@ set -eu
cd "$MESON_SOURCE_ROOT" cd "$MESON_SOURCE_ROOT"
if [ ! -f .git/hooks/pre-commit.sample -o -f .git/hooks/pre-commit ]; then if [ ! -f .git/hooks/pre-commit.sample -o -f .git/hooks/pre-commit ]; then
exit 2 # not needed exit 2 # not needed
fi fi
cp -p .git/hooks/pre-commit.sample .git/hooks/pre-commit cp -p .git/hooks/pre-commit.sample .git/hooks/pre-commit

View File

@ -1,5 +1,4 @@
#!/bin/bash #!/bin/bash
set -e set -e
function generate_directives() { function generate_directives() {
@ -12,18 +11,18 @@ function generate_directives() {
ret=0 ret=0
if [[ $(generate_directives src/network/networkd-network-gperf.gperf | wc -l) -ne $(wc -l <test/fuzz/fuzz-network-parser/directives.network) ]]; then 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" echo "Looks like test/fuzz/fuzz-network-parser/directives.network hasn't been updated"
ret=1 ret=1
fi fi
if [[ $(generate_directives src/network/netdev/netdev-gperf.gperf | wc -l) -ne $(wc -l <test/fuzz/fuzz-netdev-parser/directives.netdev) ]]; then 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" echo "Looks like test/fuzz/fuzz-netdev-parser/directives.netdev hasn't been updated"
ret=1 ret=1
fi fi
if [[ $(generate_directives src/udev/net/link-config-gperf.gperf | wc -l) -ne $(wc -l <test/fuzz/fuzz-link-parser/directives.link) ]]; then 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" echo "Looks like test/fuzz/fuzz-link-parser/directives.link hasn't been updated"
ret=1 ret=1
fi fi
exit $ret exit $ret

View File

@ -1,12 +1,11 @@
#!/bin/sh #!/bin/sh
set -e set -e
# Fedora uses C.utf8 but Debian uses C.UTF-8 # Fedora uses C.utf8 but Debian uses C.UTF-8
if locale -a | grep -xq -E 'C\.(utf8|UTF-8)'; then 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 elif locale -a | grep -xqF 'en_US.utf8'; then
echo 'en_US.UTF-8' echo 'en_US.UTF-8'
else else
echo 'C' echo 'C'
fi fi

View File

@ -1,4 +1,4 @@
#!/bin/env bash #!/bin/bash
# The official unmodified version of the script can be found at # The official unmodified version of the script can be found at
# https://scan.coverity.com/scripts/travisci_build_coverity_scan.sh # 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 # Do not run on pull requests
if [ "${TRAVIS_PULL_REQUEST}" = "true" ]; then if [ "${TRAVIS_PULL_REQUEST}" = "true" ]; then
echo -e "\033[33;1mINFO: Skipping Coverity Analysis: branch is a pull request.\033[0m" echo -e "\033[33;1mINFO: Skipping Coverity Analysis: branch is a pull request.\033[0m"
exit 0 exit 0
fi fi
# Verify this branch should run # Verify this branch should run
if [[ "${TRAVIS_BRANCH^^}" =~ "${COVERITY_SCAN_BRANCH_PATTERN^^}" ]]; then 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 else
echo -e "\033[33;1mCoverity Scan NOT configured to run on branch ${TRAVIS_BRANCH}\033[0m" echo -e "\033[33;1mCoverity Scan NOT configured to run on branch ${TRAVIS_BRANCH}\033[0m"
exit 1 exit 1
fi fi
# Verify upload is permitted # Verify upload is permitted
AUTH_RES=`curl -s --form project="$COVERITY_SCAN_PROJECT_NAME" --form token="$COVERITY_SCAN_TOKEN" $SCAN_URL/api/upload_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 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" 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"
exit 1 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 fi
TOOL_DIR=`find $TOOL_BASE -type d -name 'cov-analysis*'` TOOL_DIR=`find $TOOL_BASE -type d -name 'cov-analysis*'`
@ -62,8 +62,8 @@ export CCACHE_DISABLE=1
# -------------------- # --------------------
_help() _help()
{ {
# displays help and exits # displays help and exits
cat <<-EOF cat <<-EOF
USAGE: $0 [CMD] [OPTIONS] USAGE: $0 [CMD] [OPTIONS]
CMD CMD
@ -87,98 +87,98 @@ _help()
-t, --tar ARCHIVE Use custom .tgz archive instead of intermediate directory or pre-archived .tgz -t, --tar ARCHIVE Use custom .tgz archive instead of intermediate directory or pre-archived .tgz
(by default 'analysis-result.tgz' (by default 'analysis-result.tgz'
EOF EOF
return; return;
} }
_pack() _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" echo -e "\033[33;1mTarring Coverity Scan Analysis results...\033[0m"
tar czf $RESULTS_ARCHIVE $RESULTS_DIR tar czf $RESULTS_ARCHIVE $RESULTS_DIR
SHA=`git rev-parse --short HEAD` SHA=`git rev-parse --short HEAD`
PACKED=true PACKED=true
} }
_build() _build()
{ {
echo -e "\033[33;1mRunning Coverity Scan Analysis Tool...\033[0m" echo -e "\033[33;1mRunning Coverity Scan Analysis Tool...\033[0m"
local _cov_build_options="" local _cov_build_options=""
#local _cov_build_options="--return-emit-failures 8 --parse-error-threshold 85" #local _cov_build_options="--return-emit-failures 8 --parse-error-threshold 85"
eval "${COVERITY_SCAN_BUILD_COMMAND_PREPEND}" eval "${COVERITY_SCAN_BUILD_COMMAND_PREPEND}"
COVERITY_UNSUPPORTED=1 cov-build --dir $RESULTS_DIR $_cov_build_options sh -c "$COVERITY_SCAN_BUILD_COMMAND" 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 cov-import-scm --dir $RESULTS_DIR --scm git --log $RESULTS_DIR/scm_log.txt
if [ $? != 0 ]; then if [ $? != 0 ]; then
echo -e "\033[33;1mCoverity Scan Build failed: $TEXT.\033[0m" echo -e "\033[33;1mCoverity Scan Build failed: $TEXT.\033[0m"
return 1 return 1
fi fi
[ -z $TAR ] || [ $TAR = false ] && return 0 [ -z $TAR ] || [ $TAR = false ] && return 0
if [ "$TAR" = true ]; then if [ "$TAR" = true ]; then
_pack _pack
fi fi
} }
_upload() _upload()
{ {
# pack results # pack results
[ -z $PACKED ] || [ $PACKED = false ] && _pack [ -z $PACKED ] || [ $PACKED = false ] && _pack
# Upload results # Upload results
echo -e "\033[33;1mUploading Coverity Scan Analysis results...\033[0m" echo -e "\033[33;1mUploading Coverity Scan Analysis results...\033[0m"
response=$(curl \ response=$(curl \
--silent --write-out "\n%{http_code}\n" \ --silent --write-out "\n%{http_code}\n" \
--form project=$COVERITY_SCAN_PROJECT_NAME \ --form project=$COVERITY_SCAN_PROJECT_NAME \
--form token=$COVERITY_SCAN_TOKEN \ --form token=$COVERITY_SCAN_TOKEN \
--form email=$COVERITY_SCAN_NOTIFICATION_EMAIL \ --form email=$COVERITY_SCAN_NOTIFICATION_EMAIL \
--form file=@$RESULTS_ARCHIVE \ --form file=@$RESULTS_ARCHIVE \
--form version=$SHA \ --form version=$SHA \
--form description="Travis CI build" \ --form description="Travis CI build" \
$UPLOAD_URL) $UPLOAD_URL)
printf "\033[33;1mThe response is\033[0m\n%s\n" "$response" printf "\033[33;1mThe response is\033[0m\n%s\n" "$response"
status_code=$(echo "$response" | sed -n '$p') status_code=$(echo "$response" | sed -n '$p')
# Coverity Scan used to respond with 201 on successfully receieving analysis results. # 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. # Now for some reason it sends 200 and may change back in the foreseeable future.
# See https://github.com/pmem/pmdk/commit/7b103fd2dd54b2e5974f71fb65c81ab3713c12c5 # See https://github.com/pmem/pmdk/commit/7b103fd2dd54b2e5974f71fb65c81ab3713c12c5
if [ "$status_code" != "200" ]; then if [ "$status_code" != "200" ]; then
TEXT=$(echo "$response" | sed '$d') TEXT=$(echo "$response" | sed '$d')
echo -e "\033[33;1mCoverity Scan upload failed: $TEXT.\033[0m" echo -e "\033[33;1mCoverity Scan upload failed: $TEXT.\033[0m"
exit 1 exit 1
fi fi
echo -e "\n\033[33;1mCoverity Scan Analysis completed succesfully.\033[0m" echo -e "\n\033[33;1mCoverity Scan Analysis completed succesfully.\033[0m"
exit 0 exit 0
} }
# PARSE COMMAND LINE OPTIONS # PARSE COMMAND LINE OPTIONS
# -------------------------- # --------------------------
case $1 in case $1 in
-h|--help) -h|--help)
_help _help
exit 0 exit 0
;; ;;
build) build)
CMD='build' CMD='build'
TEMP=`getopt -o ho:t --long help,out-dir:,tar -n '$0' -- "$@"` TEMP=`getopt -o ho:t --long help,out-dir:,tar -n '$0' -- "$@"`
_ec=$? _ec=$?
[[ $_ec -gt 0 ]] && _help && exit $_ec [[ $_ec -gt 0 ]] && _help && exit $_ec
shift shift
;; ;;
upload) upload)
CMD='upload' CMD='upload'
TEMP=`getopt -o hd:t: --long help,result-dir:tar: -n '$0' -- "$@"` TEMP=`getopt -o hd:t: --long help,result-dir:tar: -n '$0' -- "$@"`
_ec=$? _ec=$?
[[ $_ec -gt 0 ]] && _help && exit $_ec [[ $_ec -gt 0 ]] && _help && exit $_ec
shift shift
;; ;;
*) *)
_help && exit 1 ;; _help && exit 1 ;;
esac esac
RESULTS_DIR='cov-int' RESULTS_DIR='cov-int'
@ -188,46 +188,46 @@ if [ $? != 0 ] ; then exit 1 ; fi
# extract options and their arguments into variables. # extract options and their arguments into variables.
if [[ $CMD == 'build' ]]; then if [[ $CMD == 'build' ]]; then
TAR=false TAR=false
while true ; do while true ; do
case $1 in case $1 in
-h|--help) -h|--help)
_help _help
exit 0 exit 0
;; ;;
-o|--out-dir) -o|--out-dir)
RESULTS_DIR="$2" RESULTS_DIR="$2"
shift 2 shift 2
;; ;;
-t|--tar) -t|--tar)
TAR=true TAR=true
shift shift
;; ;;
--) _build; shift ; break ;; --) _build; shift ; break ;;
*) echo "Internal error" ; _help && exit 6 ;; *) echo "Internal error" ; _help && exit 6 ;;
esac esac
done done
elif [[ $CMD == 'upload' ]]; then elif [[ $CMD == 'upload' ]]; then
while true ; do while true ; do
case $1 in case $1 in
-h|--help) -h|--help)
_help _help
exit 0 exit 0
;; ;;
-d|--result-dir) -d|--result-dir)
CHANGE_DEFAULT_DIR=true CHANGE_DEFAULT_DIR=true
RESULTS_DIR="$2" RESULTS_DIR="$2"
shift 2 shift 2
;; ;;
-t|--tar) -t|--tar)
RESULTS_ARCHIVE="$2" RESULTS_ARCHIVE="$2"
[ -z $CHANGE_DEFAULT_DIR ] || [ $CHANGE_DEFAULT_DIR = false ] && PACKED=true [ -z $CHANGE_DEFAULT_DIR ] || [ $CHANGE_DEFAULT_DIR = false ] && PACKED=true
shift 2 shift 2
;; ;;
--) _upload; shift ; break ;; --) _upload; shift ; break ;;
*) echo "Internal error" ; _help && exit 6 ;; *) echo "Internal error" ; _help && exit 6 ;;
esac esac
done done
fi fi

View File

@ -5,28 +5,28 @@ set -e
# we look for subdirectories of the parent directory that look like ninja build dirs. # we look for subdirectories of the parent directory that look like ninja build dirs.
if [ -n "$BUILD_DIR" ]; then if [ -n "$BUILD_DIR" ]; then
echo "$(realpath "$BUILD_DIR")" echo "$(realpath "$BUILD_DIR")"
exit 0 exit 0
fi fi
root="$(dirname "$(realpath "$0")")" root="$(dirname "$(realpath "$0")")"
found= found=
for i in "$root"/../*/build.ninja; do for i in "$root"/../*/build.ninja; do
c="$(dirname $i)" c="$(dirname $i)"
[ -d "$c" ] || continue [ -d "$c" ] || continue
[ "$(basename "$c")" != mkosi.builddir ] || continue [ "$(basename "$c")" != mkosi.builddir ] || continue
if [ -n "$found" ]; then if [ -n "$found" ]; then
echo 'Found multiple candidates, specify build directory with $BUILD_DIR' >&2 echo 'Found multiple candidates, specify build directory with $BUILD_DIR' >&2
exit 2 exit 2
fi fi
found="$c" found="$c"
done done
if [ -z "$found" ]; then if [ -z "$found" ]; then
echo 'Specify build directory with $BUILD_DIR' >&2 echo 'Specify build directory with $BUILD_DIR' >&2
exit 1 exit 1
fi fi
echo "$(realpath $found)" echo "$(realpath $found)"

View File

@ -4,39 +4,38 @@
TOP=`git rev-parse --show-toplevel` TOP=`git rev-parse --show-toplevel`
case "$1" in case "$1" in
recdiff)
if [ "$2" = "" ] ; then
DIR="$TOP"
else
DIR="$2"
fi
recdiff) find $DIR -type f \( -name '*.[ch]' -o -name '*.xml' \) -exec $0 diff \{\} \;
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
recpatch) find $DIR -type f \( -name '*.[ch]' -o -name '*.xml' \) -exec $0 patch \{\} \;
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"
;;
diff) patch)
T=`mktemp` sed -i '/^$/N;/^\n$/D' "$2"
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
;; ;;
*)
echo "Expected recdiff|recpatch|diff|patch as verb." >&2
;;
esac esac

View File

@ -4,39 +4,38 @@
TOP=`git rev-parse --show-toplevel` TOP=`git rev-parse --show-toplevel`
case "$1" in case "$1" in
recdiff)
if [ "$2" = "" ] ; then
DIR="$TOP"
else
DIR="$2"
fi
recdiff) find $DIR -type f \( -name '*.[ch]' -o -name '*.xml' \) -exec $0 diff \{\} \;
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
recpatch) find $DIR -type f \( -name '*.[ch]' -o -name '*.xml' \) -exec $0 patch \{\} \;
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"
;;
diff) patch)
T=`mktemp` sed -i 's/\t/ /g' "$2"
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
;; ;;
*)
echo "Expected recdiff|recpatch|diff|patch as verb." >&2
;;
esac esac

View File

@ -5,18 +5,18 @@ CONFIG=$1
TARGET=$2 TARGET=$2
if [ $# -ne 2 ]; then if [ $# -ne 2 ]; then
echo 'Invalid number of arguments.' echo 'Invalid number of arguments.'
exit 1 exit 1
fi fi
if [ ! -f $CONFIG ]; then if [ ! -f $CONFIG ]; then
echo "$CONFIG not found." echo "$CONFIG not found."
exit 2 exit 2
fi fi
if [ ! -f $TARGET ]; then if [ ! -f $TARGET ]; then
echo "$TARGET not found." echo "$TARGET not found."
exit 3 exit 3
fi fi
DEFINES=$(awk '$1 == "#define" && $3 == "1" { printf "-D%s ", $2 }' $CONFIG) DEFINES=$(awk '$1 == "#define" && $3 == "1" { printf "-D%s ", $2 }' $CONFIG)

View File

@ -1,5 +1,4 @@
#!/bin/sh #!/bin/sh
set -eu set -eu
sd_good=0 sd_good=0
@ -8,27 +7,27 @@ udev_good=0
udev_total=0 udev_total=0
for symbol in `nm -g --defined-only "$@" | grep " T " | cut -d" " -f3 | sort -u` ; do 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 if test -f ${MESON_BUILD_ROOT}/man/$symbol.3 ; then
echo "✓ Symbol $symbol() is documented." echo "✓ Symbol $symbol() is documented."
good=1 good=1
else else
printf " \x1b[1;31mSymbol $symbol() lacks documentation.\x1b[0m\n" printf " \x1b[1;31mSymbol $symbol() lacks documentation.\x1b[0m\n"
good=0 good=0
fi fi
case $symbol in case $symbol in
sd_*) sd_*)
((sd_good+=good)) ((sd_good+=good))
((sd_total+=1)) ((sd_total+=1))
;; ;;
udev_*) udev_*)
((udev_good+=good)) ((udev_good+=good))
((udev_total+=1)) ((udev_total+=1))
;; ;;
*) *)
echo 'unknown symbol prefix' echo 'unknown symbol prefix'
exit 1 exit 1
esac esac
done done
echo "libsystemd: $sd_good/$sd_total libudev: $udev_good/$udev_total" echo "libsystemd: $sd_good/$sd_total libudev: $udev_good/$udev_total"

View File

@ -5,19 +5,19 @@ export SYSTEMD_LOG_LEVEL=info
# output width # output width
if "$1" --help | grep -v 'default:' | grep -E -q '.{80}.'; then if "$1" --help | grep -v 'default:' | grep -E -q '.{80}.'; then
echo "$(basename "$1") --help output is too wide:" echo "$(basename "$1") --help output is too wide:"
"$1" --help | awk 'length > 80' | grep -E --color=yes '.{80}' "$1" --help | awk 'length > 80' | grep -E --color=yes '.{80}'
exit 1 exit 1
fi fi
# no --help output to stdout # no --help output to stdout
if "$1" --help 2>&1 1>/dev/null | grep .; then if "$1" --help 2>&1 1>/dev/null | grep .; then
echo "$(basename "$1") --help prints to stderr" echo "$(basename "$1") --help prints to stderr"
exit 2 exit 2
fi fi
# error output to stderr # error output to stderr
if ! "$1" --no-such-parameter 2>&1 1>/dev/null | grep -q .; then 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" echo "$(basename "$1") with an unknown parameter does not print to stderr"
exit 3 exit 3
fi fi

View File

@ -2,8 +2,8 @@
set -eu set -eu
git shortlog -s `git describe --abbrev=0`.. | \ git shortlog -s `git describe --abbrev=0`.. | \
cut -c8- | \ cut -c8- | \
sed 's/ / /g' | \ sed 's/ / /g' | \
awk '{ print $$0 "," }' | \ awk '{ print $$0 "," }' | \
sed -e 's/ / /g' | \ sed -e 's/ / /g' | \
sort -u sort -u

View File

@ -5,23 +5,23 @@ cd "$1"
unset permissive unset permissive
if [ "${2:-}" = "-p" ]; then if [ "${2:-}" = "-p" ]; then
permissive=1 permissive=1
shift shift
else else
permissive=0 permissive=0
fi fi
if [ "${2:-}" != "-n" ]; then ( if [ "${2:-}" != "-n" ]; then (
[ -z "$permissive" ] || set +e [ -z "$permissive" ] || set +e
set -x set -x
curl -L -o usb.ids 'http://www.linux-usb.org/usb.ids' 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 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-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-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 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 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 acpi_id_registry.html 'https://uefi.org/uefi-acpi-export'
) fi ) fi
set -x set -x

View File

@ -6,7 +6,7 @@ set -eu
mkdir -vp "$(dirname "${DESTDIR:-}$2")" mkdir -vp "$(dirname "${DESTDIR:-}$2")"
if [ "$(dirname $1)" = . ]; then if [ "$(dirname $1)" = . ]; then
ln -vfs -T "$1" "${DESTDIR:-}$2" ln -vfs -T "$1" "${DESTDIR:-}$2"
else else
ln -vfs -T --relative "${DESTDIR:-}$1" "${DESTDIR:-}$2" ln -vfs -T --relative "${DESTDIR:-}$1" "${DESTDIR:-}$2"
fi fi

View File

@ -8,8 +8,8 @@ tag="$2"
fallback="$3" fallback="$3"
if [ -n "$tag" ]; then if [ -n "$tag" ]; then
echo "$tag" echo "$tag"
exit 0 exit 0
fi fi
# Apparently git describe has a bug where it always considers the work-tree # Apparently git describe has a bug where it always considers the work-tree

View File

@ -29,7 +29,7 @@ mkdir -p $build
fuzzflag="oss-fuzz=true" fuzzflag="oss-fuzz=true"
if [ -z "$FUZZING_ENGINE" ]; then if [ -z "$FUZZING_ENGINE" ]; then
fuzzflag="llvm-fuzz=true" fuzzflag="llvm-fuzz=true"
fi fi
meson $build -D$fuzzflag -Db_lundef=false 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, # The seed corpus is a separate flat archive for each fuzzer,
# with a fixed name ${fuzzer}_seed_corpus.zip. # with a fixed name ${fuzzer}_seed_corpus.zip.
for d in "$(dirname "$0")/../test/fuzz/fuzz-"*; do 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 done
# get fuzz-dns-packet corpus # get fuzz-dns-packet corpus

View File

@ -3,59 +3,59 @@
# as soon as Travis CI has started to provide an easy way to export the functions to bash scripts. # as soon as Travis CI has started to provide an easy way to export the functions to bash scripts.
travis_jigger() { travis_jigger() {
local cmd_pid="${1}" local cmd_pid="${1}"
shift shift
local timeout="${1}" local timeout="${1}"
shift shift
local count=0 local count=0
echo -e "\\n" echo -e "\\n"
while [[ "${count}" -lt "${timeout}" ]]; do while [[ "${count}" -lt "${timeout}" ]]; do
count="$((count + 1))" count="$((count + 1))"
echo -ne "Still running (${count} of ${timeout}): ${*}\\r" echo -ne "Still running (${count} of ${timeout}): ${*}\\r"
sleep 60 sleep 60
done done
echo -e "\\n${ANSI_RED}Timeout (${timeout} minutes) reached. Terminating \"${*}\"${ANSI_RESET}\\n" echo -e "\\n${ANSI_RED}Timeout (${timeout} minutes) reached. Terminating \"${*}\"${ANSI_RESET}\\n"
kill -9 "${cmd_pid}" kill -9 "${cmd_pid}"
} }
travis_wait() { travis_wait() {
local timeout="${1}" local timeout="${1}"
if [[ "${timeout}" =~ ^[0-9]+$ ]]; then if [[ "${timeout}" =~ ^[0-9]+$ ]]; then
shift shift
else else
timeout=20 timeout=20
fi fi
local cmd=("${@}") local cmd=("${@}")
local log_file="travis_wait_${$}.log" local log_file="travis_wait_${$}.log"
"${cmd[@]}" &>"${log_file}" & "${cmd[@]}" &>"${log_file}" &
local cmd_pid="${!}" local cmd_pid="${!}"
travis_jigger "${!}" "${timeout}" "${cmd[@]}" & travis_jigger "${!}" "${timeout}" "${cmd[@]}" &
local jigger_pid="${!}" local jigger_pid="${!}"
local result local result
{ {
set +e set +e
wait "${cmd_pid}" 2>/dev/null wait "${cmd_pid}" 2>/dev/null
result="${?}" result="${?}"
ps -p"${jigger_pid}" &>/dev/null && kill "${jigger_pid}" ps -p"${jigger_pid}" &>/dev/null && kill "${jigger_pid}"
set -e set -e
} }
if [[ "${result}" -eq 0 ]]; then if [[ "${result}" -eq 0 ]]; then
echo -e "\\n${ANSI_GREEN}The command ${cmd[*]} exited with ${result}.${ANSI_RESET}" echo -e "\\n${ANSI_GREEN}The command ${cmd[*]} exited with ${result}.${ANSI_RESET}"
else else
echo -e "\\n${ANSI_RED}The command ${cmd[*]} exited with ${result}.${ANSI_RESET}" echo -e "\\n${ANSI_RED}The command ${cmd[*]} exited with ${result}.${ANSI_RESET}"
fi fi
echo -e "\\n${ANSI_GREEN}Log:${ANSI_RESET}\\n" echo -e "\\n${ANSI_GREEN}Log:${ANSI_RESET}\\n"
cat "${log_file}" cat "${log_file}"
return "${result}" return "${result}"
} }

View File

@ -1,5 +1,4 @@
#!/bin/bash #!/bin/bash
set -e set -e
set -x set -x

View File

@ -7,7 +7,7 @@
echo -e "\n\033[33;1mBuilding docker image: coverity-$TRAVIS_COMMIT.\033[0m" echo -e "\n\033[33;1mBuilding docker image: coverity-$TRAVIS_COMMIT.\033[0m"
docker build \ docker build \
--build-arg DOCKER_USER=$USER \ --build-arg DOCKER_USER=$USER \
--build-arg DOCKER_USER_UID=`id -u` \ --build-arg DOCKER_USER_UID=`id -u` \
--build-arg DOCKER_USER_GID=`id -g` \ --build-arg DOCKER_USER_GID=`id -g` \
--force-rm -t coverity-${TRAVIS_COMMIT} --pull=true . --force-rm -t coverity-${TRAVIS_COMMIT} --pull=true .

View File

@ -18,18 +18,18 @@ sudo apt-get update && sudo apt-get -y install wget
# Get coverity tool # Get coverity tool
if [ ! -d $TOOL_BASE ]; then if [ ! -d $TOOL_BASE ]; then
# Download Coverity Scan Analysis Tool # Download Coverity Scan Analysis Tool
if [ ! -e $TOOL_ARCHIVE ]; then if [ ! -e $TOOL_ARCHIVE ]; then
echo -e "\033[33;1mDownloading Coverity Scan Analysis Tool...\033[0m" 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" wget -nv -O $TOOL_ARCHIVE $TOOL_URL --post-data "project=$COVERITY_SCAN_PROJECT_NAME&token=$COVERITY_SCAN_TOKEN"
fi fi
# Extract Coverity Scan Analysis Tool # Extract Coverity Scan Analysis Tool
echo -e "\033[33;1mExtracting Coverity Scan Analysis Tool...\033[0m" echo -e "\033[33;1mExtracting Coverity Scan Analysis Tool...\033[0m"
mkdir -p $TOOL_BASE mkdir -p $TOOL_BASE
pushd $TOOL_BASE pushd $TOOL_BASE
tar xzf $TOOL_ARCHIVE tar xzf $TOOL_ARCHIVE
popd popd
fi fi
echo -e "\033[33;1mCoverity Scan Analysis Tool can be found at $TOOL_BASE ...\033[0m" echo -e "\033[33;1mCoverity Scan Analysis Tool can be found at $TOOL_BASE ...\033[0m"

View File

@ -6,23 +6,23 @@ target="$2"
unit="$3" unit="$3"
case "$target" in case "$target" in
*/?*) # a path, but not just a slash at the end */?*) # a path, but not just a slash at the end
dir="${DESTDIR:-}${target}" dir="${DESTDIR:-}${target}"
;; ;;
*) *)
dir="${DESTDIR:-}${unitdir}/${target}" dir="${DESTDIR:-}${unitdir}/${target}"
;; ;;
esac esac
unitpath="${DESTDIR:-}${unitdir}/${unit}" unitpath="${DESTDIR:-}${unitdir}/${unit}"
case "$target" in case "$target" in
*/) */)
mkdir -vp -m 0755 "$dir" mkdir -vp -m 0755 "$dir"
;; ;;
*) *)
mkdir -vp -m 0755 "$(dirname "$dir")" mkdir -vp -m 0755 "$(dirname "$dir")"
;; ;;
esac esac
ln -vfs --relative "$unitpath" "$dir" ln -vfs --relative "$unitpath" "$dir"

View File

@ -3,5 +3,5 @@
systemctl --user import-environment DISPLAY XAUTHORITY systemctl --user import-environment DISPLAY XAUTHORITY
if command -v dbus-update-activation-environment >/dev/null 2>&1; then 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 fi