]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test: add simple test for log namespaces
authorLennart Poettering <lennart@poettering.net>
Wed, 27 Nov 2019 16:57:51 +0000 (17:57 +0100)
committerLennart Poettering <lennart@poettering.net>
Fri, 31 Jan 2020 14:04:05 +0000 (15:04 +0100)
test/TEST-44-LOG-NAMESPACE/Makefile [new symlink]
test/TEST-44-LOG-NAMESPACE/test.sh [new file with mode: 0755]
test/TEST-44-LOG-NAMESPACE/testsuite.sh [new file with mode: 0755]

diff --git a/test/TEST-44-LOG-NAMESPACE/Makefile b/test/TEST-44-LOG-NAMESPACE/Makefile
new file mode 120000 (symlink)
index 0000000..e9f93b1
--- /dev/null
@@ -0,0 +1 @@
+../TEST-01-BASIC/Makefile
\ No newline at end of file
diff --git a/test/TEST-44-LOG-NAMESPACE/test.sh b/test/TEST-44-LOG-NAMESPACE/test.sh
new file mode 100755 (executable)
index 0000000..4dfb441
--- /dev/null
@@ -0,0 +1,39 @@
+#!/bin/bash
+set -e
+TEST_DESCRIPTION="test log namespaces"
+
+. $TEST_BASE_DIR/test-functions
+
+test_setup() {
+    create_empty_image_rootdir
+
+    (
+        LOG_LEVEL=5
+        eval $(udevadm info --export --query=env --name=${LOOPDEV}p2)
+
+        setup_basic_environment
+
+        mask_supporting_services
+
+        # setup the testsuite service
+        cat >$initdir/etc/systemd/system/testsuite.service <<EOF
+[Unit]
+Description=Testsuite service
+Before=getty-pre.target
+Wants=getty-pre.target
+Wants=systemd-journald@foobar.socket systemd-journald-varlink@foobar.socket
+After=systemd-journald@foobar.socket systemd-journald-varlink@foobar.socket
+
+[Service]
+ExecStart=/testsuite.sh
+Type=oneshot
+LogTarget=foobar
+EOF
+        cp testsuite.sh $initdir/
+
+        setup_testsuite
+    )
+    setup_nspawn_root
+}
+
+do_test "$@"
diff --git a/test/TEST-44-LOG-NAMESPACE/testsuite.sh b/test/TEST-44-LOG-NAMESPACE/testsuite.sh
new file mode 100755 (executable)
index 0000000..9be0765
--- /dev/null
@@ -0,0 +1,19 @@
+#!/bin/bash
+set -ex
+
+systemd-analyze log-level debug
+
+systemd-run -p LogNamespace=foobar echo "hello world"
+
+journalctl --namespace=foobar --sync
+journalctl --namespace=foobar > /tmp/hello-world
+journalctl > /tmp/no-hello-world
+
+grep "hello world" /tmp/hello-world
+! grep "hello world" /tmp/no-hello-world
+
+systemd-analyze log-level info
+
+echo OK > /testok
+
+exit 0