1
0
mirror of https://github.com/systemd/systemd.git synced 2024-12-23 21:35:11 +03:00
systemd/test/units/TEST-74-AUX-UTILS.defer_reactivation.sh
Matteo Croce 9784ed760e timer: add unit tests for DeferReactivation
Create a unit test for systemd timer DeferReactivation config option.
The test works by creating a timer which fires every 5 seconds and
starts an unit which runs for 5 seconds.
With DeferReactivation=true, the timer must fire every 5+5 seconds,
instead of the 5 it fires normally.

As we need at least two timer runs to check if the delta is correct,
the test duration on success will be at least 20 seconds.
To be safe, the test script waits 35 seconds: this is enough to get
at least three runs but low enough to avoid clogging the CI.
2024-10-11 22:54:16 +02:00

24 lines
451 B
Bash
Executable File

#!/usr/bin/env bash
# SPDX-License-Identifier: LGPL-2.1-or-later
set -eux
set -o pipefail
systemctl start realtime-test.timer
sleep 35
mindelta=10
last=
while read -r time; do
if [ -n "$last" ]; then
delta=$((time - last))
if [ "$delta" -lt $mindelta ]; then
echo "Timer fired too early: $delta < $mindelta" >/failed
break
fi
fi
last=$time
done </tmp/realtime-test.log
test ! -s /failed