From d52a6931643a384b1184b1c30badb739ff885f78 Mon Sep 17 00:00:00 2001 From: Clayton Craft Date: Fri, 14 Aug 2026 14:25:01 -0700 Subject: [PATCH] test: cover both of timesyncd's resolver paths This checks that we resolve through resolved when it's running, and fall back to getaddrinfo when it isn't. --- test/units/TEST-45-TIMEDATE.sh | 71 ++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) diff --git a/test/units/TEST-45-TIMEDATE.sh b/test/units/TEST-45-TIMEDATE.sh index 820c3ae9f5..0af99fc96c 100755 --- a/test/units/TEST-45-TIMEDATE.sh +++ b/test/units/TEST-45-TIMEDATE.sh @@ -248,6 +248,19 @@ assert_timesyncd_state() { return 1 } +assert_timesyncd_log() { + local cursor="${1:?}" + local match="${2:?}" + + for _ in {0..29}; do + journalctl --sync + journalctl -q -u systemd-timesyncd.service --after-cursor="$(<"$cursor")" --grep "$match" >/dev/null && return 0 + sleep .5 + done + + return 1 +} + testcase_ntp() { # timesyncd has ConditionVirtualization=!container by default; drop/mock that for testing if systemd-detect-virt --container --quiet; then @@ -409,6 +422,64 @@ EOF rm -f /run/systemd/network/ntp99.* } +teardown_timesyncd_resolve() { + set +eu + + systemctl start systemd-resolved-varlink.socket + systemctl start systemd-resolved.service + + rm -rf /run/systemd/system/systemd-timesyncd.service.d + systemctl daemon-reload + systemctl stop systemd-timesyncd +} + +testcase_timesyncd_resolve() { + local cursor + + if systemd-detect-virt -cq; then + echo "This test case requires a VM, skipping..." + return 0 + fi + + if ! command -v resolvectl >/dev/null; then + echo "This test requires systemd-resolved, skipping..." + return 0 + fi + + trap teardown_timesyncd_resolve RETURN + + mkdir -p /run/systemd/system/systemd-timesyncd.service.d + cat >/run/systemd/system/systemd-timesyncd.service.d/10-debug.conf <