summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPatrick Vacek <patrickvacek@gmail.com>2019-04-15 13:40:49 +0200
committerGitHub <noreply@github.com>2019-04-15 13:40:49 +0200
commit8cc72a845e34e46d232c070280f42b5b695560d7 (patch)
tree8bb8ee285865949722184c4e117c556f3083ad7f
parent121bb090d7336c8a9180f9908fb011adda05f70c (diff)
parentff4ef176490bb9f6234a4ed475f1daaf8587c7f9 (diff)
downloadmeta-updater-8cc72a845e34e46d232c070280f42b5b695560d7.tar.gz
Merge pull request #508 from advancedtelematic/test/oe-selftest-ptest
Add oe-selftest for aktualizr ptest run on qemu
-rw-r--r--lib/oeqa/selftest/cases/testutils.py4
-rw-r--r--lib/oeqa/selftest/cases/updater_qemux86_64_ptest.py52
-rwxr-xr-xrecipes-sota/aktualizr/aktualizr_git.bb12
-rwxr-xr-xrecipes-sota/aktualizr/files/run-ptest6
4 files changed, 64 insertions, 10 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..a04032c
--- /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 # simulate a login shell, so that /usr/sbin is in $PATH (from /etc/profile)
41 stdout, stderr, retcode = self.qemu_command('sh -l -c 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)
diff --git a/recipes-sota/aktualizr/aktualizr_git.bb b/recipes-sota/aktualizr/aktualizr_git.bb
index f2f62b5..64382d8 100755
--- a/recipes-sota/aktualizr/aktualizr_git.bb
+++ b/recipes-sota/aktualizr/aktualizr_git.bb
@@ -11,12 +11,12 @@ RDEPENDS_${PN}_class-target = "aktualizr-check-discovery aktualizr-configs lshw"
11RDEPENDS_${PN}-secondary = "aktualizr-check-discovery" 11RDEPENDS_${PN}-secondary = "aktualizr-check-discovery"
12RDEPENDS_${PN}-host-tools = "aktualizr aktualizr-repo aktualizr-cert-provider ${@bb.utils.contains('PACKAGECONFIG', 'sota-tools', 'garage-deploy garage-push', '', d)}" 12RDEPENDS_${PN}-host-tools = "aktualizr aktualizr-repo aktualizr-cert-provider ${@bb.utils.contains('PACKAGECONFIG', 'sota-tools', 'garage-deploy garage-push', '', d)}"
13 13
14RDEPENDS_${PN}-ptest += "bash cmake curl python3-modules sqlite3 valgrind" 14RDEPENDS_${PN}-ptest += "bash cmake curl python3-modules openssl-bin sqlite3 valgrind"
15 15
16PV = "1.0+git${SRCPV}" 16PV = "1.0+git${SRCPV}"
17PR = "7" 17PR = "7"
18 18
19GARAGE_SIGN_PV = "0.6.0-3-gc38b9f3" 19GARAGE_SIGN_PV = "0.6.0-18-g5b8b259"
20 20
21SRC_URI = " \ 21SRC_URI = " \
22 gitsm://github.com/advancedtelematic/aktualizr;branch=${BRANCH} \ 22 gitsm://github.com/advancedtelematic/aktualizr;branch=${BRANCH} \
@@ -30,10 +30,10 @@ SRC_URI = " \
30 " 30 "
31 31
32# for garage-sign archive 32# for garage-sign archive
33SRC_URI[md5sum] = "30d7f0931e2236954679e75d1bae174f" 33SRC_URI[md5sum] = "c5e9968dfe78a7264ab9a8338c11725d"
34SRC_URI[sha256sum] = "46d8c6448ce14cbb9af6a93eba7e29d38579e566dcd6518d22f723a8da16cad5" 34SRC_URI[sha256sum] = "3a19258d7a1825a308aca0da82f7a337985bec05e8951355c4c95f0fcf2444f4"
35 35
36SRCREV = "2e3ccbbdd43fdf70eb815454ea64f0bd8085856c" 36SRCREV = "9c5ef10b7b91cc7d51cd22fc60446e734cf84690"
37BRANCH ?= "master" 37BRANCH ?= "master"
38 38
39S = "${WORKDIR}/git" 39S = "${WORKDIR}/git"
@@ -73,7 +73,7 @@ RESOURCE_MEMORY_HIGH = "100M"
73RESOURCE_MEMORY_MAX = "80%" 73RESOURCE_MEMORY_MAX = "80%"
74 74
75do_compile_ptest() { 75do_compile_ptest() {
76 cmake_runcmake_build --target build_tests 76 cmake_runcmake_build --target build_tests "${PARALLEL_MAKE}"
77} 77}
78 78
79do_install_ptest() { 79do_install_ptest() {
diff --git a/recipes-sota/aktualizr/files/run-ptest b/recipes-sota/aktualizr/files/run-ptest
index e5f0d56..ff441f9 100755
--- a/recipes-sota/aktualizr/files/run-ptest
+++ b/recipes-sota/aktualizr/files/run-ptest
@@ -1,6 +1,8 @@
1#!/bin/sh 1#!/bin/sh
2 2
3set -e 3set -eu
4
5AKTUALIZR_PTEST_PARALLEL_LEVEL=${AKTUALIZR_PTEST_PARALLEL_LEVEL:-2}
4 6
5filter_logs() { 7filter_logs() {
6 awk '/^.*Test[[:space:]]*#[[:digit:]]+:/ { 8 awk '/^.*Test[[:space:]]*#[[:digit:]]+:/ {
@@ -13,4 +15,4 @@ filter_logs() {
13} 15}
14 16
15cd build 17cd build
16ctest -j 8 -O /tmp/aktualizr-ptest.log --output-on-failure -LE 'noptest' 2> /dev/null | filter_logs 18ctest -j "$AKTUALIZR_PTEST_PARALLEL_LEVEL" -O /tmp/aktualizr-ptest.log --output-on-failure -LE 'noptest' 2> /dev/null | filter_logs