diff --git a/test/TEST-74-AUX-UTILS/TEST-74-AUX-UTILS.units/realtime-test.service b/test/TEST-74-AUX-UTILS/TEST-74-AUX-UTILS.units/realtime-test.service new file mode 100644 index 0000000000..a754626828 --- /dev/null +++ b/test/TEST-74-AUX-UTILS/TEST-74-AUX-UTILS.units/realtime-test.service @@ -0,0 +1,6 @@ +[Unit] +Description=Testing systemd timers + +[Service] +Type=simple +ExecStart=sh -c 'date +%%s >>/tmp/realtime-test.log ; sleep 5' diff --git a/test/TEST-74-AUX-UTILS/TEST-74-AUX-UTILS.units/realtime-test.timer b/test/TEST-74-AUX-UTILS/TEST-74-AUX-UTILS.units/realtime-test.timer new file mode 100644 index 0000000000..b870b41628 --- /dev/null +++ b/test/TEST-74-AUX-UTILS/TEST-74-AUX-UTILS.units/realtime-test.timer @@ -0,0 +1,10 @@ +[Unit] +Description=Testing systemd timers + +[Timer] +OnCalendar=*:*:0/5 +AccuracySec=1us +DeferReactivation=true + +[Install] +WantedBy=timers.target diff --git a/test/TEST-74-AUX-UTILS/meson.build b/test/TEST-74-AUX-UTILS/meson.build index 668ad492ca..543eee195f 100644 --- a/test/TEST-74-AUX-UTILS/meson.build +++ b/test/TEST-74-AUX-UTILS/meson.build @@ -7,3 +7,5 @@ integration_tests += [ 'vm' : true, }, ] + +testdata_subdirs += [meson.current_source_dir() / 'TEST-74-AUX-UTILS.units'] diff --git a/test/units/TEST-74-AUX-UTILS.defer_reactivation.sh b/test/units/TEST-74-AUX-UTILS.defer_reactivation.sh new file mode 100755 index 0000000000..d1b113d1ab --- /dev/null +++ b/test/units/TEST-74-AUX-UTILS.defer_reactivation.sh @@ -0,0 +1,23 @@ +#!/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