|
|
984f77 |
From 2bbaa4b647c8a60a6c6a591f71313b0667447246 Mon Sep 17 00:00:00 2001
|
|
|
984f77 |
From: Lennart Poettering <lennart@poettering.net>
|
|
|
984f77 |
Date: Mon, 26 Nov 2018 21:09:07 +0100
|
|
|
984f77 |
Subject: [PATCH] =?UTF-8?q?test:=20add=20a=20test=20for=20StandardError=3D?=
|
|
|
984f77 |
=?UTF-8?q?file:=E2=80=A6?=
|
|
|
984f77 |
MIME-Version: 1.0
|
|
|
984f77 |
Content-Type: text/plain; charset=UTF-8
|
|
|
984f77 |
Content-Transfer-Encoding: 8bit
|
|
|
984f77 |
|
|
|
984f77 |
This deserves a test of its, given how broken on so many levels this
|
|
|
984f77 |
previously was.
|
|
|
984f77 |
|
|
|
984f77 |
(cherry picked from commit 196b0a11f306b8041e35316feb05ed1f00380957)
|
|
|
984f77 |
|
|
|
984f77 |
Related: #2093479
|
|
|
984f77 |
---
|
|
|
984f77 |
test/TEST-27-STDOUTFILE/Makefile | 1 +
|
|
|
984f77 |
test/TEST-27-STDOUTFILE/test.sh | 52 ++++++++++++++++++++++++++++
|
|
|
984f77 |
test/TEST-27-STDOUTFILE/testsuite.sh | 40 +++++++++++++++++++++
|
|
|
984f77 |
3 files changed, 93 insertions(+)
|
|
|
984f77 |
create mode 120000 test/TEST-27-STDOUTFILE/Makefile
|
|
|
984f77 |
create mode 100755 test/TEST-27-STDOUTFILE/test.sh
|
|
|
984f77 |
create mode 100755 test/TEST-27-STDOUTFILE/testsuite.sh
|
|
|
984f77 |
|
|
|
984f77 |
diff --git a/test/TEST-27-STDOUTFILE/Makefile b/test/TEST-27-STDOUTFILE/Makefile
|
|
|
984f77 |
new file mode 120000
|
|
|
984f77 |
index 0000000000..e9f93b1104
|
|
|
984f77 |
--- /dev/null
|
|
|
984f77 |
+++ b/test/TEST-27-STDOUTFILE/Makefile
|
|
|
984f77 |
@@ -0,0 +1 @@
|
|
|
984f77 |
+../TEST-01-BASIC/Makefile
|
|
|
984f77 |
\ No newline at end of file
|
|
|
984f77 |
diff --git a/test/TEST-27-STDOUTFILE/test.sh b/test/TEST-27-STDOUTFILE/test.sh
|
|
|
984f77 |
new file mode 100755
|
|
|
984f77 |
index 0000000000..724dbef231
|
|
|
984f77 |
--- /dev/null
|
|
|
984f77 |
+++ b/test/TEST-27-STDOUTFILE/test.sh
|
|
|
984f77 |
@@ -0,0 +1,52 @@
|
|
|
984f77 |
+#!/bin/bash
|
|
|
984f77 |
+# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
|
|
|
984f77 |
+# ex: ts=8 sw=4 sts=4 et filetype=sh
|
|
|
984f77 |
+set -e
|
|
|
984f77 |
+TEST_DESCRIPTION="test StandardOutput=file:"
|
|
|
984f77 |
+
|
|
|
984f77 |
+. $TEST_BASE_DIR/test-functions
|
|
|
984f77 |
+
|
|
|
984f77 |
+test_setup() {
|
|
|
984f77 |
+ create_empty_image
|
|
|
984f77 |
+ mkdir -p $TESTDIR/root
|
|
|
984f77 |
+ mount ${LOOPDEV}p1 $TESTDIR/root
|
|
|
984f77 |
+
|
|
|
984f77 |
+ (
|
|
|
984f77 |
+ LOG_LEVEL=5
|
|
|
984f77 |
+ eval $(udevadm info --export --query=env --name=${LOOPDEV}p2)
|
|
|
984f77 |
+
|
|
|
984f77 |
+ inst_binary cmp
|
|
|
984f77 |
+
|
|
|
984f77 |
+ setup_basic_environment
|
|
|
984f77 |
+
|
|
|
984f77 |
+ # mask some services that we do not want to run in these tests
|
|
|
984f77 |
+ ln -fs /dev/null $initdir/etc/systemd/system/systemd-hwdb-update.service
|
|
|
984f77 |
+ ln -fs /dev/null $initdir/etc/systemd/system/systemd-journal-catalog-update.service
|
|
|
984f77 |
+ ln -fs /dev/null $initdir/etc/systemd/system/systemd-networkd.service
|
|
|
984f77 |
+ ln -fs /dev/null $initdir/etc/systemd/system/systemd-networkd.socket
|
|
|
984f77 |
+ ln -fs /dev/null $initdir/etc/systemd/system/systemd-resolved.service
|
|
|
984f77 |
+ ln -fs /dev/null $initdir/etc/systemd/system/systemd-machined.service
|
|
|
984f77 |
+
|
|
|
984f77 |
+ # setup the testsuite service
|
|
|
984f77 |
+ cat >$initdir/etc/systemd/system/testsuite.service <
|
|
|
984f77 |
+[Unit]
|
|
|
984f77 |
+Description=Testsuite service
|
|
|
984f77 |
+
|
|
|
984f77 |
+[Service]
|
|
|
984f77 |
+ExecStart=/testsuite.sh
|
|
|
984f77 |
+Type=oneshot
|
|
|
984f77 |
+StandardOutput=tty
|
|
|
984f77 |
+StandardError=tty
|
|
|
984f77 |
+NotifyAccess=all
|
|
|
984f77 |
+EOF
|
|
|
984f77 |
+ cp testsuite.sh $initdir/
|
|
|
984f77 |
+
|
|
|
984f77 |
+ setup_testsuite
|
|
|
984f77 |
+ ) || return 1
|
|
|
984f77 |
+ setup_nspawn_root
|
|
|
984f77 |
+
|
|
|
984f77 |
+ ddebug "umount $TESTDIR/root"
|
|
|
984f77 |
+ umount $TESTDIR/root
|
|
|
984f77 |
+}
|
|
|
984f77 |
+
|
|
|
984f77 |
+do_test "$@"
|
|
|
984f77 |
diff --git a/test/TEST-27-STDOUTFILE/testsuite.sh b/test/TEST-27-STDOUTFILE/testsuite.sh
|
|
|
984f77 |
new file mode 100755
|
|
|
984f77 |
index 0000000000..75559e03e5
|
|
|
984f77 |
--- /dev/null
|
|
|
984f77 |
+++ b/test/TEST-27-STDOUTFILE/testsuite.sh
|
|
|
984f77 |
@@ -0,0 +1,40 @@
|
|
|
984f77 |
+#!/bin/bash
|
|
|
984f77 |
+# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
|
|
|
984f77 |
+# ex: ts=8 sw=4 sts=4 et filetype=sh
|
|
|
984f77 |
+set -ex
|
|
|
984f77 |
+set -o pipefail
|
|
|
984f77 |
+
|
|
|
984f77 |
+systemd-analyze set-log-level debug
|
|
|
984f77 |
+systemd-analyze set-log-target console
|
|
|
984f77 |
+
|
|
|
984f77 |
+systemd-run --unit=one -p StandardOutput=file:/tmp/stdout -p StandardError=file:/tmp/stderr -p Type=exec sh -c 'echo x ; echo y >&2'
|
|
|
984f77 |
+cmp /tmp/stdout <
|
|
|
984f77 |
+x
|
|
|
984f77 |
+EOF
|
|
|
984f77 |
+cmp /tmp/stderr <
|
|
|
984f77 |
+y
|
|
|
984f77 |
+EOF
|
|
|
984f77 |
+
|
|
|
984f77 |
+systemd-run --unit=two -p StandardOutput=file:/tmp/stdout -p StandardError=file:/tmp/stderr -p Type=exec sh -c 'echo z ; echo a >&2'
|
|
|
984f77 |
+cmp /tmp/stdout <
|
|
|
984f77 |
+z
|
|
|
984f77 |
+EOF
|
|
|
984f77 |
+cmp /tmp/stderr <
|
|
|
984f77 |
+a
|
|
|
984f77 |
+EOF
|
|
|
984f77 |
+
|
|
|
984f77 |
+systemd-run --unit=three -p StandardOutput=append:/tmp/stdout -p StandardError=append:/tmp/stderr -p Type=exec sh -c 'echo b ; echo c >&2'
|
|
|
984f77 |
+cmp /tmp/stdout <
|
|
|
984f77 |
+z
|
|
|
984f77 |
+b
|
|
|
984f77 |
+EOF
|
|
|
984f77 |
+cmp /tmp/stderr <
|
|
|
984f77 |
+a
|
|
|
984f77 |
+c
|
|
|
984f77 |
+EOF
|
|
|
984f77 |
+
|
|
|
984f77 |
+systemd-analyze set-log-level info
|
|
|
984f77 |
+
|
|
|
984f77 |
+echo OK > /testok
|
|
|
984f77 |
+
|
|
|
984f77 |
+exit 0
|