summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLaurent Bonnans <laurent.bonnans@here.com>2019-03-21 17:30:55 +0100
committerLaurent Bonnans <laurent.bonnans@here.com>2019-04-09 14:33:14 +0200
commitf47d2d8deeccb56f839035c383c68da6558c5d9c (patch)
tree1b17fd799b3cba55a30aa004757a84be194a7e1d
parent121bb090d7336c8a9180f9908fb011adda05f70c (diff)
downloadmeta-updater-f47d2d8deeccb56f839035c383c68da6558c5d9c.tar.gz
Add oe-selftest for aktualizr ptest run on qemu
Signed-off-by: Laurent Bonnans <laurent.bonnans@here.com>
-rw-r--r--lib/oeqa/selftest/cases/testutils.py4
-rw-r--r--lib/oeqa/selftest/cases/updater_qemux86_64_ptest.py52
2 files changed, 54 insertions, 2 deletions
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):
52 pass 52 pass
53 53
54 54
55def qemu_send_command(port, command): 55def qemu_send_command(port, command, timeout=60):
56 command = ['ssh -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no root@localhost -p ' + 56 command = ['ssh -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no root@localhost -p ' +
57 str(port) + ' "' + command + '"'] 57 str(port) + ' "' + command + '"']
58 s2 = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) 58 s2 = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
59 stdout, stderr = s2.communicate(timeout=60) 59 stdout, stderr = s2.communicate(timeout=timeout)
60 return stdout, stderr, s2.returncode 60 return stdout, stderr, s2.returncode
61 61
62 62
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 @@
1# pylint: disable=C0111,C0325
2import os
3import re
4
5from oeqa.selftest.case import OESelftestTestCase
6from oeqa.utils.commands import runCmd
7from testutils import qemu_launch, qemu_send_command, qemu_terminate
8
9
10class PtestTests(OESelftestTestCase):
11
12 def setUpLocal(self):
13 layer = "meta-updater-qemux86-64"
14 result = runCmd('bitbake-layers show-layers')
15 if re.search(layer, result.output) is None:
16 # Assume the directory layout for finding other layers. We could also
17 # make assumptions by using 'show-layers', but either way, if the
18 # layers we need aren't where we expect them, we are out of like.
19 path = os.path.abspath(os.path.dirname(__file__))
20 metadir = path + "/../../../../../"
21 self.meta_qemu = metadir + layer
22 runCmd('bitbake-layers add-layer "%s"' % self.meta_qemu)
23 else:
24 self.meta_qemu = None
25 self.append_config('MACHINE = "qemux86-64"')
26 self.append_config('SYSTEMD_AUTO_ENABLE_aktualizr = "disable"')
27 self.append_config('PTEST_ENABLED_pn-aktualizr = "1"')
28 self.append_config('IMAGE_INSTALL_append += "aktualizr-ptest ptest-runner "')
29 self.qemu, self.s = qemu_launch(machine='qemux86-64')
30
31 def tearDownLocal(self):
32 qemu_terminate(self.s)
33 if self.meta_qemu:
34 runCmd('bitbake-layers remove-layer "%s"' % self.meta_qemu, ignore_status=True)
35
36 def qemu_command(self, command, timeout=60):
37 return qemu_send_command(self.qemu.ssh_port, command, timeout=timeout)
38
39 def test_run_ptests(self):
40 # logger = logging.getLogger("selftest")
41 stdout, stderr, retcode = self.qemu_command('ptest-runner', timeout=None)
42 output = stdout.decode()
43 print(output)
44 self.assertEqual(retcode, 0)
45
46 has_failure = re.search('^FAIL', output, flags=re.MULTILINE) is not None
47 if has_failure:
48 print("Full test suite log:")
49 stdout, stderr, retcode = self.qemu_command('cat /tmp/aktualizr-ptest.log', timeout=None)
50 print(stdout.decode())
51
52 self.assertFalse(has_failure)