aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFranck Bui <fbui@suse.com>2018-03-05 12:32:18 +0100
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2018-03-05 21:49:11 +0100
commite04fc13f5f4fb6db46ef035949c56128b52243e0 (patch)
tree4bfb3fdd05c56bc6b31534674a9bd83f11543558
parenttest: fix setup_suse() to make it work with an already populated root (diff)
downloadsystemd-e04fc13f5f4fb6db46ef035949c56128b52243e0.tar.xz
systemd-e04fc13f5f4fb6db46ef035949c56128b52243e0.zip
test: add tests for systemd-tmpfiles
-rw-r--r--test/TEST-22-TMPFILES/Makefile4
-rwxr-xr-xtest/TEST-22-TMPFILES/run-tmpfiles-tests.sh13
-rwxr-xr-xtest/TEST-22-TMPFILES/test-01.sh13
-rwxr-xr-xtest/TEST-22-TMPFILES/test.sh38
-rw-r--r--test/TEST-22-TMPFILES/testsuite.service8
5 files changed, 76 insertions, 0 deletions
diff --git a/test/TEST-22-TMPFILES/Makefile b/test/TEST-22-TMPFILES/Makefile
new file mode 100644
index 00000000000..34d7cc6cdf7
--- /dev/null
+++ b/test/TEST-22-TMPFILES/Makefile
@@ -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 --$@
diff --git a/test/TEST-22-TMPFILES/run-tmpfiles-tests.sh b/test/TEST-22-TMPFILES/run-tmpfiles-tests.sh
new file mode 100755
index 00000000000..3ad652f4ede
--- /dev/null
+++ b/test/TEST-22-TMPFILES/run-tmpfiles-tests.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
diff --git a/test/TEST-22-TMPFILES/test-01.sh b/test/TEST-22-TMPFILES/test-01.sh
new file mode 100755
index 00000000000..d233e37fb21
--- /dev/null
+++ b/test/TEST-22-TMPFILES/test-01.sh
@@ -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
diff --git a/test/TEST-22-TMPFILES/test.sh b/test/TEST-22-TMPFILES/test.sh
new file mode 100755
index 00000000000..ca789333807
--- /dev/null
+++ b/test/TEST-22-TMPFILES/test.sh
@@ -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 "$@"
diff --git a/test/TEST-22-TMPFILES/testsuite.service b/test/TEST-22-TMPFILES/testsuite.service
new file mode 100644
index 00000000000..3a44b41989c
--- /dev/null
+++ b/test/TEST-22-TMPFILES/testsuite.service
@@ -0,0 +1,8 @@
+[Unit]
+Description=Testsuite service
+After=multi-user.target
+
+[Service]
+WorkingDirectory=/testsuite
+ExecStart=/testsuite/run-tmpfiles-tests.sh
+Type=oneshot