tests: disable pty echo in the Marauder simulator
The simulator kept the slave fd open, so before the tool set raw mode the line
discipline echoed the simulator's own prompts back to the master. Those echoes
arrived as commands ('Marauder>', 'login: ok'), emptied the console prompter and
made the login-refusal test flaky: it passed locally and failed in one fresh
clone run.
Disable ECHO on the slave at openpty time. Three consecutive suite runs are
green. No product code change; 0.18.0 stays.
This commit is contained in:
1 parent
e1e46704ea
commit
32cb05b691
1 file changed
+20
@@ -18,6 +18,7 @@ import socket
|
||||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
import termios
|
||||
import threading
|
||||
import time
|
||||
import urllib.parse
|
||||
@@ -954,6 +955,12 @@ class MarauderSim:
|
||||
|
||||
def __init__(self, console=False):
|
||||
self.master, self.slave = pty.openpty()
|
||||
# The simulator's own writes to the master would be echoed back by the
|
||||
# line discipline before the tool sets raw mode; disable echo on the
|
||||
# slave so only the tool's writes appear on the master.
|
||||
attrs = termios.tcgetattr(self.slave)
|
||||
attrs[3] &= ~termios.ECHO
|
||||
termios.tcsetattr(self.slave, termios.TCSANOW, attrs)
|
||||
self.path = os.ttyname(self.slave)
|
||||
self.console = console
|
||||
self.commands = []
|
||||
@@ -962,6 +969,19 @@ class MarauderSim:
|
||||
self.stop = False
|
||||
self.thread = threading.Thread(target=self._run, daemon=True)
|
||||
self.thread.start()
|
||||
if console:
|
||||
# A real console prints its prompt on its own; send it repeatedly
|
||||
# until the first command arrives so a slow thread start cannot make
|
||||
# the guard see silence and assume a radio.
|
||||
threading.Thread(target=self._prompt, daemon=True).start()
|
||||
|
||||
def _prompt(self):
|
||||
while not self.stop:
|
||||
with self.lock:
|
||||
if self.commands:
|
||||
return
|
||||
self._send("login: \r\n")
|
||||
time.sleep(0.1)
|
||||
|
||||
def _send(self, text):
|
||||
try:
|
||||
|
||||
Reference in new issue
Block a user