From 03e184b4741c0c182ed2446f41ab07926398634e Mon Sep 17 00:00:00 2001 From: Gerd Hoffmann Date: Thu, 28 Mar 2019 11:46:56 +0100 Subject: test tweaks --- tests/README | 1 + tests/basic.py | 14 +++++++++++--- tests/drminfo/__init__.py | 23 ++++++++++++++++++++++- 3 files changed, 34 insertions(+), 4 deletions(-) diff --git a/tests/README b/tests/README index 0ad5ccb..da8182c 100644 --- a/tests/README +++ b/tests/README @@ -4,3 +4,4 @@ avocado framework tests for qemu display devices usage: export QEMU_BUILD_DIR=/path/to/qemu/build/tree avocado run . + diff --git a/tests/basic.py b/tests/basic.py index a7f5ca1..3cf762d 100644 --- a/tests/basic.py +++ b/tests/basic.py @@ -77,6 +77,12 @@ class BaseDRM(TestDRM): self.wconsole.write('\n') self.wconsole.flush() + def write_text(self, device, name, content): + outfile = '%s/%s-%s.txt' % (self.outputdir, name, device) + f = open(outfile, "w") + f.write(content) + f.close() + def run_one_test(self, device): version = os.uname()[2] kernel = "/boot/vmlinuz-%s" % version @@ -104,7 +110,8 @@ class BaseDRM(TestDRM): self.console_wait('---root---') self.console_run('drminfo -a') - self.console_wait('---root---') + txt = self.console_wait('---root---') + self.write_text(device, "drminfo", txt) self.console_run('drminfo -F') formats = self.console_wait('---root---') @@ -130,8 +137,9 @@ class BaseDRM(TestDRM): self.screen_dump(device, 'virtio') self.console_wait('---root---') - self.console_run('fbinfo -a') - self.console_wait('---root---') + self.console_run('fbinfo') + txt = self.console_wait('---root---') + self.write_text(device, "fbinfo", txt) self.console_run('fbtest -a -s 10') self.console_wait('---ok---', '---root---', 'fbtest failed') diff --git a/tests/drminfo/__init__.py b/tests/drminfo/__init__.py index 015cd03..629afd5 100644 --- a/tests/drminfo/__init__.py +++ b/tests/drminfo/__init__.py @@ -6,9 +6,30 @@ QEMU_BUILD_DIR = os.environ.get("QEMU_BUILD_DIR"); sys.path.append(os.path.join(QEMU_BUILD_DIR, 'python')) from qemu import QEMUMachine +def find_qemu_binary(): + """ + Picks the path of a QEMU binary, starting either in the current working + directory or in the source tree root directory. + """ + arch = os.uname()[4] + qemu_build = os.path.join(QEMU_BUILD_DIR, + "%s-softmmu" % arch, + "qemu-system-%s" % arch) + qemu_path = [ + qemu_build, + "/usr/local/bin/qemu-system-%s" % arch, + "/usr/bin/qemu-system-%s" % arch, + "/usr/bin/qemu-kvm", + "/usr/libexec/qemu-kvm", + ] + for item in qemu_path: + if os.path.isfile(item): + return item; + return None + class TestDRM(avocado.Test): def setUp(self): - self.vm = QEMUMachine("/usr/local/bin/qemu-system-x86_64") + self.vm = QEMUMachine(find_qemu_binary()) def tearDown(self): self.vm.shutdown() -- cgit