Skip to content

Commit e92c95d

Browse files
committed
Test console with pexpect
1 parent 41ead94 commit e92c95d

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

jumpstarter/drivers/dutlink/base_test.py

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
1+
import socket
2+
from pathlib import Path
3+
from tempfile import TemporaryDirectory
14
from time import sleep
25

6+
import anyio
7+
from pexpect.fdpexpect import fdspawn
8+
39
from jumpstarter.common.utils import serve
410
from jumpstarter.drivers.dutlink.base import Dutlink
511

@@ -23,5 +29,15 @@ def test_drivers_dutlink():
2329

2430
client.storage.write("/dev/null")
2531

26-
with client.console.connect() as stream:
27-
pass
32+
with TemporaryDirectory() as tempdir:
33+
socketpath = Path(tempdir) / "socket"
34+
35+
listener = client.portal.call(anyio.create_unix_listener, socketpath)
36+
37+
with client.console.portforward(listener):
38+
with socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) as s:
39+
s.connect(str(socketpath))
40+
41+
expect = fdspawn(s)
42+
expect.send("about\r\n")
43+
expect.expect("Jumpstarter test-harness")

0 commit comments

Comments
 (0)