8000 Adding a test "framework" to run real world machine tests by Torxed · Pull Request #2500 · archlinux/archinstall · GitHub
[go: up one dir, main page]

Skip to content

Adding a test "framework" to run real world machine tests #2500

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 34 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
2063a65
Adding base functions for end to end testing using qemu tooling
Torxed May 13, 2024
589a09b
Fixing issue of: _Warning: Package 'archinstall.default_profiles' is …
Torxed May 13, 2024
9b2edb1
Merging in changes from branch fix-pybuild
Torxed May 13, 2024
3a19b50
Corrected the package name from 'where' to 'archinstall'
Torxed May 13, 2024
c097fc2
Merging in changes from branch fix-pybuild
Torxed May 13, 2024
583b865
Undoing change to 'package-data'
Torxed May 13, 2024
0ecf623
Merging in changes from branch fix-pybuild
Torxed May 13, 2024
79021c1
Added a minimal test example of a runner that can cycle through the m…
Torxed May 13, 2024
a5cec12
Fixing flake8
Torxed May 13, 2024
a604afd
Merged changes in master
Torxed May 13, 2024
c6dd76e
Testing local runner
Torxed May 14, 2024
adaef17
Testing local runner
Torxed May 14, 2024
5c02fdb
Attempting to grab artifact from build job
Torxed May 14, 2024
0b8d386
Attempting to grab artifact from build job
Torxed May 14, 2024
8d34a8b
Attempting to call the qemu-tests from the iso-build to create a pipe…
Torxed May 14, 2024
3f07bb4
Attempting to call the qemu-tests from the iso-build to create a pipe…
Torxed May 14, 2024
83671b4
Figuring out github workflow job dependencies
Torxed May 14, 2024
02d2fee
Figuring out github workflow job dependencies
Torxed May 14, 2024
8a7f6e0
Figuring out github workflow job dependencies
Torxed May 14, 2024
c1214e2
Figuring out github workflow job dependencies
Torxed May 14, 2024
933d466
Making screen work in the gitlab runner
Torxed May 14, 2024
d251e83
Making sure the iso-build job and qemu-runner puts the ISO in the cor…
Torxed May 14, 2024
818b945
Making sure screen can be executed
Torxed May 14, 2024
7d815e5
Making sure OVMF things are in place
Torxed May 14, 2024
0161326
Making sure OVMF things are in place
Torxed May 14, 2024
7ffb0e0
Making sure OVMF things are in place
Torxed May 14, 2024
4d200e2
Making sure qemu images are in correct place
Torxed May 14, 2024
b5df588
Attempting to limit runner to set users
Torxed May 14, 2024
a21be09
Attempting to limit runner to set users
Torxed May 14, 2024
7ef8013
Attempting to limit runner to set users
Torxed May 14, 2024
4bb5056
rm syntax issue
Torxed May 14, 2024
5e526c4
testing resize of 'screen'
Torxed May 14, 2024
c09f570
Attempting to limit codereview spam while improving runner requirements
Torxed May 14, 2024
66d7b1e
Setting environment on job
Torxed May 14, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fixing flake8
  • Loading branch information
Torxed committed May 13, 2024
commit a5cec12616bae87bf0080463ed05b1b9a919135d
7 changes: 4 additions & 3 deletions tests/qemu/machines.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# flake8: noqa E131

import pathlib
from runners import TestLeaveAllDefault

Expand All @@ -9,7 +11,6 @@
'-name', '"archinstall-test"',
'-display', 'none',
'-monitor', 'none',
#'-serial', 'none',
'-nographic',
'-m', '4096',
'-smp', '4,sockets=1,dies=1,cores=4,threads=1',
Expand All @@ -36,8 +37,8 @@
'-device', 'pcie-root-port,port=0x11,chassis=13,id=pci.13,bus=pcie.0,addr=0x6.0x3',
'-drive', 'if=pflash,format=raw,readonly=on,file=/usr/share/ovmf/x64/OVMF_CODE.secboot.fd',
'-drive', f'if=pflash,format=raw,file={pathlib.Path(__file__).parent}/OVMF_VARS.fd',
#'-tpmdev', 'passthrough,id=tpm0,path=/dev/tpm0,cancel-path=/tmp/foo-cancel2',
#'-device', 'tpm-tis,tpmdev=tpm0',
# '-tpmdev', 'passthrough,id=tpm0,path=/dev/tpm0,cancel-path=/tmp/foo-cancel2',
# '-device', 'tpm-tis,tpmdev=tpm0',
'-object', 'iothread,id=iothread1',
'-device', 'virtio-scsi-pci,bus=pcie.0,id=scsi2,addr=0x8',
'-device', 'virtio-scsi-pci,iothread=iothread1,id=scsi0,num_queues=8,bus=pci.13,addr=0x0',
Expand Down
50 changes: 28 additions & 22 deletions tests/qemu/run_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,10 @@
import pathlib
import socket
import select
import os
import json
import logging
import sys
import enum
from subprocess import Popen, PIPE, STDOUT
from qemu.qmp import QMPClient, Message
from qemu.qmp import QMPClient
from machines import parameters

logger = logging.getLogger("archtest")
Expand Down Expand Up @@ -64,19 +61,25 @@ async def edit_boot(self):
'send-key',
arguments={
'keys': [
{ "type": "qcode", "data": "e" }
{
"type": "qcode",
"data": "e"
}
]
}
)
)

await asyncio.sleep(1)
ret = await self.QMP.qmp.execute_msg(
await self.QMP.qmp.execute_msg(
self.QMP.qmp.make_execute_msg(
'send-key',
arguments={
'keys': [
{ "type": "qcode", "data": "end" }
{
"type": "qcode",
"data": "end"
}
]
}
)
Expand All @@ -85,15 +88,15 @@ async def edit_boot(self):

keys = []
# https://gist.github.com/mvidner/8939289
keys.append({ "type": "qcode", "data": "spc" })
keys.append({"type": "qcode", "data": "spc"})
for character in list('console=tty0 console=ttyS0,115200'):
if character.isupper():
keys.append({ "type": "qcode", "data": 'caps_lock' })
keys.append({ "type": "qcode", "data": character.lower().replace('=', 'equal').replace(',', 'comma').replace(' ', 'spc') })
keys.append({"type": "qcode", "data": 'caps_lock'})
keys.append({"type": "qcode", "data": character.lower().replace('=', 'equal').replace(',', 'comma').replace(' ', 'spc')})
if character.isupper():
keys.append({ "type": "qcode", "data": 'caps_lock' })
keys.append({"type": "qcode", "data": 'caps_lock'})

ret = await self.QMP.qmp.execute_msg(
await self.QMP.qmp.execute_msg(
self.QMP.qmp.make_execute_msg(
'send-key',
arguments={
Expand All @@ -103,12 +106,15 @@ async def edit_boot(self):
)

await asyncio.sleep(1)
ret = await self.QMP.qmp.execute_msg(
await self.QMP.qmp.execute_msg(
self.QMP.qmp.make_execute_msg(
'send-key',
arguments={
'keys': [
{ "type": "qcode", "data": "kp_enter" }
{
"type": "qcode",
"data": "kp_enter"
}
]
}
)
Expand Down Expand Up @@ -181,7 +187,6 @@ def __init__(self, cmd, qmp_socket, serial_socket):
self.start()

def run(self):
#print(self.cmd)
self.handle = Popen(
' '.join(self.cmd),
stdout=PIPE,
Expand All @@ -200,26 +205,27 @@ def run(self):
if fd == self.handle.stdout.fileno():
if (output := self.handle.stdout.read()):
print(output)
#elif fd == self.handle.stderr.fileno():
# if (output := self.handle.stderr.read()):
# print(output)
# elif fd == self.handle.stderr.fileno():
# if (output := self.handle.stderr.read()):
# print(output)
# No exit signal yet
time.sleep(0.25)

r, w, x = select.select([self.handle.stdout.fileno(), self.handle.stdout.fileno()], [], [], 0.2)
for fd in r:
if fd == self.handle.stdout.fileno():
if (output := self.handle.stdout.read()):
print(output)
#elif fd == self.handle.stderr.fileno():
# if (output := self.handle.stderr.read()):
# print(output)
print(output)
# elif fd == self.handle.stderr.fileno():
# if (output := self.handle.stderr.read()):
# print(output)

self.handle.stdin.close()
self.handle.stdout.close()
# self.handle.stderr.close()
logger.warning("Qemu closed..")


# .. todo::
# Needs a bit of more work to allow for multiple runners and test benches.
for profile in parameters:
Expand Down
10 changes: 5 additions & 5 deletions tests/qemu/testbase.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
class Keyboard(enum.Enum):
# https://vt100.net/docs/vt100-ug/chapter3.html
# https://espterm.github.io/docs/VT100%20escape%20codes.html
arrow_up='\033[A'
arrow_up = '\033[A'
arrow_down = '\033[B'
arrow_right = '\033[C'
arrow_left = '\033[D'
Expand All @@ -29,11 +29,11 @@ async def _send_key(self, key):
def send_string(self, chars, delay=None):
logger.debug(f"Sending string: {chars.encode('UTF-8')}")

while len((r := select.select([self.serial_monitor.client_socket], [], [], 0.2)[0])):
while len(select.select([self.serial_monitor.client_socket], [], [], 0.2)[0]):
# Waiting for read buffer to finish to not collide
time.sleep(0.02)

if len(w := select.select([], [self.serial_monitor.client_socket], [], 0.2)[1]):
if len(select.select([], [self.serial_monitor.client_socket], [], 0.2)[1]):
# asyncio.run_coroutine_threadsafe(self._send_key(vt100_key), loop=self.serial_monitor.QMP.loop)
self.serial_monitor.client_socket.send(chars.encode('UTF-8'), socket.MSG_WAITALL) # flags=socket.MSG_WAITALL
# os.fsync(self.serial_monitor.client_socket.fileno())
Expand All @@ -52,11 +52,11 @@ def send_key(self, key, delay=None):

logger.debug(f"Sending key: {key} \033[0;32m({vt100_key})\033[0m")

while len((r := select.select([self.serial_monitor.client_socket], [], [], 0.2)[0])):
while len(select.select([self.serial_monitor.client_socket], [], [], 0.2)[0]):
# Waiting for read buffer to finish to not collide
time.sleep(0.02)

if len(w := select.select([], [self.serial_monitor.client_socket], [], 0.2)[1]):
if len(select.select([], [self.serial_monitor.client_socket], [], 0.2)[1]):
# asyncio.run_coroutine_threadsafe(self._send_key(vt100_key), loop=self.serial_monitor.QMP.loop)
self.serial_monitor.client_socket.send(vt100_key, socket.MSG_WAITALL) # flags=socket.MSG_WAITALL
# os.fsync(self.serial_monitor.client_socket.fileno())
Expand Down
0