883 files, from working commit b1a079a. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
51 lines
2.5 KiB
Python
51 lines
2.5 KiB
Python
"""Exercise real process/journal boundaries without starting Wine or a game."""
|
|
import subprocess
|
|
import sys
|
|
import tempfile
|
|
import unittest
|
|
from pathlib import Path
|
|
|
|
sys.path.insert(0,str(Path(__file__).resolve().parents[1]/'ops'))
|
|
from linux_client_package import inprocess_startup_state,wait_inprocess_startup
|
|
|
|
READY='GW_LOGIN_SITE event=1 tid=36 pid=32 module=5368709120 query=196702 state=0 protect=0 rpm=0 match=0 got=0 error=0 hwnd=0 owner_tid=0 owner_pid=0 foreground_match=0\n'
|
|
|
|
|
|
class NativeInprocessLauncherTest(unittest.TestCase):
|
|
def test_health_uses_initialisation_without_requiring_user_input(self):
|
|
self.assertEqual(inprocess_startup_state(READY),'ready')
|
|
self.assertEqual(inprocess_startup_state('GW_LOGIN_SITE event=5 match=1 error=0\n'),'pending')
|
|
self.assertEqual(inprocess_startup_state(READY.replace('query=196702','query=0').replace('error=0','error=13')),'failed')
|
|
self.assertEqual(inprocess_startup_state(READY.replace('query=196702','query=0')),'pending')
|
|
|
|
def test_running_child_becomes_ready_without_external_listener(self):
|
|
with tempfile.TemporaryDirectory() as folder:
|
|
journal=Path(folder)/'startup.log'
|
|
script='import pathlib,sys,time;pathlib.Path(sys.argv[1]).write_text(sys.argv[2]);time.sleep(30)'
|
|
child=subprocess.Popen([sys.executable,'-c',script,str(journal),READY])
|
|
try:
|
|
wait_inprocess_startup(child,journal,3)
|
|
self.assertIsNone(child.poll())
|
|
finally:
|
|
child.terminate();child.wait(timeout=3)
|
|
|
|
def test_closed_child_is_not_reported_ready_from_journal(self):
|
|
with tempfile.TemporaryDirectory() as folder:
|
|
journal=Path(folder)/'startup.log';journal.write_text(READY)
|
|
child=subprocess.Popen([sys.executable,'-c','pass']);child.wait(timeout=3)
|
|
with self.assertRaisesRegex(RuntimeError,'closed before'):
|
|
wait_inprocess_startup(child,journal,1)
|
|
|
|
def test_missing_gateway_times_out_without_claiming_success(self):
|
|
with tempfile.TemporaryDirectory() as folder:
|
|
child=subprocess.Popen([sys.executable,'-c','import time;time.sleep(30)'])
|
|
try:
|
|
with self.assertRaisesRegex(TimeoutError,'did not initialise'):
|
|
wait_inprocess_startup(child,Path(folder)/'absent.log',.03)
|
|
self.assertIsNone(child.poll())
|
|
finally:
|
|
child.terminate();child.wait(timeout=3)
|
|
|
|
|
|
if __name__=='__main__':unittest.main()
|