Skip to content

Commit

Permalink
wip3
Browse files Browse the repository at this point in the history
Signed-off-by: Maciej Pijanowski <[email protected]>
  • Loading branch information
macpijan committed Oct 11, 2023
1 parent 4cff25f commit ec947a7
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 23 deletions.
69 changes: 46 additions & 23 deletions .github/workflows/qemu-self-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,50 @@ on: [push, pull_request]
jobs:
qemu:
runs-on: ubuntu-latest

steps:
- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Download firmware files for QEMU
run: |
wget -O OVMF_CODE.fd https://cloud.3mdeb.com/index.php/s/iXmyJxKLBB2Eb94/download
wget -O OVMF_VARS.fd https://cloud.3mdeb.com/index.php/s/Mn2n92DZLnZQZ8N/download
- name: Start QEMU in background
run: |
qemu-system-x86_64 -machine q35,smm=on \
-global driver=cfi.pflash01,property=secure,value=on \
-drive if=pflash,format=raw,unit=0,file=OVMF_CODE.fd,readonly=on \
-drive if=pflash,format=raw,unit=1,file=OVMF_VARS.fd \
-debugcon file:debug.log -global isa-debugcon.iobase=0x402 \
-global ICH9-LPC.disable_s3=1 \
-qmp unix:/tmp/qmp-socket,server,nowait \
-net none \
-serial telnet:localhost:1234,server,nowait &
- name: Start keywords self-tests with QEMU
run: |
./scripts/ci/qemu-self-test.sh
- name: Checkout repository and submodules
uses: actions/checkout@v2
with:
submodules: 'recursive'

- name: Set up QEMU
run: |
sudo apt-get update
sudo apt-get install qemu-system-x86-64
- name: Download firmware files for QEMU
run: |
wget -O OVMF_CODE.fd https://cloud.3mdeb.com/index.php/s/iXmyJxKLBB2Eb94/download
wget -O OVMF_VARS.fd https://cloud.3mdeb.com/index.php/s/Mn2n92DZLnZQZ8N/download
- name: Start QEMU in background
run: |
qemu-system-x86_64 -machine q35,smm=on \
-global driver=cfi.pflash01,property=secure,value=on \
-drive if=pflash,format=raw,unit=0,file=OVMF_CODE.fd,readonly=on \
-drive if=pflash,format=raw,unit=1,file=OVMF_VARS.fd \
-debugcon file:debug.log -global isa-debugcon.iobase=0x402 \
-global ICH9-LPC.disable_s3=1 \
-qmp unix:/tmp/qmp-socket,server,nowait \
-net none \
-serial telnet:localhost:1234,server,nowait &
- name: Checkout repository and submodules
uses: actions/checkout@v2
with:
submodules: 'recursive'

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.11'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Start keywords self-tests with QEMU
run: |
scripts/ci/qemu-self-test.sh
41 changes: 41 additions & 0 deletions lib/QemuMonitor.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import json
import socket

from robot.api.deco import keyword, library


@library
class QemuMonitor:
def __init__(self, socket_path):
self.sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
self.sock.connect(socket_path)
greeting = self.sock.recv(4096)
self.qmp_capabilities()

def _send(self, command, **args):
msg = {"execute": command, "arguments": args}
self.sock.sendall(json.dumps(msg).encode())
response = self.sock.recv(4096).decode()
json_objects = [
json.loads(line) for line in response.splitlines() if line.strip()
]
if len(json_objects) > 1:
return {"ack": json_objects[0], "event": json_objects[1]}
else:
return json_objects[0]

@keyword
def qmp_capabilities(self):
return self._send("qmp_capabilities")

@keyword
def system_powerdown(self):
return self._send("system_powerdown")

@keyword
def system_reset(self):
return self._send("system_reset")

@keyword
def quit(self):
return self._send("quit")

0 comments on commit ec947a7

Please sign in to comment.