mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-11-28 04:18:52 -06:00
fix: start core_probe one way from every probe
pack_probe and region_check run core_probe through probes.host.run_when_idle: a busy refusal is retried until the wait runs out, a timeout kills the run's whole process group, and pack_probe takes core_probe's own probe lock, which honours RETROBIOS_PROBE_LOCK_HELD. core_probe names its busy exit status EXIT_BUSY.
This commit is contained in:
1 parent
922d60807f
commit
d2984bc466
7 files changed
+49
-60
No files matched your search
@@ -16,6 +16,7 @@ import tests
|
||||
import contextlib
|
||||
import io
|
||||
import json
|
||||
import os
|
||||
import re
|
||||
import shutil
|
||||
import unittest
|
||||
@@ -283,8 +284,9 @@ class Lock(unittest.TestCase):
|
||||
return subprocess.CompletedProcess(command, 2, "", "refused")
|
||||
|
||||
lay = layout({"a.bin": 1})
|
||||
with unittest.mock.patch.object(packprobe, "PROBE_LOCK", lock), \
|
||||
unittest.mock.patch.object(packprobe.subprocess, "run", fake_run):
|
||||
env = {"RETROBIOS_PROBE_LOCK": str(lock), "RETROBIOS_PROBE_LOCK_HELD": ""}
|
||||
with unittest.mock.patch.dict(os.environ, env), \
|
||||
unittest.mock.patch.object(packprobe, "run_group", fake_run):
|
||||
for _ in range(2):
|
||||
self.assertEqual(packprobe.core_probe(["run"], {"a.bin"}, lay, work), (2, None, "refused"))
|
||||
self.assertEqual(held, [True, True])
|
||||
@@ -314,8 +316,9 @@ class RecordsNameNoLocalPath(unittest.TestCase):
|
||||
def fake_run(command, **kwargs):
|
||||
return subprocess.CompletedProcess(command, 1, "", f' File "{script}", line 9\n')
|
||||
|
||||
with unittest.mock.patch.object(packprobe, "PROBE_LOCK", work / "probe.lock"), \
|
||||
unittest.mock.patch.object(packprobe.subprocess, "run", fake_run):
|
||||
env = {"RETROBIOS_PROBE_LOCK": str(work / "probe.lock"), "RETROBIOS_PROBE_LOCK_HELD": ""}
|
||||
with unittest.mock.patch.dict(os.environ, env), \
|
||||
unittest.mock.patch.object(packprobe, "run_group", fake_run):
|
||||
code, record, error = packprobe.core_probe(["run"], set(), layout({}), work)
|
||||
self.assertEqual((code, record), (1, None))
|
||||
self.assertEqual(error, 'File "<repo>/scripts/core_probe.py", line 9')
|
||||
|
||||
@@ -8,7 +8,8 @@ import tests
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
|
||||
from probes import regioncheck
|
||||
from core_probe import EXIT_BUSY
|
||||
from probes import host, regioncheck
|
||||
|
||||
ROOT = Path(__file__).resolve().parent.parent
|
||||
|
||||
@@ -74,16 +75,16 @@ class BusyHost(unittest.TestCase):
|
||||
def pause(seconds: float) -> None:
|
||||
now[0] += seconds
|
||||
|
||||
proc = regioncheck.probe_when_idle(["probe"], max_wait, clock=lambda: now[0], pause=pause, runner=runner)
|
||||
proc = host.run_when_idle(["probe"], max_wait, clock=lambda: now[0], pause=pause, runner=runner)
|
||||
return proc.returncode, len(calls)
|
||||
|
||||
def test_a_refused_run_is_tried_again_once_the_host_settles(self) -> None:
|
||||
self.assertEqual(self._run([regioncheck.BUSY, regioncheck.BUSY, 0], 600), (0, 3))
|
||||
self.assertEqual(self._run([EXIT_BUSY, EXIT_BUSY, 0], 600), (0, 3))
|
||||
|
||||
def test_it_gives_up_after_the_wait(self) -> None:
|
||||
code, calls = self._run([regioncheck.BUSY], 60)
|
||||
self.assertEqual(code, regioncheck.BUSY)
|
||||
self.assertEqual(calls, 60 // regioncheck.POLL_S + 1)
|
||||
code, calls = self._run([EXIT_BUSY], 60)
|
||||
self.assertEqual(code, EXIT_BUSY)
|
||||
self.assertEqual(calls, 60 // host.BUSY_POLL + 1)
|
||||
|
||||
def test_another_failure_is_not_retried(self) -> None:
|
||||
self.assertEqual(self._run([1, 0], 600), (1, 1))
|
||||
|
||||
Reference in new issue
Block a user