diff options
author | Patrick Vacek <patrickvacek@gmail.com> | 2019-04-15 13:40:49 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-04-15 13:40:49 +0200 |
commit | 8cc72a845e34e46d232c070280f42b5b695560d7 (patch) | |
tree | 8bb8ee285865949722184c4e117c556f3083ad7f | |
parent | 121bb090d7336c8a9180f9908fb011adda05f70c (diff) | |
parent | ff4ef176490bb9f6234a4ed475f1daaf8587c7f9 (diff) | |
download | meta-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.py | 4 | ||||
-rw-r--r-- | lib/oeqa/selftest/cases/updater_qemux86_64_ptest.py | 52 | ||||
-rwxr-xr-x | recipes-sota/aktualizr/aktualizr_git.bb | 12 | ||||
-rwxr-xr-x | recipes-sota/aktualizr/files/run-ptest | 6 |
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 | ||
55 | def qemu_send_command(port, command): | 55 | def 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 | ||
2 | import os | ||
3 | import re | ||
4 | |||
5 | from oeqa.selftest.case import OESelftestTestCase | ||
6 | from oeqa.utils.commands import runCmd | ||
7 | from testutils import qemu_launch, qemu_send_command, qemu_terminate | ||
8 | |||
9 | |||
10 | class 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" | |||
11 | RDEPENDS_${PN}-secondary = "aktualizr-check-discovery" | 11 | RDEPENDS_${PN}-secondary = "aktualizr-check-discovery" |
12 | RDEPENDS_${PN}-host-tools = "aktualizr aktualizr-repo aktualizr-cert-provider ${@bb.utils.contains('PACKAGECONFIG', 'sota-tools', 'garage-deploy garage-push', '', d)}" | 12 | RDEPENDS_${PN}-host-tools = "aktualizr aktualizr-repo aktualizr-cert-provider ${@bb.utils.contains('PACKAGECONFIG', 'sota-tools', 'garage-deploy garage-push', '', d)}" |
13 | 13 | ||
14 | RDEPENDS_${PN}-ptest += "bash cmake curl python3-modules sqlite3 valgrind" | 14 | RDEPENDS_${PN}-ptest += "bash cmake curl python3-modules openssl-bin sqlite3 valgrind" |
15 | 15 | ||
16 | PV = "1.0+git${SRCPV}" | 16 | PV = "1.0+git${SRCPV}" |
17 | PR = "7" | 17 | PR = "7" |
18 | 18 | ||
19 | GARAGE_SIGN_PV = "0.6.0-3-gc38b9f3" | 19 | GARAGE_SIGN_PV = "0.6.0-18-g5b8b259" |
20 | 20 | ||
21 | SRC_URI = " \ | 21 | SRC_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 |
33 | SRC_URI[md5sum] = "30d7f0931e2236954679e75d1bae174f" | 33 | SRC_URI[md5sum] = "c5e9968dfe78a7264ab9a8338c11725d" |
34 | SRC_URI[sha256sum] = "46d8c6448ce14cbb9af6a93eba7e29d38579e566dcd6518d22f723a8da16cad5" | 34 | SRC_URI[sha256sum] = "3a19258d7a1825a308aca0da82f7a337985bec05e8951355c4c95f0fcf2444f4" |
35 | 35 | ||
36 | SRCREV = "2e3ccbbdd43fdf70eb815454ea64f0bd8085856c" | 36 | SRCREV = "9c5ef10b7b91cc7d51cd22fc60446e734cf84690" |
37 | BRANCH ?= "master" | 37 | BRANCH ?= "master" |
38 | 38 | ||
39 | S = "${WORKDIR}/git" | 39 | S = "${WORKDIR}/git" |
@@ -73,7 +73,7 @@ RESOURCE_MEMORY_HIGH = "100M" | |||
73 | RESOURCE_MEMORY_MAX = "80%" | 73 | RESOURCE_MEMORY_MAX = "80%" |
74 | 74 | ||
75 | do_compile_ptest() { | 75 | do_compile_ptest() { |
76 | cmake_runcmake_build --target build_tests | 76 | cmake_runcmake_build --target build_tests "${PARALLEL_MAKE}" |
77 | } | 77 | } |
78 | 78 | ||
79 | do_install_ptest() { | 79 | do_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 | ||
3 | set -e | 3 | set -eu |
4 | |||
5 | AKTUALIZR_PTEST_PARALLEL_LEVEL=${AKTUALIZR_PTEST_PARALLEL_LEVEL:-2} | ||
4 | 6 | ||
5 | filter_logs() { | 7 | filter_logs() { |
6 | awk '/^.*Test[[:space:]]*#[[:digit:]]+:/ { | 8 | awk '/^.*Test[[:space:]]*#[[:digit:]]+:/ { |
@@ -13,4 +15,4 @@ filter_logs() { | |||
13 | } | 15 | } |
14 | 16 | ||
15 | cd build | 17 | cd build |
16 | ctest -j 8 -O /tmp/aktualizr-ptest.log --output-on-failure -LE 'noptest' 2> /dev/null | filter_logs | 18 | ctest -j "$AKTUALIZR_PTEST_PARALLEL_LEVEL" -O /tmp/aktualizr-ptest.log --output-on-failure -LE 'noptest' 2> /dev/null | filter_logs |