mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-18 12:28:40 +00:00
* fix: Steam can restart more than twice in a session Every exit 42 counted toward the cap that stops an update which will not install, and the count was never cleared, so the third restart of a session ended it however far apart they were. A client that ran for a minute before asking is not that loop: the count starts again. * fix: measure the client's run time as it exits The time spent collecting logs and checking FEX after the client exits counted toward its run, so a slow cleanup could make a quick exit 42 look like a long one and clear the count. --------- Co-authored-by: Kirk <12691869+KirkPatrickJunsay@users.noreply.github.com> Co-authored-by: Kurt Himebauch <136133082+xXJSONDeruloXx@users.noreply.github.com>
35 lines
1.4 KiB
Python
35 lines
1.4 KiB
Python
import re
|
|
import subprocess
|
|
import unittest
|
|
from pathlib import Path
|
|
|
|
SESSION = Path(__file__).resolve().parents[1] / "linuxfs/overlay/usr/local/bin/droiddeck-session"
|
|
|
|
|
|
def stuck_function():
|
|
match = re.search(r"^steam_update_stuck\(\) \{\n.*?^\}\n", SESSION.read_text(), re.M | re.S)
|
|
return match.group(0) if match else None
|
|
|
|
|
|
class SteamRestartCapTest(unittest.TestCase):
|
|
def restarts(self, *seconds_up):
|
|
function = stuck_function()
|
|
self.assertIsNotNone(function, "droiddeck-session has no steam_update_stuck()")
|
|
script = function + "steam_updates=0\nfor up in %s; do\n" % " ".join(map(str, seconds_up))
|
|
script += " if steam_update_stuck \"$up\"; then echo stop; else echo restart; fi\ndone\n"
|
|
return subprocess.run(["bash", "-c", script], capture_output=True, text=True, timeout=30,
|
|
check=True).stdout.split()
|
|
|
|
def test_an_update_that_keeps_asking_at_once_is_stopped_on_the_third(self):
|
|
self.assertEqual(["restart", "restart", "stop"], self.restarts(11, 13, 9))
|
|
|
|
def test_restarts_of_a_client_that_stayed_up_are_never_stopped(self):
|
|
self.assertEqual(["restart"] * 5, self.restarts(75, 4000, 90, 600, 61))
|
|
|
|
def test_a_run_that_stayed_up_starts_the_count_again(self):
|
|
self.assertEqual(["restart", "restart", "restart", "restart", "stop"], self.restarts(12, 10, 300, 14, 8))
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|