CI: the desktop runner works while its screen is locked or untouched for 15 min

Ludovic's rule (2026-10-26): runner_pause.py pauses at once on keyboard, mouse or gamepad input
(read from /dev/input, only whether bytes came), on an unlocked session touched in the last
15 min, at 90 °C, on a game or the GPU. Fixes the service start: the link loop's last test
failed the script under set -e.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Ludovic Marie
2026-10-26 00:27:22 +01:00
parent d81aa97e84
commit 0baf6cbd62
6 changed files with 113 additions and 36 deletions
+12 -1
View File
@@ -18,7 +18,7 @@ class Machine:
self.throttles = [] # (clock, on)
self.calls = []
def reason(self, hot):
def reason(self, hot, keys):
return next((reason for start, end, reason in self.signs if start <= self.clock < end), None)
def systemctl(self, *arguments):
@@ -77,6 +77,17 @@ class RunnerPauseTests(unittest.TestCase):
self.assertLess(stop, 1215)
self.assertEqual(machine.throttles[-1], (1290 + 300, False))
def test_the_desktop_is_free_when_locked_or_untouched_for_15_minutes(self):
cases = [ # (session, seconds since the last input, someone there)
(("3", False), 30, True), (("3", True), 30, True), # any input pauses at once, even on the lock screen
(("3", False), 120, True), (("3", False), 1000, False), # unlocked: free after 15 min untouched
(("3", True), 120, False), (None, 120, False), # locked, or nobody logged in
]
for session, idle, there in cases:
with self.subTest(session=session, idle=idle), \
mock.patch.object(runner_pause, "seat_session", lambda: session):
self.assertEqual(runner_pause.at_the_screen(idle) is not None, there)
if __name__ == "__main__":
unittest.main()