594167
From 4dd51db0381048f15973dc0046fe5fdec1f40aa8 Mon Sep 17 00:00:00 2001
594167
From: Frantisek Sumsal <frantisek@sumsal.cz>
594167
Date: Thu, 16 Jun 2022 22:16:53 +0200
594167
Subject: [PATCH] test: send stdout/stderr of testsuite units to journal &
594167
 console
594167
594167
to make debugging in CIs slightly easier.
594167
594167
(cherry picked from commit ba7abf79a5a2df2a93332fc32e8e3c268c74abc7)
594167
594167
Related: #2087652
594167
---
594167
 test/test-functions             | 12 ++++++++++++
594167
 test/units/testsuite-22.service |  2 --
594167
 test/units/testsuite-35.service |  2 --
594167
 test/units/testsuite-45.service |  2 --
594167
 test/units/testsuite-64.service |  2 --
594167
 test/units/testsuite-71.service |  2 --
594167
 test/units/testsuite-73.service |  2 --
594167
 7 files changed, 12 insertions(+), 12 deletions(-)
594167
594167
diff --git a/test/test-functions b/test/test-functions
594167
index 57d4df3e7e..77d4a0afff 100644
594167
--- a/test/test-functions
594167
+++ b/test/test-functions
594167
@@ -2867,6 +2867,18 @@ test_setup() {
594167
             mask_supporting_services
594167
         fi
594167
 
594167
+        # Send stdout/stderr of testsuite-*.service units to both journal and
594167
+        # console to make debugging in CIs easier
594167
+        # Note: we can't use a dropin for `testsuite-.service`, since that also
594167
+        #       overrides 'sub-units' of some tests that already use a specific
594167
+        #       value for Standard(Output|Error)=
594167
+        #       (e.g. test/units/testsuite-66-deviceisolation.service)
594167
+        if ! get_bool "$INTERACTIVE_DEBUG"; then
594167
+            local dropin_dir="${initdir:?}/etc/systemd/system/testsuite-${TESTID:?}.service.d"
594167
+            mkdir -p "$dropin_dir"
594167
+            printf '[Service]\nStandardOutput=journal+console\nStandardError=journal+console' >"$dropin_dir/99-stdout.conf"
594167
+        fi
594167
+
594167
         if get_bool "$hook_defined"; then
594167
             test_append_files "${initdir:?}"
594167
         fi
594167
diff --git a/test/units/testsuite-22.service b/test/units/testsuite-22.service
594167
index b9ecc4c5d6..a5ed660c62 100644
594167
--- a/test/units/testsuite-22.service
594167
+++ b/test/units/testsuite-22.service
594167
@@ -9,5 +9,3 @@ Wants=getty-pre.target
594167
 ExecStartPre=rm -f /failed /testok
594167
 ExecStart=/usr/lib/systemd/tests/testdata/units/%N.sh
594167
 Type=oneshot
594167
-StandardOutput=tty
594167
-StandardError=tty
594167
diff --git a/test/units/testsuite-35.service b/test/units/testsuite-35.service
594167
index 556a57a384..0599f6104e 100644
594167
--- a/test/units/testsuite-35.service
594167
+++ b/test/units/testsuite-35.service
594167
@@ -5,6 +5,4 @@ Description=TEST-35-LOGIN
594167
 [Service]
594167
 ExecStartPre=rm -f /failed /testok
594167
 ExecStart=/usr/lib/systemd/tests/testdata/units/%N.sh
594167
-StandardOutput=journal+console
594167
-StandardError=journal+console
594167
 Type=oneshot
594167
diff --git a/test/units/testsuite-45.service b/test/units/testsuite-45.service
594167
index 79c0a6f117..b16ce9933f 100644
594167
--- a/test/units/testsuite-45.service
594167
+++ b/test/units/testsuite-45.service
594167
@@ -5,6 +5,4 @@ Description=TEST-45-TIMEDATE
594167
 [Service]
594167
 ExecStartPre=rm -f /failed /testok
594167
 ExecStart=/usr/lib/systemd/tests/testdata/units/%N.sh
594167
-StandardOutput=journal+console
594167
-StandardError=journal+console
594167
 Type=oneshot
594167
diff --git a/test/units/testsuite-64.service b/test/units/testsuite-64.service
594167
index 10b61e7e53..f75a3d7aad 100644
594167
--- a/test/units/testsuite-64.service
594167
+++ b/test/units/testsuite-64.service
594167
@@ -6,5 +6,3 @@ Description=TEST-64-UDEV
594167
 ExecStartPre=rm -f /failed /testok
594167
 ExecStart=/usr/lib/systemd/tests/testdata/units/%N.sh
594167
 Type=oneshot
594167
-StandardOutput=journal+console
594167
-StandardError=journal+console
594167
diff --git a/test/units/testsuite-71.service b/test/units/testsuite-71.service
594167
index 019e8bff24..1718629c05 100644
594167
--- a/test/units/testsuite-71.service
594167
+++ b/test/units/testsuite-71.service
594167
@@ -5,6 +5,4 @@ Description=TEST-71-HOSTNAME
594167
 [Service]
594167
 ExecStartPre=rm -f /failed /testok
594167
 ExecStart=/usr/lib/systemd/tests/testdata/units/%N.sh
594167
-StandardOutput=journal+console
594167
-StandardError=journal+console
594167
 Type=oneshot
594167
diff --git a/test/units/testsuite-73.service b/test/units/testsuite-73.service
594167
index bee8c4215d..3ebd24da18 100644
594167
--- a/test/units/testsuite-73.service
594167
+++ b/test/units/testsuite-73.service
594167
@@ -5,6 +5,4 @@ Description=TEST-73-LOCALE
594167
 [Service]
594167
 ExecStartPre=rm -f /failed /testok
594167
 ExecStart=/usr/lib/systemd/tests/testdata/units/%N.sh
594167
-StandardOutput=journal+console
594167
-StandardError=journal+console
594167
 Type=oneshot