Files
pokerfreak/tests/geber_aufraeumen_spec.py
T
mmintel 9c79d8236b Acceptance 5.11.: channel play without AFK, quiet focus, working Cockpit, stronger play
- Practice tables: 20-min session 54/54 turns at the server, control session 28 turns,
  0 timeouts; stage: 3 tables, two rounds each, clean teardown.
- Never let the clock run: an engine abstention becomes check or fold (nie_verstreichen).
- Mittler join in a fixed order (kill the duplicate, then announce), a mittler ends with its
  game, the laufwache opens no tables, stop waits for the runner to stand up.
- Focus: no lobby connections from HUD, probes or layout; "Focus Window on Turn" off.
- Tables: disconnected or sitting-out opponents do not count; a table without channel is
  closed and avoided after 45 s; the join event keeps the writer's pid (strict invariants).
- Geldwache: same room list as the runner, the table's own report, stand up before closing.
- Engine: the small blind completes the top 65 % against limpers (price per fair share);
  the calling range of a bet is as wide as the villain calls - value bets into stations.
- Cockpit: the source tree never comes from SHELL; one operating set for laufwache and
  Cockpit (sicht/start.py --client, ServerStart).
- Project lives in ~/Projects/pokerfreak (kern was a detour).
2026-11-05 16:10:43 +01:00

103 lines
4.1 KiB
Python

#!/usr/bin/env python3
"""Aufraeumen der Buehne (hand/geber.py `_sauber_weg`): genau der eigene Tisch, nie ein Nachbar.
Befund 5.11.2026 (Abnahme `betrieb/buehne_show.py --alle`): die Zellen 10 und 11 brachen in den
Wellen mit BrokenPipeError und 0 Haenden ab (ev_chop, fixed_bombpot, plo6, rabbit). Kein Rahmen
war schuld: das Aufraeumen von Zelle 1 (`...-buehne1`) traf per Teilstring auch `...-buehne10`
und `...-buehne11` und schoss deren Tischprozesse ab (Systemlog: Tisch 1 stirbt 01:23:08,
die Tische der Zellen 10/11 folgen 01:23:15/01:23:16; Runde 2: 01:25:34 -> 01:25:38).
Geprueft ueber die echte Prozessgrenze, ohne etwas zu toeten: ein Ersatz-`ps` (feste Liste) und
ein Ersatz-`kill` (schreibt nur mit) liegen vorn im PATH. Raumname und pids sind erfunden (pids
ueber dem macOS-Hoechstwert 99998) - selbst ein echtes `ps`/`kill` faende nichts.
python3 tests/geber_aufraeumen_spec.py -v
"""
import os
import shutil
import stat
import sys
import tempfile
import unittest
HIER = os.path.dirname(os.path.abspath(__file__))
WURZEL = os.path.dirname(HIER)
for p in (os.path.join(WURZEL, "hand"), os.path.join(WURZEL, "client")):
if p in sys.path:
sys.path.remove(p)
sys.path.insert(0, p)
import geber
RAUM = "Spec Raum 0000001"
SPIEL = ("/Applications/CoinPoker.app/Contents/Resources/unity-resources-arm64/"
"CoinPoker Game.app/Contents/MacOS/CoinPoker")
REST = " mode=prod buildName=BUEHNE-1 -screen-fullscreen 0 -screen-width 1640"
def tischzeile(pid, endung, rest=REST):
"""Eine `ps -eo pid,command`-Zeile eines Buehnentisches, so wie `theater.starte_spiel` startet."""
return (f"{pid} {SPIEL} serverIp=poker-nlb.coinpoker.ai:7001 roomName={RAUM} "
f"isSuspectedFraud=false tableSize=6 theme=/t/desk-1.jpg lobbyId=1 "
f"pipeName={RAUM}{endung}{rest}")
PS_LISTE = [
" PID COMMAND",
tischzeile(4100001, "-buehne1"),
tischzeile(4100010, "-buehne10"),
tischzeile(4100011, "-buehne11"),
tischzeile(4100002, "-buehne2", rest=""), # pipeName als letztes Argument
f"4100099 /usr/bin/python3 betrieb/buehne_show.py pipeName={RAUM}-buehne1 --x", # kein Tisch
]
class Aufraeumen(unittest.TestCase):
"""Wer `_sauber_weg(name)` ruft, trifft den Tischprozess mit GENAU diesem pipeName."""
def setUp(self):
self.ordner = tempfile.mkdtemp(prefix="geber-aufraeumen-")
self.mitschrift = os.path.join(self.ordner, "kill.txt")
liste = os.path.join(self.ordner, "ps.txt")
with open(liste, "w", encoding="utf-8") as h:
h.write("\n".join(PS_LISTE) + "\n")
self._skript("ps", f'cat "{liste}"\n')
self._skript("kill", f'echo "$@" >> "{self.mitschrift}"\n')
self.pfad_vorher = os.environ.get("PATH", "")
os.environ["PATH"] = self.ordner + os.pathsep + self.pfad_vorher
def tearDown(self):
os.environ["PATH"] = self.pfad_vorher
shutil.rmtree(self.ordner, ignore_errors=True)
def _skript(self, name, rumpf):
pfad = os.path.join(self.ordner, name)
with open(pfad, "w", encoding="utf-8") as h:
h.write("#!/bin/sh\n" + rumpf)
os.chmod(pfad, os.stat(pfad).st_mode | stat.S_IXUSR)
def _getroffen(self, name):
"""Die `kill`-Aufrufe, die `_sauber_weg(name)` absetzt - als Argumentlisten."""
geber._sauber_weg(name)
if not os.path.exists(self.mitschrift):
return []
with open(self.mitschrift, encoding="utf-8") as h:
return [z.split() for z in h.read().splitlines()]
def test_nachbar_mit_laengerem_namen_bleibt_stehen(self):
"""Zelle 1 aufraeumen trifft NUR Zelle 1 - nicht die Tische der Zellen 10 und 11."""
self.assertEqual(self._getroffen(RAUM + "-buehne1"), [["-9", "4100001"]])
def test_eigener_tisch_mit_zweistelliger_zelle_wird_getroffen(self):
self.assertEqual(self._getroffen(RAUM + "-buehne10"), [["-9", "4100010"]])
def test_name_am_zeilenende_wird_getroffen(self):
self.assertEqual(self._getroffen(RAUM + "-buehne2"), [["-9", "4100002"]])
def test_ohne_namen_wird_nichts_getroffen(self):
self.assertEqual(self._getroffen(""), [])
if __name__ == "__main__":
unittest.main()