#!/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"
. $TEST_BASE_DIR/test-functions
#!/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
}
test_cleanup() {
- umount $TESTDIR/root/var 2>/dev/null
+ [ -d $TESTDIR/root/var ] && mountpoint $TESTDIR/root/var && umount $TESTDIR/root/var
[[ -b /dev/mapper/varcrypt ]] && cryptsetup luksClose /dev/mapper/varcrypt
- umount $TESTDIR/root 2>/dev/null
+ umount $TESTDIR/root 2>/dev/null || true
[[ $LOOPDEV ]] && losetup -d $LOOPDEV
return 0
}
-#!/bin/bash -x
+#!/bin/bash -e
# Test merging of a --job-mode=ignore-dependencies job into a previously
# installed job.
systemctl list-jobs > /root/list-jobs.txt
done
-grep 'hello\.service.*waiting' /root/list-jobs.txt || exit 1
+grep 'hello\.service.*waiting' /root/list-jobs.txt
# This is supposed to finish quickly, not wait for sleep to finish.
START_SEC=$(date -u '+%s')
END_SEC=$(date -u '+%s')
ELAPSED=$(($END_SEC-$START_SEC))
-[ "$ELAPSED" -lt 3 ] || exit 1
+[ "$ELAPSED" -lt 3 ]
# sleep should still be running, hello not.
systemctl list-jobs > /root/list-jobs.txt
-grep 'sleep\.service.*running' /root/list-jobs.txt || exit 1
+grep 'sleep\.service.*running' /root/list-jobs.txt
grep 'hello\.service' /root/list-jobs.txt && exit 1
-systemctl stop sleep.service hello-after-sleep.target || exit 1
+systemctl stop sleep.service hello-after-sleep.target
# Test for a crash when enqueuing a JOB_NOP when other job already exists
-systemctl start --no-block hello-after-sleep.target || exit 1
+systemctl start --no-block hello-after-sleep.target
# hello.service should still be waiting, so these try-restarts will collapse
# into NOPs.
-systemctl try-restart --job-mode=fail hello.service || exit 1
-systemctl try-restart hello.service || exit 1
-systemctl stop hello.service sleep.service hello-after-sleep.target || exit 1
+systemctl try-restart --job-mode=fail hello.service
+systemctl try-restart hello.service
+systemctl stop hello.service sleep.service hello-after-sleep.target
# TODO: add more job queueing/merging tests here.
# Test for irreversible jobs
-systemctl start unstoppable.service || exit 1
+systemctl start unstoppable.service
# This is expected to fail with 'job cancelled'
systemctl stop unstoppable.service && exit 1
# But this should succeed
-systemctl stop --job-mode=replace-irreversibly unstoppable.service || exit 1
+systemctl stop --job-mode=replace-irreversibly unstoppable.service
# We're going to shutdown soon. Let's see if it succeeds when
# there's an active service that tries to be unstoppable.
# Shutdown of the container/VM will hang if not.
-systemctl start unstoppable.service || exit 1
+systemctl start unstoppable.service
# Test waiting for a started unit(s) to terminate again
cat <<EOF > /run/systemd/system/wait2.service
# wait2 succeeds
START_SEC=$(date -u '+%s')
-systemctl start --wait wait2.service || exit 1
+systemctl start --wait wait2.service
END_SEC=$(date -u '+%s')
ELAPSED=$(($END_SEC-$START_SEC))
[[ "$ELAPSED" -ge 2 ]] && [[ "$ELAPSED" -le 4 ]] || exit 1
#!/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_BASE_DIR/test-functions
#!/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"
. $TEST_BASE_DIR/test-functions
#!/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"
. $TEST_BASE_DIR/test-functions
#!/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
#!/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
#!/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
#!/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
#!/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"
TEST_NO_NSPAWN=1
#!/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
#!/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
#!/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
SKIP_INITRD=yes
#!/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"
TEST_NO_NSPAWN=1
SKIP_INITRD=yes
#!/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
PATH=/sbin:/bin:/usr/sbin:/usr/bin
export PATH
-LOOKS_LIKE_DEBIAN=$(source /etc/os-release && [[ "$ID" = "debian" || "$ID_LIKE" = "debian" ]] && echo yes)
-LOOKS_LIKE_ARCH=$(source /etc/os-release && [[ "$ID" = "arch" ]] && echo yes)
-LOOKS_LIKE_SUSE=$(source /etc/os-release && [[ "$ID_LIKE" = "suse" ]] && echo yes)
+LOOKS_LIKE_DEBIAN=$(source /etc/os-release && [[ "$ID" = "debian" || "$ID_LIKE" = "debian" ]] && echo yes || true)
+LOOKS_LIKE_ARCH=$(source /etc/os-release && [[ "$ID" = "arch" ]] && echo yes || true)
+LOOKS_LIKE_SUSE=$(source /etc/os-release && [[ "$ID_LIKE" = "suse" ]] && echo yes || true)
KERNEL_VER=${KERNEL_VER-$(uname -r)}
KERNEL_MODS="/lib/modules/$KERNEL_VER/"
QEMU_TIMEOUT="${QEMU_TIMEOUT:-infinity}"
egrep -ho '^Exec[^ ]*=[^ ]+' $initdir/{$systemdsystemunitdir,$systemduserunitdir}/*.service \
| while read i; do
i=${i##Exec*=}; i=${i##-}
- inst $i
+ # some {rc,halt}.local scripts and programs are okay to not exist, the rest should
+ inst $i || [ "${i%.local}" != "$i" ] || [ "${i%systemd-update-done}" != "$i" ]
done
)
}
}
install_config_files() {
- inst /etc/sysconfig/init
+ inst /etc/sysconfig/init || true
inst /etc/passwd
inst /etc/shadow
inst /etc/login.defs
inst /etc/group
inst /etc/shells
inst /etc/nsswitch.conf
- inst /etc/pam.conf
- inst /etc/securetty
+ inst /etc/pam.conf || true
+ inst /etc/securetty || true
inst /etc/os-release
inst /etc/localtime
# we want an empty environment
install_pam() {
(
- [[ "$LOOKS_LIKE_DEBIAN" ]] && type -p dpkg-architecture &>/dev/null && find "/lib/$(dpkg-architecture -qDEB_HOST_MULTIARCH)/security" -xtype f
- find \
- /etc/pam.d \
- /etc/security \
- /lib64/security \
- /lib/security -xtype f \
+ if [[ "$LOOKS_LIKE_DEBIAN" ]] && type -p dpkg-architecture &>/dev/null; then
+ find "/lib/$(dpkg-architecture -qDEB_HOST_MULTIARCH)/security" -xtype f
+ else
+ find /lib*/security -xtype f
+ fi
+ find /etc/pam.d /etc/security -xtype f
) | while read file; do
inst $file
done
# Create additional symlinks. See rev_symlinks description.
for _symlink in $(rev_lib_symlinks $_src) $(rev_lib_symlinks $_reallib); do
- [[ ! -e $initdir/$_symlink ]] && {
+ [[ -e $initdir/$_symlink ]] || {
ddebug "Creating extra symlink: $_symlink"
inst_symlink $_symlink
}
# can be overridden in specific test
test_cleanup() {
umount $TESTDIR/root 2>/dev/null || true
- [[ $LOOPDEV ]] && losetup -d $LOOPDEV
+ [[ $LOOPDEV ]] && losetup -d $LOOPDEV || true
return 0
}
case $1 in
--run)
echo "TEST RUN: $TEST_DESCRIPTION"
- test_run
- ret=$?
- if [ $ret -eq 0 ]; then
+ if test_run; then
echo "TEST RUN: $TEST_DESCRIPTION [OK]"
else
echo "TEST RUN: $TEST_DESCRIPTION [FAILED]"
--setup)
echo "TEST SETUP: $TEST_DESCRIPTION"
test_setup
- exit $?;;
+ ;;
--clean)
echo "TEST CLEANUP: $TEST_DESCRIPTION"
test_cleanup
rm -fr "$TESTDIR"
rm -f "$STATEFILE"
- exit $?;;
+ ;;
--all)
+ ret=0
echo -n "TEST: $TEST_DESCRIPTION ";
(
test_setup && test_run
rm -fr "$TESTDIR"
rm -f "$STATEFILE"
exit $ret
- ) </dev/null >"$TESTLOG" 2>&1
- ret=$?
+ ) </dev/null >"$TESTLOG" 2>&1 || ret=$?
if [ $ret -eq 0 ]; then
rm "$TESTLOG"
echo "[OK]"