test: make the testsuite passive rather than active

Let the image be responsible for running its own test, and simply
listen for the output from the testsuite.

Hook this up with a standard f30 image that contains a simple boot
test case, using systemctl to verify that all services started
correctly.

This replaces the old web-server test, giving similar functionality.
The reason for the change is twofold: this way the tests are fully
specificed in the pipeline, so easier to reproduce. Moreover, this
is less intrusive, as the test does not require network support in
the image.

Signed-off-by: Tom Gundersen <teg@jklm.no>
This commit is contained in:
Tom Gundersen 2019-08-29 14:24:13 +02:00
parent e14b93b06e
commit a41ce99521
6 changed files with 52 additions and 97 deletions

View file

@ -6,19 +6,14 @@ import time
from .config import *
@contextlib.contextmanager
def boot_image(file_name: str):
def run_image(file_name: str):
acceleration = ["-accel", "kvm:hvf:tcg"]
network = ["-net", "nic,model=rtl8139", "-net", "user,hostfwd=tcp::8888-:8888"]
cmd = ["qemu-system-x86_64", "-nographic", "-m", "1024", "-snapshot"] + \
acceleration + [f"{OUTPUT_DIR}/{file_name}"] + network
silence = ["-nographic", "-monitor", "none", "-serial", "none"]
serial = ["-chardev", "stdio,id=stdio", "-device", "virtio-serial", "-device", "virtserialport,chardev=stdio"]
cmd = ["qemu-system-x86_64", "-m", "1024", "-snapshot"] + \
acceleration + silence + serial + [f"{OUTPUT_DIR}/{file_name}"]
logging.info(f"Booting image: {cmd}")
vm = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
try:
time.sleep(EXPECTED_TIME_TO_BOOT)
yield None
finally:
vm.kill()
return subprocess.run(cmd, capture_output=True, timeout=EXPECTED_TIME_TO_BOOT, encoding="utf-8", check=True)
@contextlib.contextmanager