summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2022-06-18 10:45:22 +0900
committerGitHub <noreply@github.com>2022-06-18 10:45:22 +0900
commit297cc64bfbabfc73ae1a4ffb7aa3e1e8592f0a62 (patch)
tree38395461767813d21ee4a838d8f023f9c7bd103b /test
parent25ed7633b1d231acf61246bbdca29faa80d7f00f (diff)
parent8cda7b91ff267fc21325d4886980e243389a7566 (diff)
downloadsystemd-297cc64bfbabfc73ae1a4ffb7aa3e1e8592f0a62.tar.gz
Merge pull request #23771 from mrc0mmand/test-tweaks
A couple of test-output-related tweaks
Diffstat (limited to 'test')
-rwxr-xr-xtest/TEST-52-HONORFIRSTSHUTDOWN/test.sh13
-rw-r--r--test/test-functions28
-rwxr-xr-xtest/units/testsuite-02.sh9
-rwxr-xr-xtest/units/testsuite-20.sh1
-rwxr-xr-xtest/units/testsuite-23.sh1
-rwxr-xr-xtest/units/testsuite-27.sh1
-rwxr-xr-xtest/units/testsuite-30.sh1
-rwxr-xr-xtest/units/testsuite-32.sh1
-rwxr-xr-xtest/units/testsuite-34.sh1
-rwxr-xr-xtest/units/testsuite-38.sh9
-rwxr-xr-xtest/units/testsuite-39.sh1
-rwxr-xr-xtest/units/testsuite-40.sh1
-rwxr-xr-xtest/units/testsuite-41.sh1
-rwxr-xr-xtest/units/testsuite-46.sh1
-rwxr-xr-xtest/units/testsuite-47.sh1
-rwxr-xr-xtest/units/testsuite-52.sh1
-rwxr-xr-xtest/units/testsuite-55.sh1
-rwxr-xr-xtest/units/testsuite-59.sh1
-rwxr-xr-xtest/units/testsuite-62.sh1
-rwxr-xr-xtest/units/testsuite-66.sh1
20 files changed, 29 insertions, 46 deletions
diff --git a/test/TEST-52-HONORFIRSTSHUTDOWN/test.sh b/test/TEST-52-HONORFIRSTSHUTDOWN/test.sh
index 936e801c51..6a1ec9ca29 100755
--- a/test/TEST-52-HONORFIRSTSHUTDOWN/test.sh
+++ b/test/TEST-52-HONORFIRSTSHUTDOWN/test.sh
@@ -14,15 +14,10 @@ TEST_NO_QEMU=1
# could turn into a reboot if the test fails.
NSPAWN_TIMEOUT=60
-# Remove this file if it exists. This is used along with
-# the make target "finish". Since concrete confirmation is
-# only found from the console during the poweroff.
-rm -f /tmp/honorfirstshutdown.log >/dev/null
-
check_result_nspawn_hook() {
- grep -q "Shutdown is already active. Skipping emergency action request" /tmp/honorfirstshutdown.log
+ local workspace="${1:?}"
+
+ "${JOURNALCTL:?}" -D "${workspace:?}/var/log/journal" --grep "Shutdown is already active. Skipping emergency action request" --no-pager
}
-# Note: don't use a pipe in the following expression, as it breaks the trap
-# handlers we have defined in test/test-functions.
-do_test "$@" > >(tee /tmp/honorfirstshutdown.log)
+do_test "$@"
diff --git a/test/test-functions b/test/test-functions
index 98650a503f..b3844f246c 100644
--- a/test/test-functions
+++ b/test/test-functions
@@ -1502,17 +1502,17 @@ check_result_nspawn() {
local workspace="${1:?}"
local ret
- check_result_common "${workspace}"
- ret=$?
-
- # Run additional test-specific checks if defined by check_result_nspawn_hook()
+ # Run a test-specific checks if defined by check_result_nspawn_hook()
if declare -F check_result_nspawn_hook >/dev/null; then
- if ! check_result_nspawn_hook; then
+ if ! check_result_nspawn_hook "${workspace}"; then
derror "check_result_nspawn_hook() returned with EC > 0"
ret=4
fi
fi
+ check_result_common "${workspace}"
+ ret=$?
+
_umount_dir "${initdir:?}"
return $ret
@@ -1523,19 +1523,19 @@ check_result_qemu() {
local ret
mount_initdir
- check_result_common "${initdir:?}"
- ret=$?
-
- _umount_dir "${initdir:?}"
-
- # Run additional test-specific checks if defined by check_result_qemu_hook()
+ # Run a test-specific checks if defined by check_result_qemu_hook()
if declare -F check_result_qemu_hook >/dev/null; then
- if ! check_result_qemu_hook; then
+ if ! check_result_qemu_hook "${initdir:?}"; then
derror "check_result_qemu_hook() returned with EC > 0"
ret=4
fi
fi
+ check_result_common "${initdir:?}"
+ ret=$?
+
+ _umount_dir "${initdir:?}"
+
return $ret
}
@@ -2484,9 +2484,9 @@ inst_binary() {
# Same as above, but we need to wrap certain libraries unconditionally
#
- # login - dlopen()s (not only) systemd's PAM modules
+ # login, useradd, userdel - dlopen()s (not only) systemd's PAM modules
# tar - called by machinectl in TEST-25
- if get_bool "$IS_BUILT_WITH_ASAN" && [[ "$bin" =~ /(login|tar)$ ]]; then
+ if get_bool "$IS_BUILT_WITH_ASAN" && [[ "$bin" =~ /(login|tar|useradd|userdel)$ ]]; then
wrap_binary=1
fi
diff --git a/test/units/testsuite-02.sh b/test/units/testsuite-02.sh
index af6e007825..8ebcc575ee 100755
--- a/test/units/testsuite-02.sh
+++ b/test/units/testsuite-02.sh
@@ -49,6 +49,7 @@ function report_result() {
systemd-cat cat "/$name.log"
}
+set +x
# Associative array for running tasks, where running[test-path]=PID
declare -A running=()
for task in "${TEST_LIST[@]}"; do
@@ -60,7 +61,7 @@ for task in "${TEST_LIST[@]}"; do
# Task has finished, report its result and drop it from the queue
wait "${running[$key]}" && ec=0 || ec=$?
report_result "$key" $ec
- unset running["$key"]
+ unset "running[$key]"
# Break from inner for loop and outer while loop to skip
# the sleep below when we find a free slot in the queue
break 2
@@ -72,6 +73,7 @@ for task in "${TEST_LIST[@]}"; do
done
if [[ -x $task ]]; then
+ echo "Executing test '$task'"
log_file="/${task##*/}.log"
$task &>"$log_file" &
running[$task]=$!
@@ -80,11 +82,14 @@ done
# Wait for remaining running tasks
for key in "${!running[@]}"; do
+ echo "Waiting for test '$key' to finish"
wait ${running[$key]} && ec=0 || ec=$?
report_result "$key" $ec
- unset running["$key"]
+ unset "running[$key]"
done
+set -x
+
# Test logs are sometimes lost, as the system shuts down immediately after
journalctl --sync
diff --git a/test/units/testsuite-20.sh b/test/units/testsuite-20.sh
index fc87c18c4c..338769aacc 100755
--- a/test/units/testsuite-20.sh
+++ b/test/units/testsuite-20.sh
@@ -4,7 +4,6 @@ set -eux
set -o pipefail
systemd-analyze log-level debug
-systemd-analyze log-target console
test "$(systemctl show -P MainPID testsuite-20.service)" -eq $$
diff --git a/test/units/testsuite-23.sh b/test/units/testsuite-23.sh
index 46e45c8780..e8f99ff60d 100755
--- a/test/units/testsuite-23.sh
+++ b/test/units/testsuite-23.sh
@@ -4,7 +4,6 @@ set -eux
set -o pipefail
systemd-analyze log-level debug
-systemd-analyze log-target console
# Create a binary for which execve() will fail
touch /tmp/brokenbinary
diff --git a/test/units/testsuite-27.sh b/test/units/testsuite-27.sh
index 3b2f925153..c0701f35c3 100755
--- a/test/units/testsuite-27.sh
+++ b/test/units/testsuite-27.sh
@@ -4,7 +4,6 @@ set -eux
set -o pipefail
systemd-analyze log-level debug
-systemd-analyze log-target console
systemd-run --wait --unit=test27-one \
-p StandardOutput=file:/tmp/stdout \
diff --git a/test/units/testsuite-30.sh b/test/units/testsuite-30.sh
index 51b9bdd093..57f46669f9 100755
--- a/test/units/testsuite-30.sh
+++ b/test/units/testsuite-30.sh
@@ -4,7 +4,6 @@ set -eux
set -o pipefail
systemd-analyze log-level debug
-systemd-analyze log-target console
systemctl disable --now systemd-timesyncd.service
diff --git a/test/units/testsuite-32.sh b/test/units/testsuite-32.sh
index 20ab67f6f1..5c289d0abf 100755
--- a/test/units/testsuite-32.sh
+++ b/test/units/testsuite-32.sh
@@ -11,7 +11,6 @@ set -o pipefail
if test -f /sys/fs/cgroup/system.slice/testsuite-32.service/memory.oom.group; then
systemd-analyze log-level debug
- systemd-analyze log-target console
# Run a service that is guaranteed to be the first candidate for OOM killing
systemd-run --unit=oomtest.service \
diff --git a/test/units/testsuite-34.sh b/test/units/testsuite-34.sh
index 57a7b950a0..e6171beaa6 100755
--- a/test/units/testsuite-34.sh
+++ b/test/units/testsuite-34.sh
@@ -4,7 +4,6 @@ set -eux
set -o pipefail
systemd-analyze log-level debug
-systemd-analyze log-target console
function test_directory() {
local directory="$1"
diff --git a/test/units/testsuite-38.sh b/test/units/testsuite-38.sh
index f2f61b961f..c5f9bcc22c 100755
--- a/test/units/testsuite-38.sh
+++ b/test/units/testsuite-38.sh
@@ -5,7 +5,6 @@ set -eux
set -o pipefail
systemd-analyze log-level debug
-systemd-analyze log-target console
unit=testsuite-38-sleep.service
@@ -18,7 +17,7 @@ dbus_freeze() {
local name object_path suffix
suffix="${1##*.}"
- name="${1%.$suffix}"
+ name="${1%".$suffix"}"
object_path="/org/freedesktop/systemd1/unit/${name//-/_2d}_2e${suffix}"
busctl call \
@@ -32,7 +31,7 @@ dbus_thaw() {
local name object_path suffix
suffix="${1##*.}"
- name="${1%.$suffix}"
+ name="${1%".$suffix"}"
object_path="/org/freedesktop/systemd1/unit/${name//-/_2d}_2e${suffix}"
busctl call \
@@ -66,7 +65,7 @@ dbus_can_freeze() {
local name object_path suffix
suffix="${1##*.}"
- name="${1%.$suffix}"
+ name="${1%".$suffix"}"
object_path="/org/freedesktop/systemd1/unit/${name//-/_2d}_2e${suffix}"
busctl get-property \
@@ -80,7 +79,7 @@ check_freezer_state() {
local name object_path suffix
suffix="${1##*.}"
- name="${1%.$suffix}"
+ name="${1%".$suffix"}"
object_path="/org/freedesktop/systemd1/unit/${name//-/_2d}_2e${suffix}"
for _ in {0..10}; do
diff --git a/test/units/testsuite-39.sh b/test/units/testsuite-39.sh
index 03abf391f1..5b77bbbaf1 100755
--- a/test/units/testsuite-39.sh
+++ b/test/units/testsuite-39.sh
@@ -4,7 +4,6 @@ set -eux
set -o pipefail
systemd-analyze log-level debug
-systemd-analyze log-target console
export SYSTEMD_PAGER=
SERVICE_PATH="$(mktemp /etc/systemd/system/execreloadXXX.service)"
diff --git a/test/units/testsuite-40.sh b/test/units/testsuite-40.sh
index dd54fa174c..cec1fd3a7a 100755
--- a/test/units/testsuite-40.sh
+++ b/test/units/testsuite-40.sh
@@ -4,7 +4,6 @@ set -eux
set -o pipefail
systemd-analyze log-level debug
-systemd-analyze log-target console
declare -A property
diff --git a/test/units/testsuite-41.sh b/test/units/testsuite-41.sh
index 3b41db03f5..13bc684c2d 100755
--- a/test/units/testsuite-41.sh
+++ b/test/units/testsuite-41.sh
@@ -7,7 +7,6 @@ set -o pipefail
MAX_SECS=60
systemd-analyze log-level debug
-systemd-analyze log-target console
# test one: Restart=on-failure should restart the service
systemd-run --unit=one -p Type=oneshot -p Restart=on-failure /bin/bash -c "exit 1" \
diff --git a/test/units/testsuite-46.sh b/test/units/testsuite-46.sh
index 82da3b755c..9d090654bc 100755
--- a/test/units/testsuite-46.sh
+++ b/test/units/testsuite-46.sh
@@ -34,7 +34,6 @@ wait_for_state() {
}
systemd-analyze log-level debug
-systemd-analyze log-target console
systemctl service-log-level systemd-homed debug
# Create a tmpfs to use as backing store for the home dir. That way we can enforce a size limit nicely.
diff --git a/test/units/testsuite-47.sh b/test/units/testsuite-47.sh
index ff10602df7..529e9617a5 100755
--- a/test/units/testsuite-47.sh
+++ b/test/units/testsuite-47.sh
@@ -4,7 +4,6 @@ set -eux
set -o pipefail
systemd-analyze log-level debug
-systemd-analyze log-target console
systemctl start testsuite-47-repro
sleep 4
diff --git a/test/units/testsuite-52.sh b/test/units/testsuite-52.sh
index 8a76ff6ed6..d78fdd53ba 100755
--- a/test/units/testsuite-52.sh
+++ b/test/units/testsuite-52.sh
@@ -4,7 +4,6 @@ set -ex
set -o pipefail
systemd-analyze log-level debug
-systemd-analyze log-target console
systemctl enable test-honor-first-shutdown.service
systemctl start test-honor-first-shutdown.service
diff --git a/test/units/testsuite-55.sh b/test/units/testsuite-55.sh
index 009933e665..8fa1d01fd0 100755
--- a/test/units/testsuite-55.sh
+++ b/test/units/testsuite-55.sh
@@ -4,7 +4,6 @@ set -eux
set -o pipefail
systemd-analyze log-level debug
-systemd-analyze log-target console
# Loose checks to ensure the environment has the necessary features for systemd-oomd
[[ -e /proc/pressure ]] || echo "no PSI" >>/skipped
diff --git a/test/units/testsuite-59.sh b/test/units/testsuite-59.sh
index 143e44ec63..83db053107 100755
--- a/test/units/testsuite-59.sh
+++ b/test/units/testsuite-59.sh
@@ -28,7 +28,6 @@ wait_on_state_or_fail () {
}
systemd-analyze log-level debug
-systemd-analyze log-target console
cat >/run/systemd/system/testservice-fail-59.service <<EOF
diff --git a/test/units/testsuite-62.sh b/test/units/testsuite-62.sh
index da40c2f1e7..04b79b7e77 100755
--- a/test/units/testsuite-62.sh
+++ b/test/units/testsuite-62.sh
@@ -5,7 +5,6 @@ set -o pipefail
setup() {
systemd-analyze log-level debug
- systemd-analyze log-target console
for i in {0..3};
do
diff --git a/test/units/testsuite-66.sh b/test/units/testsuite-66.sh
index fba42d15df..7a88e5bcba 100755
--- a/test/units/testsuite-66.sh
+++ b/test/units/testsuite-66.sh
@@ -6,7 +6,6 @@ set -o pipefail
RESULTS_FILE=/tmp/testsuite66serviceresults
systemd-analyze log-level debug
-systemd-analyze log-target console
systemctl start testsuite-66-deviceisolation.service