Skip to content

Commit 52829d7

Browse files
committed
qemu_test: factor out vm fixture
In a future change I want to pass around another value as well as the pexpect.spawn object, so make the fixture return a SimpleNamespace that has the spawn object under that instead of it being the direct value. Change the existing test accordingly. This should result in no functional change to the test suite. Signed-off-by: Robie Basak <robie.basak@oss.qualcomm.com>
1 parent 4ec72e8 commit 52829d7

File tree

1 file changed

+18
-17
lines changed

1 file changed

+18
-17
lines changed

ci/qemu_test.py

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import subprocess
99
import sys
1010
import tempfile
11+
import types
1112

1213
import pexpect
1314
import pytest
@@ -33,7 +34,7 @@ def vm():
3334
],
3435
check=True,
3536
)
36-
child = pexpect.spawn(
37+
spawn = pexpect.spawn(
3738
"qemu-system-aarch64",
3839
[
3940
"-cpu",
@@ -53,32 +54,32 @@ def vm():
5354
"/usr/share/AAVMF/AAVMF_CODE.fd",
5455
],
5556
)
56-
child.logfile = sys.stdout.buffer
57-
yield child
57+
spawn.logfile = sys.stdout.buffer
58+
yield types.SimpleNamespace(spawn=spawn)
5859

5960
# No need to be nice; that would take time
60-
child.kill(signal.SIGKILL)
61+
spawn.kill(signal.SIGKILL)
6162

6263
# If this blocks then we have a problem. Better to hang than build up
6364
# excess qemu processes that won't die.
64-
child.wait()
65+
spawn.wait()
6566

6667

6768
def test_password_reset_required(vm):
6869
"""On first login, there should be a mandatory reset password flow"""
6970
# https://github.com/qualcomm-linux/qcom-deb-images/issues/69
7071

7172
# This takes a minute or two on a ThinkPad T14s Gen 6 Snapdragon
72-
vm.expect_exact("debian login:", timeout=240)
73+
vm.spawn.expect_exact("debian login:", timeout=240)
7374

74-
vm.send("debian\r\n")
75-
vm.expect_exact("Password:")
76-
vm.send("debian\r\n")
77-
vm.expect_exact("You are required to change your password immediately")
78-
vm.expect_exact("Current password:")
79-
vm.send("debian\r\n")
80-
vm.expect_exact("New password:")
81-
vm.send("new password\r\n")
82-
vm.expect_exact("Retype new password:")
83-
vm.send("new password\r\n")
84-
vm.expect_exact("debian@debian:~$")
75+
vm.spawn.send("debian\r\n")
76+
vm.spawn.expect_exact("Password:")
77+
vm.spawn.send("debian\r\n")
78+
vm.spawn.expect_exact("You are required to change your password immediately")
79+
vm.spawn.expect_exact("Current password:")
80+
vm.spawn.send("debian\r\n")
81+
vm.spawn.expect_exact("New password:")
82+
vm.spawn.send("new password\r\n")
83+
vm.spawn.expect_exact("Retype new password:")
84+
vm.spawn.send("new password\r\n")
85+
vm.spawn.expect_exact("debian@debian:~$")

0 commit comments

Comments
 (0)