Merge pull request #28368 from mrc0mmand/test-fail-on-error

test: a couple of clean ups
This commit is contained in:
Luca Boccassi
2023-07-12 23:51:42 +01:00
committed by GitHub
52 changed files with 58 additions and 162 deletions
+2 -1
View File
@@ -36,6 +36,7 @@ fi
# Collect failed units & do one daemon-reload to a basic sanity check
systemctl --state=failed --no-legend --no-pager | tee /failed
test ! -s /failed
systemctl daemon-reload
# Check that the early setup is actually skipped on reexec.
@@ -44,4 +45,4 @@ systemctl daemon-reload
# of systemd-analyze blame. See issue #27187.
systemd-analyze blame
echo OK >/testok
touch /testok
+4 -3
View File
@@ -23,7 +23,7 @@ MAX_QUEUE_SIZE=${NPROC:-2}
mapfile -t TEST_LIST < <(find /usr/lib/systemd/tests/unit-tests/ -maxdepth 1 -type f -name "${TESTS_GLOB}")
# Reset state
rm -fv /failed-tests /skipped-tests /skipped
rm -fv /failed /skipped /testok
if ! systemd-detect-virt -qc; then
# Make sure ping works for unprivileged users (for test-bpf-firewall)
@@ -34,7 +34,7 @@ fi
# Arguments:
# $1: test path
# $2: test exit code
function report_result() {
report_result() {
if [[ $# -ne 2 ]]; then
echo >&2 "check_result: missing arguments"
exit 1
@@ -112,4 +112,5 @@ set -x
# Test logs are sometimes lost, as the system shuts down immediately after
journalctl --sync
exit 0
test ! -s /failed
touch /testok
-3
View File
@@ -9,9 +9,6 @@ trap "journalctl --rotate --vacuum-size=16M" EXIT
# shellcheck source=test/units/test-control.sh
. "$(dirname "$0")"/test-control.sh
: >/failed
run_subtests
touch /testok
rm /failed
-3
View File
@@ -6,8 +6,6 @@ set -o pipefail
# shellcheck source=test/units/test-control.sh
. "$(dirname "$0")"/test-control.sh
: >/failed
# Issue: https://github.com/systemd/systemd/issues/2730
# See TEST-07-PID1/test.sh for the first "half" of the test
mountpoint /issue2730
@@ -15,4 +13,3 @@ mountpoint /issue2730
run_subtests
touch /testok
rm /failed
-3
View File
@@ -6,9 +6,6 @@ set -o pipefail
# shellcheck source=test/units/test-control.sh
. "$(dirname "$0")"/test-control.sh
: >/failed
run_subtests
touch /testok
rm /failed
+17 -17
View File
@@ -6,7 +6,7 @@ set -o pipefail
# shellcheck source=test/units/test-control.sh
. "$(dirname "$0")"/test-control.sh
clear_unit () {
clear_unit() {
local UNIT_NAME="${1:?}"
systemctl stop "$UNIT_NAME" 2>/dev/null || :
rm -f /{etc,run,usr/lib}/systemd/system/"$UNIT_NAME"
@@ -22,14 +22,14 @@ clear_unit () {
fi
}
clear_units () {
clear_units() {
for u in "$@"; do
clear_unit "$u"
done
systemctl daemon-reload
}
create_service () {
create_service() {
local SERVICE_NAME="${1:?}"
clear_units "${SERVICE_NAME}".service
@@ -43,13 +43,13 @@ EOF
mkdir -p /{etc,run,usr/lib}/systemd/system/"$SERVICE_NAME".service.{d,wants,requires}
}
create_services () {
create_services() {
for u in "$@"; do
create_service "$u"
done
}
check_ok () {
check_ok() {
x="$(systemctl show --value -p "${2:?}" "${1:?}")"
case "$x" in
*${3:?}*) return 0 ;;
@@ -57,11 +57,11 @@ check_ok () {
esac
}
check_ko () {
check_ko() {
! check_ok "$@"
}
testcase_basic_dropins () {
testcase_basic_dropins() {
echo "Testing basic dropins..."
echo "*** test a wants b wants c"
@@ -127,7 +127,7 @@ EOF
clear_units test15-{a,b,c,c1}.service
}
testcase_linked_units () {
testcase_linked_units() {
echo "Testing linked units..."
echo "*** test linked unit (same basename)"
@@ -180,7 +180,7 @@ testcase_template_alias() {
clear_units test15-{a,b}@.service
}
testcase_hierarchical_service_dropins () {
testcase_hierarchical_service_dropins() {
echo "Testing hierarchical service dropins..."
echo "*** test service.d/ top level drop-in"
create_services a-b-c
@@ -226,7 +226,7 @@ ExecCondition=echo $dropin
clear_units a-b-c.service
}
testcase_hierarchical_slice_dropins () {
testcase_hierarchical_slice_dropins() {
echo "Testing hierarchical slice dropins..."
echo "*** test slice.d/ top level drop-in"
# Slice units don't even need a fragment, so we test the defaults here
@@ -285,7 +285,7 @@ MemoryMax=1000000001
clear_units a-b-c.slice
}
testcase_transient_service_dropins () {
testcase_transient_service_dropins() {
echo "Testing dropins for a transient service..."
echo "*** test transient service drop-ins"
@@ -320,7 +320,7 @@ testcase_transient_service_dropins () {
/etc/systemd/system/a-b-.service.d/drop3.conf
}
testcase_transient_slice_dropins () {
testcase_transient_slice_dropins() {
echo "Testing dropins for a transient slice..."
echo "*** test transient slice drop-ins"
@@ -370,7 +370,7 @@ testcase_transient_slice_dropins () {
/etc/systemd/system/a-b-.slice.d/drop3.conf
}
testcase_template_dropins () {
testcase_template_dropins() {
echo "Testing template dropins..."
create_services foo bar@ yup@
@@ -519,7 +519,7 @@ EOF
clear_units foo.service {bar,yup,bar-alias}@{,1,2,3}.service
}
testcase_alias_dropins () {
testcase_alias_dropins() {
echo "Testing alias dropins..."
echo "*** test a wants b1 alias of b"
@@ -551,7 +551,7 @@ testcase_alias_dropins () {
clear_units test15-{a,x,y}.service
}
testcase_masked_dropins () {
testcase_masked_dropins() {
echo "Testing masked dropins..."
create_services test15-a test15-b
@@ -672,7 +672,7 @@ EOF
clear_units test15-{a,b}.service
}
testcase_invalid_dropins () {
testcase_invalid_dropins() {
echo "Testing invalid dropins..."
# Assertion failed on earlier versions, command exits unsuccessfully on later versions
systemctl cat nonexistent@.service || true
@@ -685,7 +685,7 @@ testcase_invalid_dropins () {
return 0
}
testcase_symlink_dropin_directory () {
testcase_symlink_dropin_directory() {
# For issue #21920.
echo "Testing symlink drop-in directory..."
create_services test15-a
+2 -3
View File
@@ -7,7 +7,7 @@ rm -f /test.log
TESTLOG=/test.log.XXXXXXXX
function wait_for()
wait_for()
{
local service="${1:-wait_for: missing service argument}"
local result="${2:-success}"
@@ -23,7 +23,7 @@ function wait_for()
fi
}
function wait_for_timeout()
wait_for_timeout()
{
local unit="$1"
local time="$2"
@@ -117,4 +117,3 @@ if [[ -f "$TESTLOG" ]]; then
fi
touch /testok
exit 0
-3
View File
@@ -6,11 +6,8 @@ set -o pipefail
# shellcheck source=test/units/test-control.sh
. "$(dirname "$0")"/test-control.sh
: >/failed
udevadm settle
run_subtests
touch /testok
rm /failed
-3
View File
@@ -3,12 +3,9 @@
set -eux
set -o pipefail
: >/failed
# shellcheck source=test/units/test-control.sh
. "$(dirname "$0")"/test-control.sh
run_subtests
touch /testok
rm /failed
+1 -3
View File
@@ -107,6 +107,4 @@ for bus in "${SESSION_BUS_LIST[@]}"; do
systemctl --machine 'testuser@.host' --user daemon-reexec
done
echo OK >/testok
exit 0
touch /testok
-3
View File
@@ -6,9 +6,6 @@ set -o pipefail
# shellcheck source=test/units/test-control.sh
. "$(dirname "$0")"/test-control.sh
: >/failed
run_subtests
touch /testok
rm /failed
-3
View File
@@ -3,8 +3,6 @@
set -eux
set -o pipefail
: >/failed
# shellcheck source=test/units/test-control.sh
. "$(dirname "$0")"/test-control.sh
@@ -12,4 +10,3 @@ set -o pipefail
run_subtests_with_signals SIGUSR1 SIGUSR2 SIGRTMIN+1
touch /testok
rm /failed
+1 -1
View File
@@ -213,4 +213,4 @@ cryptsetup_start_and_check -f detached_fail{0..4}
cryptsetup_start_and_check detached_slot{0..1}
cryptsetup_start_and_check -f detached_slot_fail
echo OK >/testok
touch /testok
+1 -3
View File
@@ -140,6 +140,4 @@ machinectl remove scratch5
test ! -f /var/lib/machines/scratch5
(! machinectl image-status scratch5)
echo OK >/testok
exit 0
touch /testok
-3
View File
@@ -7,8 +7,6 @@ set -o pipefail
# shellcheck source=test/units/util.sh
. "$(dirname "$0")"/util.sh
: >/failed
at_exit() {
if [[ -v UNIT_NAME && -e "/usr/lib/systemd/system/$UNIT_NAME" ]]; then
rm -fvr "/usr/lib/systemd/system/$UNIT_NAME" "/etc/systemd/system/$UNIT_NAME.d" "+4"
@@ -463,4 +461,3 @@ systemctl enable --now test-WantedBy.service || :
systemctl daemon-reload
touch /testok
rm /failed
+1 -3
View File
@@ -231,6 +231,4 @@ touch /tmp/emptyext/usr/lib/extension-release.d/extension-release.emptyext
res="$(! portablectl attach --extension /tmp/emptyext /tmp/emptyroot 2> >(grep "Remote peer disconnected"))"
test -z "${res}"
echo OK >/testok
exit 0
touch /testok
+1 -3
View File
@@ -26,6 +26,4 @@ while test ! -f /tmp/clock-changed ; do sleep .5 ; done
systemd-analyze log-level info
echo OK >/testok
exit 0
touch /testok
+1 -2
View File
@@ -7,5 +7,4 @@ if journalctl -b -t systemd --grep '\.device: Changed plugged -> dead'; then
exit 1
fi
echo OK >/testok
exit 0
touch /testok
+1 -3
View File
@@ -33,6 +33,4 @@ if test -f /sys/fs/cgroup/system.slice/testsuite-32.service/memory.oom.group; th
systemd-analyze log-level info
fi
echo OK >/testok
exit 0
touch /testok
+1 -3
View File
@@ -157,6 +157,4 @@ test_check_writable
systemd-analyze log-level info
echo OK >/testok
exit 0
touch /testok
-3
View File
@@ -653,11 +653,8 @@ EOF
rm -f "$SCRIPT" "$PAMSERVICE"
}
: >/failed
setup_test_user
test_enable_debug
run_testcases
touch /testok
rm /failed
+1 -3
View File
@@ -349,6 +349,4 @@ systemctl daemon-reload
systemd-analyze log-level info
echo OK >/testok
exit 0
touch /testok
+1 -2
View File
@@ -298,5 +298,4 @@ if [[ -e /sys/fs/cgroup/system.slice/cgroup.freeze ]]; then
run_testcases
fi
echo OK >/testok
exit 0
touch /testok
+1 -3
View File
@@ -135,6 +135,4 @@ fi
systemd-analyze log-level info
echo OK >/testok
exit 0
touch /testok
+1 -3
View File
@@ -15,6 +15,4 @@ grep "^hello world$" /tmp/hello-world
systemd-analyze log-level info
echo OK >/testok
exit 0
touch /testok
-3
View File
@@ -277,9 +277,6 @@ EOF
assert_rc 3 systemctl is-active --quiet systemd-timesyncd
}
: >/failed
run_testcases
touch /testok
rm /failed
+1 -3
View File
@@ -308,6 +308,4 @@ done
systemd-analyze log-level info
echo OK >/testok
exit 0
touch /testok
+1 -3
View File
@@ -551,6 +551,4 @@ echo abc > abc
systemd-dissect --copy-to /tmp/img abc /abc
test -f /tmp/img/abc
echo OK >/testok
exit 0
touch /testok
+1 -3
View File
@@ -8,6 +8,4 @@ systemd-analyze log-level debug
systemctl enable test-honor-first-shutdown.service
systemctl start test-honor-first-shutdown.service
echo OK >/testok
exit 0
touch /testok
+1 -3
View File
@@ -316,6 +316,4 @@ fi
systemd-analyze log-level info
echo OK >/testok
exit 0
touch /testok
+1 -3
View File
@@ -174,6 +174,4 @@ fi
systemd-analyze log-level info
echo OK >/testok
exit 0
touch /testok
+1 -3
View File
@@ -1183,6 +1183,4 @@ test_sector 1024
test_sector 2048
test_sector 4096
echo OK >/testok
exit 0
touch /testok
+3 -5
View File
@@ -3,7 +3,7 @@
set -eux
set -o pipefail
fail () {
fail() {
systemd-analyze log-level info
exit 1
}
@@ -11,7 +11,7 @@ fail () {
# Wait for a service to enter a state within a timeout period, if it doesn't
# enter the desired state within the timeout period then this function will
# exit the test case with a non zero exit code.
wait_on_state_or_fail () {
wait_on_state_or_fail() {
service=$1
expected_state=$2
timeout=$3
@@ -157,6 +157,4 @@ rm /run/notify-reload-test.sh
systemd-analyze log-level info
echo OK >/testok
exit 0
touch /testok
-3
View File
@@ -241,8 +241,6 @@ EOF
done
}
: >/failed
systemd-analyze log-level debug
systemd-analyze log-target journal
@@ -308,4 +306,3 @@ test_issue_23796
systemd-analyze log-level info
touch /testok
rm /failed
+1 -3
View File
@@ -60,6 +60,4 @@ systemctl start --wait testsuite-62-3.service
systemctl start --wait testsuite-62-4.service
systemctl start --wait testsuite-62-5.service
echo OK >/testok
exit 0
touch /testok
+1 -1
View File
@@ -82,4 +82,4 @@ assert_in "test63-issue-24577-dep.service" "$output"
systemctl log-level info
echo OK >/testok
touch /testok
-3
View File
@@ -1159,8 +1159,6 @@ testcase_mdadm_lvm() {
helper_check_device_units
}
: >/failed
udevadm settle
udevadm control --log-level debug
lsblk -a
@@ -1187,4 +1185,3 @@ udevadm control --log-level info
systemctl status systemd-udevd
touch /testok
rm /failed
+1 -3
View File
@@ -845,6 +845,4 @@ systemd-analyze pcrs 14 7 0 ima
systemd-analyze log-level info
echo OK >/testok
exit 0
touch /testok
+1 -3
View File
@@ -21,6 +21,4 @@ grep -q "thisshouldnotbehere" "$RESULTS_FILE" && exit 42
systemd-analyze log-level info
echo OK >/testok
exit 0
touch /testok
+1 -1
View File
@@ -116,4 +116,4 @@ do
separate_data=0
done
echo OK >/testok
touch /testok
+2 -3
View File
@@ -6,7 +6,7 @@ set -o pipefail
# Wait for a service to enter a state within a timeout period, if it doesn't
# enter the desired state within the timeout period then this function will
# exit the test case with a non zero exit code.
wait_on_state_or_fail () {
wait_on_state_or_fail() {
service=$1
expected_state=$2
timeout=$3
@@ -212,6 +212,5 @@ systemctl start testservice-failure-68-template.service
wait_on_state_or_fail "testservice-failure-exit-handler-68-template@testservice-failure-68-template.service.service" "inactive" "10"
systemd-analyze log-level info
echo OK >/testok
exit 0
touch /testok
+1 -3
View File
@@ -316,6 +316,4 @@ systemd-cryptenroll --tpm2-pcrs=boot-loader-code+boot-loader-config "$img"
(! systemd-cryptenroll --wipe-slot=10240000 "$img")
(! systemd-cryptenroll --fido2-device=auto --unlock-fido2-device=auto "$img")
echo OK >/testok
exit 0
touch /testok
-3
View File
@@ -223,9 +223,6 @@ testcase_nss-myhostname() {
(! getent hosts -s myhostname fd00:dead:beef:cafe::1)
}
: >/failed
run_testcases
touch /testok
rm /failed
+1 -3
View File
@@ -202,6 +202,4 @@ verify_version v4 2048 4096
rm /var/tmp/72-joined.raw
rm -r /var/tmp/72-{dirs,defs,source,xbootldr,esp}
echo OK >/testok
exit 0
touch /testok
-3
View File
@@ -682,8 +682,6 @@ testcase_locale_gen_leading_space() {
localectl set-locale en_US.UTF-8
}
: >/failed
# Make sure the content of kbd-model-map is the one that the tests expect
# regardless of the version installed on the distro where the testsuite is
# running on.
@@ -693,4 +691,3 @@ enable_debug
run_testcases
touch /testok
rm /failed
-3
View File
@@ -6,9 +6,6 @@ set -o pipefail
# shellcheck source=test/units/test-control.sh
. "$(dirname "$0")"/test-control.sh
: >/failed
run_subtests
touch /testok
rm /failed
-3
View File
@@ -14,8 +14,6 @@ set -o pipefail
# shellcheck source=test/units/util.sh
. "$(dirname "$0")"/util.sh
: >/failed
RUN_OUT="$(mktemp)"
run() {
@@ -580,4 +578,3 @@ else
fi
touch /testok
rm /failed
+1 -2
View File
@@ -31,6 +31,5 @@ test "$(grep SigQ: /proc/"$P"/status | cut -d: -f2 | cut -d/ -f1)" -eq 6
systemctl stop $UNIT
systemd-analyze log-level info
echo OK >/testok
exit 0
touch /testok
+1 -2
View File
@@ -54,6 +54,5 @@ systemd-run -u "$UNIT" -p Type=exec -p ProtectControlGroups=1 -p DynamicUser=1 -
rm "$SCRIPT"
systemd-analyze log-level info
echo OK >/testok
exit 0
touch /testok
-5
View File
@@ -7,8 +7,6 @@ set -o pipefail
# shellcheck source=test/units/util.sh
. "$(dirname "$0")"/util.sh
: >/failed
mkfifo /tmp/syncfifo1 /tmp/syncfifo2
sync_in() {
@@ -126,6 +124,3 @@ assert_eq "$(systemctl show fdstore-pin.service -P SubState)" dead
assert_eq "$(systemctl show fdstore-nopin.service -P SubState)" dead
touch /testok
rm /failed
exit 0
-3
View File
@@ -6,9 +6,6 @@ set -o pipefail
# shellcheck source=test/units/test-control.sh
. "$(dirname "$0")"/test-control.sh
: >/failed
run_subtests
touch /testok
rm /failed
+1 -3
View File
@@ -140,8 +140,6 @@ EOF
fi
systemd-analyze log-level info
echo OK >/testok
touch /testok
systemctl --no-block poweroff
exit 0