From 79383e9d8023307f4e0f085794a312a286bf0e0b Mon Sep 17 00:00:00 2001 From: Laurent Bonnans Date: Thu, 21 Mar 2019 17:30:55 +0100 Subject: Add oe-selftest for aktualizr ptest run on qemu Signed-off-by: Laurent Bonnans --- lib/oeqa/selftest/cases/testutils.py | 4 +- .../selftest/cases/updater_qemux86_64_ptest.py | 52 ++++++++++++++++++++++ 2 files changed, 54 insertions(+), 2 deletions(-) create mode 100644 lib/oeqa/selftest/cases/updater_qemux86_64_ptest.py (limited to 'lib/oeqa') diff --git a/lib/oeqa/selftest/cases/testutils.py b/lib/oeqa/selftest/cases/testutils.py index 90ba653..2ad99ad 100644 --- a/lib/oeqa/selftest/cases/testutils.py +++ b/lib/oeqa/selftest/cases/testutils.py @@ -52,11 +52,11 @@ def qemu_terminate(s): pass -def qemu_send_command(port, command): +def qemu_send_command(port, command, timeout=60): command = ['ssh -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no root@localhost -p ' + str(port) + ' "' + command + '"'] s2 = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) - stdout, stderr = s2.communicate(timeout=60) + stdout, stderr = s2.communicate(timeout=timeout) return stdout, stderr, s2.returncode diff --git a/lib/oeqa/selftest/cases/updater_qemux86_64_ptest.py b/lib/oeqa/selftest/cases/updater_qemux86_64_ptest.py new file mode 100644 index 0000000..8ac6443 --- /dev/null +++ b/lib/oeqa/selftest/cases/updater_qemux86_64_ptest.py @@ -0,0 +1,52 @@ +# pylint: disable=C0111,C0325 +import os +import re + +from oeqa.selftest.case import OESelftestTestCase +from oeqa.utils.commands import runCmd +from testutils import qemu_launch, qemu_send_command, qemu_terminate + + +class PtestTests(OESelftestTestCase): + + def setUpLocal(self): + layer = "meta-updater-qemux86-64" + result = runCmd('bitbake-layers show-layers') + if re.search(layer, result.output) is None: + # Assume the directory layout for finding other layers. We could also + # make assumptions by using 'show-layers', but either way, if the + # layers we need aren't where we expect them, we are out of like. + path = os.path.abspath(os.path.dirname(__file__)) + metadir = path + "/../../../../../" + self.meta_qemu = metadir + layer + runCmd('bitbake-layers add-layer "%s"' % self.meta_qemu) + else: + self.meta_qemu = None + self.append_config('MACHINE = "qemux86-64"') + self.append_config('SYSTEMD_AUTO_ENABLE_aktualizr = "disable"') + self.append_config('PTEST_ENABLED_pn-aktualizr = "1"') + self.append_config('IMAGE_INSTALL_append += "aktualizr-ptest ptest-runner "') + self.qemu, self.s = qemu_launch(machine='qemux86-64') + + def tearDownLocal(self): + qemu_terminate(self.s) + if self.meta_qemu: + runCmd('bitbake-layers remove-layer "%s"' % self.meta_qemu, ignore_status=True) + + def qemu_command(self, command, timeout=60): + return qemu_send_command(self.qemu.ssh_port, command, timeout=timeout) + + def test_run_ptests(self): + # logger = logging.getLogger("selftest") + stdout, stderr, retcode = self.qemu_command('ptest-runner', timeout=None) + output = stdout.decode() + print(output) + self.assertEqual(retcode, 0) + + has_failure = re.search('^FAIL', output, flags=re.MULTILINE) is not None + if has_failure: + print("Full test suite log:") + stdout, stderr, retcode = self.qemu_command('cat /tmp/aktualizr-ptest.log', timeout=None) + print(stdout.decode()) + + self.assertFalse(has_failure) -- cgit v1.2.3-54-g00ecf