diff options
author | Lennart Poettering <lennart@poettering.net> | 2019-04-01 16:51:55 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2019-07-11 12:18:51 +0200 |
commit | 273fe5d3cba509eae97a36838766b6ea43ef17a7 (patch) | |
tree | bf9d29253dc3d80310d11cf9973e3b841a4990d7 | |
parent | a7056cde56577798a91c1ddb09f052c5a3ccc23d (diff) | |
download | systemd-273fe5d3cba509eae97a36838766b6ea43ef17a7.tar.gz |
test: add testcase for new CleanUnit logic
l--------- | test/TEST-33-CLEAN-UNIT/Makefile | 1 | ||||
-rwxr-xr-x | test/TEST-33-CLEAN-UNIT/test.sh | 49 | ||||
-rwxr-xr-x | test/TEST-33-CLEAN-UNIT/testsuite.sh | 79 |
3 files changed, 129 insertions, 0 deletions
diff --git a/test/TEST-33-CLEAN-UNIT/Makefile b/test/TEST-33-CLEAN-UNIT/Makefile new file mode 120000 index 0000000000..e9f93b1104 --- /dev/null +++ b/test/TEST-33-CLEAN-UNIT/Makefile @@ -0,0 +1 @@ +../TEST-01-BASIC/Makefile
\ No newline at end of file diff --git a/test/TEST-33-CLEAN-UNIT/test.sh b/test/TEST-33-CLEAN-UNIT/test.sh new file mode 100755 index 0000000000..44082af4d4 --- /dev/null +++ b/test/TEST-33-CLEAN-UNIT/test.sh @@ -0,0 +1,49 @@ +#!/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 CleanUnit" + +. $TEST_BASE_DIR/test-functions + +test_setup() { + create_empty_image + mkdir -p $TESTDIR/root + mount ${LOOPDEV}p1 $TESTDIR/root + + ( + LOG_LEVEL=5 + eval $(udevadm info --export --query=env --name=${LOOPDEV}p2) + + setup_basic_environment + + # mask some services that we do not want to run in these tests + ln -fs /dev/null $initdir/etc/systemd/system/systemd-hwdb-update.service + ln -fs /dev/null $initdir/etc/systemd/system/systemd-journal-catalog-update.service + ln -fs /dev/null $initdir/etc/systemd/system/systemd-networkd.service + ln -fs /dev/null $initdir/etc/systemd/system/systemd-networkd.socket + ln -fs /dev/null $initdir/etc/systemd/system/systemd-resolved.service + ln -fs /dev/null $initdir/etc/systemd/system/systemd-machined.service + + # setup the testsuite service + cat >$initdir/etc/systemd/system/testsuite.service <<EOF +[Unit] +Description=Testsuite service + +[Service] +ExecStart=/bin/bash -x /testsuite.sh +Type=oneshot +StandardOutput=tty +StandardError=tty +EOF + cp testsuite.sh $initdir/ + + setup_testsuite + ) || return 1 + setup_nspawn_root + + ddebug "umount $TESTDIR/root" + umount $TESTDIR/root +} + +do_test "$@" diff --git a/test/TEST-33-CLEAN-UNIT/testsuite.sh b/test/TEST-33-CLEAN-UNIT/testsuite.sh new file mode 100755 index 0000000000..15aa687238 --- /dev/null +++ b/test/TEST-33-CLEAN-UNIT/testsuite.sh @@ -0,0 +1,79 @@ +#!/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 + +cat > /etc/systemd/system/testservice.service <<EOF +[Service] +ConfigurationDirectory=testservice +RuntimeDirectory=testservice +StateDirectory=testservice +CacheDirectory=testservice +LogsDirectory=testservice +RuntimeDirectoryPreserve=yes +ExecStart=/bin/sleep infinity +Type=exec +EOF + +systemctl daemon-reload + +! test -e /etc/testservice +! test -e /run/testservice +! test -e /var/lib/testservice +! test -e /var/cache/testservice +! test -e /var/log/testservice + +systemctl start testservice + +test -d /etc/testservice +test -d /run/testservice +test -d /var/lib/testservice +test -d /var/cache/testservice +test -d /var/log/testservice + +! systemctl clean testservice + +systemctl stop testservice + +test -d /etc/testservice +test -d /run/testservice +test -d /var/lib/testservice +test -d /var/cache/testservice +test -d /var/log/testservice + +systemctl clean testservice --what=configuration + +! test -e /etc/testservice +test -d /run/testservice +test -d /var/lib/testservice +test -d /var/cache/testservice +test -d /var/log/testservice + +systemctl clean testservice + +! test -e /etc/testservice +! test -e /run/testservice +test -d /var/lib/testservice +! test -e /var/cache/testservice +test -d /var/log/testservice + +systemctl clean testservice --what=logs + +! test -e /etc/testservice +! test -e /run/testservice +test -d /var/lib/testservice +! test -e /var/cache/testservice +! test -e /var/log/testservice + +systemctl clean testservice --what=all + +! test -e /etc/testservice +! test -e /run/testservice +! test -e /var/lib/testservice +! test -e /var/cache/testservice +! test -e /var/log/testservice + +echo OK > /testok + +exit 0 |