Permalink
Browse files

test: add tests for systemd-tmpfiles

  • Loading branch information...
fbuihuu authored and keszybz committed Mar 5, 2018
1 parent caced73 commit e04fc13f5f4fb6db46ef035949c56128b52243e0
@@ -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 --$@
@@ -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
@@ -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
@@ -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 "$@"
@@ -0,0 +1,8 @@
[Unit]
Description=Testsuite service
After=multi-user.target

[Service]
WorkingDirectory=/testsuite
ExecStart=/testsuite/run-tmpfiles-tests.sh
Type=oneshot

0 comments on commit e04fc13

Please sign in to comment.