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)
(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)

View File

@ -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

1
.vimrc
View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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 ]

View File

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

View File

@ -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; }'

View File

@ -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_//'

View File

@ -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

View File

@ -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; }'

View File

@ -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

View File

@ -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

View File

@ -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_//'

View File

@ -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"

View File

@ -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 }
'

View File

@ -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}

View File

@ -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

View File

@ -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

View File

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

View File

@ -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"

View File

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

View File

@ -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"

View File

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

View File

@ -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

View File

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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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"

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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 "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 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,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 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
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 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
# '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
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 "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
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
# 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
clear_services a x y
}
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
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
# '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 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' 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
# '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
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 '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
# '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
# '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
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
# 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 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
# '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
# '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
# 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
clear_services a b
}
test_basic_dropins

View File

@ -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 "$@"

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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"

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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"

View File

@ -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

View File

@ -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
# ensure our build of systemd-sysusers is run
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
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
# 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
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 -
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
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 -
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
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"
# 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)"
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"
# 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=…)"
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
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
# 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 "$@"

View File

@ -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

View File

@ -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"

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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"

View File

@ -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

View File

@ -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"

View File

@ -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

View File

@ -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:"

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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"

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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
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
if [ $? != 0 ]; then
echo -e "\033[33;1mCoverity Scan Build failed: $TEXT.\033[0m"
return 1
fi
[ -z $TAR ] || [ $TAR = false ] && return 0
[ -z $TAR ] || [ $TAR = false ] && return 0
if [ "$TAR" = true ]; then
_pack
fi
if [ "$TAR" = true ]; then
_pack
fi
}
_upload()
{
# pack results
[ -z $PACKED ] || [ $PACKED = false ] && _pack
# 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
# 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
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

View File

@ -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)"

View File

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

View File

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

View File

@ -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)

View File

@ -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"

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

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.
travis_jigger() {
local cmd_pid="${1}"
shift
local timeout="${1}"
shift
local count=0
local cmd_pid="${1}"
shift
local timeout="${1}"
shift
local count=0
echo -e "\\n"
echo -e "\\n"
while [[ "${count}" -lt "${timeout}" ]]; do
count="$((count + 1))"
echo -ne "Still running (${count} of ${timeout}): ${*}\\r"
sleep 60
done
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}"
echo -e "\\n${ANSI_RED}Timeout (${timeout} minutes) reached. Terminating \"${*}\"${ANSI_RESET}\\n"
kill -9 "${cmd_pid}"
}
travis_wait() {
local timeout="${1}"
local timeout="${1}"
if [[ "${timeout}" =~ ^[0-9]+$ ]]; then
shift
else
timeout=20
fi
if [[ "${timeout}" =~ ^[0-9]+$ ]]; then
shift
else
timeout=20
fi
local cmd=("${@}")
local log_file="travis_wait_${$}.log"
local cmd=("${@}")
local log_file="travis_wait_${$}.log"
"${cmd[@]}" &>"${log_file}" &
local cmd_pid="${!}"
"${cmd[@]}" &>"${log_file}" &
local cmd_pid="${!}"
travis_jigger "${!}" "${timeout}" "${cmd[@]}" &
local jigger_pid="${!}"
local result
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
}
{
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
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}"
echo -e "\\n${ANSI_GREEN}Log:${ANSI_RESET}\\n"
cat "${log_file}"
return "${result}"
return "${result}"
}

View File

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

View File

@ -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 .

View File

@ -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
# 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
# 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"

View File

@ -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"

View File

@ -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