1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2024-12-22 13:33:56 +03:00

test: add tests for systemd-tmpfiles

This commit is contained in:
Franck Bui 2018-03-05 12:32:18 +01:00 committed by Zbigniew Jędrzejewski-Szmek
parent caced73270
commit e04fc13f5f
5 changed files with 76 additions and 0 deletions

View File

@ -0,0 +1,4 @@
BUILD_DIR=$(shell ../../tools/find-build-dir.sh)
all setup clean run:
@basedir=../.. TEST_BASE_DIR=../ BUILD_DIR=$(BUILD_DIR) ./test.sh --$@

View File

@ -0,0 +1,13 @@
#!/bin/bash
set -x
set -e
>/failed
for t in test-*.sh; do
echo "Running $t"; ./$t
done
touch /testok
rm /failed

View File

@ -0,0 +1,13 @@
#! /bin/bash
#
# With "e" don't attempt to set permissions when file doesn't exist, see
# https://github.com/systemd/systemd/pull/6682.
#
set -e
rm -fr /tmp/test
echo "e /tmp/test - root root 1d" | systemd-tmpfiles --create -
! test -e /tmp/test

38
test/TEST-22-TMPFILES/test.sh Executable file
View File

@ -0,0 +1,38 @@
#!/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
. $TEST_BASE_DIR/test-functions
test_setup() {
# create the basic filesystem layout
setup_basic_environment >/dev/null
inst_binary mv
inst_binary stat
inst_binary seq
inst_binary xargs
# 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
cp testsuite.service $initdir/etc/systemd/system/
setup_testsuite
mkdir -p $initdir/testsuite
cp run-tmpfiles-tests.sh $initdir/testsuite/
cp test-*.sh $initdir/testsuite/
# create dedicated rootfs for nspawn (located in $TESTDIR/nspawn-root)
setup_nspawn_root
}
do_test "$@"

View File

@ -0,0 +1,8 @@
[Unit]
Description=Testsuite service
After=multi-user.target
[Service]
WorkingDirectory=/testsuite
ExecStart=/testsuite/run-tmpfiles-tests.sh
Type=oneshot