From 8794bbf773d1559842481e8eb2ef72a54f8bd01d Mon Sep 17 00:00:00 2001 From: Andrew Savinykh <658865+AndrewSav@users.noreply.github.com> Date: Thu, 22 Oct 2026 07:52:00 +0000 Subject: [PATCH] Wait for clamd's finish script before restarting it in the reload test The "cron user's reload waits for clamd to start" test stopped clamd and sent s6-svc -u as soon as the clamd process was gone. On exit code 0, clamd's finish script sends its own s6-svc -d, and that runs after the process exits. When the test's -u landed before it, clamd stayed down, the reload's ping timed out, and the test failed with "Could not connect to clamd". s6-svc -wD -d returns only once the finish script has exited. --- test/default.bats | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/default.bats b/test/default.bats index eee9dce..5056f97 100644 --- a/test/default.bats +++ b/test/default.bats @@ -781,7 +781,9 @@ sigs_cron_job() { @test "checking clamav-unofficial-sigs: cron user's reload waits for clamd to start" { reloads() { docker exec mailserver_default grep -c 'Database correctly reloaded' /var/log/clamav/clamav.log || true; } before=$(reloads) - docker exec mailserver_default /bin/sh -c "s6-svc -d /services/clamd; while pgrep -x clamd > /dev/null; do sleep 0.2; done; s6-svc -u /services/clamd" + # Wait for clamd's finish script as well as clamd (-wD): on exit code 0 the + # finish script sends its own s6-svc -d, which undoes a -u sent before it. + docker exec mailserver_default /bin/sh -c "s6-svc -wD -d /services/clamd; s6-svc -u /services/clamd" run docker exec mailserver_default /bin/sh -c ". /etc/clamav-unofficial-sigs/os.conf; user=\$(grep -v '^#' /etc/cron.d/clamav-unofficial-sigs | grep . | awk '{print \$6}'); su -s /bin/sh \"\$user\" -c \"\$clamd_reload_opt\"" assert_success refute_output --partial 'ERROR'