summaryrefslogtreecommitdiffstats
path: root/test/TEST-74-AUX-UTILS
diff options
context:
space:
mode:
authorMatteo Croce <teknoraver@meta.com>2024-10-05 01:39:37 +0200
committerMatteo Croce <teknoraver@meta.com>2024-10-11 22:54:16 +0200
commit9784ed760eebbc12407c919d787e9bb1fa7fbc62 (patch)
tree93e3dc025c9005b052ac84ca0550161034b3d1ee /test/TEST-74-AUX-UTILS
parenttimer: introduce DeferReactivation setting (diff)
downloadsystemd-9784ed760eebbc12407c919d787e9bb1fa7fbc62.tar.xz
systemd-9784ed760eebbc12407c919d787e9bb1fa7fbc62.zip
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.
Diffstat (limited to 'test/TEST-74-AUX-UTILS')
-rw-r--r--test/TEST-74-AUX-UTILS/TEST-74-AUX-UTILS.units/realtime-test.service6
-rw-r--r--test/TEST-74-AUX-UTILS/TEST-74-AUX-UTILS.units/realtime-test.timer10
-rw-r--r--test/TEST-74-AUX-UTILS/meson.build2
3 files changed, 18 insertions, 0 deletions
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']