diff options
author | Laurent Bonnans <laurent.bonnans@here.com> | 2019-07-08 11:28:34 +0200 |
---|---|---|
committer | Laurent Bonnans <laurent.bonnans@here.com> | 2019-07-17 18:28:28 +0200 |
commit | 4ab468bc0cb76f5d13b24af35e0d7746a0c035ad (patch) | |
tree | 5fd1f847b83bb86a404e1d1bae2563a11ae4b379 /lib/oeqa | |
parent | 144d9b25815300fc98157ea411081e898b7457f9 (diff) | |
download | meta-updater-4ab468bc0cb76f5d13b24af35e0d7746a0c035ad.tar.gz |
Factor out ugly function in oe-selftests
Signed-off-by: Laurent Bonnans <laurent.bonnans@here.com>
Diffstat (limited to 'lib/oeqa')
-rw-r--r-- | lib/oeqa/selftest/cases/testutils.py | 10 | ||||
-rw-r--r-- | lib/oeqa/selftest/cases/updater_minnowboard.py | 12 | ||||
-rw-r--r-- | lib/oeqa/selftest/cases/updater_qemux86_64.py | 47 | ||||
-rw-r--r-- | lib/oeqa/selftest/cases/updater_qemux86_64_ptest.py | 9 | ||||
-rw-r--r-- | lib/oeqa/selftest/cases/updater_raspberrypi.py | 13 |
5 files changed, 28 insertions, 63 deletions
diff --git a/lib/oeqa/selftest/cases/testutils.py b/lib/oeqa/selftest/cases/testutils.py index 900d15c..e67f30c 100644 --- a/lib/oeqa/selftest/cases/testutils.py +++ b/lib/oeqa/selftest/cases/testutils.py | |||
@@ -69,6 +69,16 @@ def qemu_send_command(port, command, timeout=60): | |||
69 | return stdout, stderr, s2.returncode | 69 | return stdout, stderr, s2.returncode |
70 | 70 | ||
71 | 71 | ||
72 | def metadir(): | ||
73 | # Assume the directory layout for finding other layers. We could also | ||
74 | # make assumptions by using 'show-layers', but either way, if the | ||
75 | # layers we need aren't where we expect them, we are out of luck. | ||
76 | path = os.path.abspath(os.path.dirname(__file__)) | ||
77 | metadir = path + "/../../../../../" | ||
78 | |||
79 | return metadir | ||
80 | |||
81 | |||
72 | def akt_native_run(testInst, cmd, **kwargs): | 82 | def akt_native_run(testInst, cmd, **kwargs): |
73 | # run a command supplied by aktualizr-native and checks that: | 83 | # run a command supplied by aktualizr-native and checks that: |
74 | # - the executable exists | 84 | # - the executable exists |
diff --git a/lib/oeqa/selftest/cases/updater_minnowboard.py b/lib/oeqa/selftest/cases/updater_minnowboard.py index 267445b..855bd20 100644 --- a/lib/oeqa/selftest/cases/updater_minnowboard.py +++ b/lib/oeqa/selftest/cases/updater_minnowboard.py | |||
@@ -1,9 +1,8 @@ | |||
1 | import os | ||
2 | import re | 1 | import re |
3 | 2 | ||
4 | from oeqa.selftest.case import OESelftestTestCase | 3 | from oeqa.selftest.case import OESelftestTestCase |
5 | from oeqa.utils.commands import runCmd, get_bb_var | 4 | from oeqa.utils.commands import runCmd, get_bb_var |
6 | from testutils import qemu_launch, qemu_send_command, qemu_terminate, verifyProvisioned | 5 | from testutils import metadir, qemu_launch, qemu_send_command, qemu_terminate, verifyProvisioned |
7 | 6 | ||
8 | 7 | ||
9 | class MinnowTests(OESelftestTestCase): | 8 | class MinnowTests(OESelftestTestCase): |
@@ -12,18 +11,13 @@ class MinnowTests(OESelftestTestCase): | |||
12 | layer_intel = "meta-intel" | 11 | layer_intel = "meta-intel" |
13 | layer_minnow = "meta-updater-minnowboard" | 12 | layer_minnow = "meta-updater-minnowboard" |
14 | result = runCmd('bitbake-layers show-layers') | 13 | result = runCmd('bitbake-layers show-layers') |
15 | # Assume the directory layout for finding other layers. We could also | ||
16 | # make assumptions by using 'show-layers', but either way, if the | ||
17 | # layers we need aren't where we expect them, we are out of luck. | ||
18 | path = os.path.abspath(os.path.dirname(__file__)) | ||
19 | metadir = path + "/../../../../../" | ||
20 | if re.search(layer_intel, result.output) is None: | 14 | if re.search(layer_intel, result.output) is None: |
21 | self.meta_intel = metadir + layer_intel | 15 | self.meta_intel = metadir() + layer_intel |
22 | runCmd('bitbake-layers add-layer "%s"' % self.meta_intel) | 16 | runCmd('bitbake-layers add-layer "%s"' % self.meta_intel) |
23 | else: | 17 | else: |
24 | self.meta_intel = None | 18 | self.meta_intel = None |
25 | if re.search(layer_minnow, result.output) is None: | 19 | if re.search(layer_minnow, result.output) is None: |
26 | self.meta_minnow = metadir + layer_minnow | 20 | self.meta_minnow = metadir() + layer_minnow |
27 | runCmd('bitbake-layers add-layer "%s"' % self.meta_minnow) | 21 | runCmd('bitbake-layers add-layer "%s"' % self.meta_minnow) |
28 | else: | 22 | else: |
29 | self.meta_minnow = None | 23 | self.meta_minnow = None |
diff --git a/lib/oeqa/selftest/cases/updater_qemux86_64.py b/lib/oeqa/selftest/cases/updater_qemux86_64.py index c61c9b2..7228529 100644 --- a/lib/oeqa/selftest/cases/updater_qemux86_64.py +++ b/lib/oeqa/selftest/cases/updater_qemux86_64.py | |||
@@ -9,7 +9,8 @@ from uuid import uuid4 | |||
9 | from oeqa.selftest.case import OESelftestTestCase | 9 | from oeqa.selftest.case import OESelftestTestCase |
10 | from oeqa.utils.commands import runCmd, bitbake, get_bb_var, get_bb_vars | 10 | from oeqa.utils.commands import runCmd, bitbake, get_bb_var, get_bb_vars |
11 | from testutils import qemu_launch, qemu_send_command, qemu_terminate, \ | 11 | from testutils import qemu_launch, qemu_send_command, qemu_terminate, \ |
12 | akt_native_run, verifyNotProvisioned, verifyProvisioned, qemu_bake_image, qemu_boot_image | 12 | metadir, akt_native_run, verifyNotProvisioned, verifyProvisioned, \ |
13 | qemu_bake_image, qemu_boot_image | ||
13 | 14 | ||
14 | 15 | ||
15 | class GeneralTests(OESelftestTestCase): | 16 | class GeneralTests(OESelftestTestCase): |
@@ -46,8 +47,6 @@ class AktualizrToolsTests(OESelftestTestCase): | |||
46 | akt_native_run(self, 'aktualizr-cert-provider --help') | 47 | akt_native_run(self, 'aktualizr-cert-provider --help') |
47 | 48 | ||
48 | def test_cert_provider_local_output(self): | 49 | def test_cert_provider_local_output(self): |
49 | logger = logging.getLogger("selftest") | ||
50 | logger.info('Running bitbake to build aktualizr-device-prov') | ||
51 | bb_vars = get_bb_vars(['SOTA_PACKED_CREDENTIALS', 'T'], 'aktualizr-native') | 50 | bb_vars = get_bb_vars(['SOTA_PACKED_CREDENTIALS', 'T'], 'aktualizr-native') |
52 | creds = bb_vars['SOTA_PACKED_CREDENTIALS'] | 51 | creds = bb_vars['SOTA_PACKED_CREDENTIALS'] |
53 | temp_dir = bb_vars['T'] | 52 | temp_dir = bb_vars['T'] |
@@ -75,12 +74,7 @@ class SharedCredProvTests(OESelftestTestCase): | |||
75 | layer = "meta-updater-qemux86-64" | 74 | layer = "meta-updater-qemux86-64" |
76 | result = runCmd('bitbake-layers show-layers') | 75 | result = runCmd('bitbake-layers show-layers') |
77 | if re.search(layer, result.output) is None: | 76 | if re.search(layer, result.output) is None: |
78 | # Assume the directory layout for finding other layers. We could also | 77 | self.meta_qemu = metadir() + layer |
79 | # make assumptions by using 'show-layers', but either way, if the | ||
80 | # layers we need aren't where we expect them, we are out of luck. | ||
81 | path = os.path.abspath(os.path.dirname(__file__)) | ||
82 | metadir = path + "/../../../../../" | ||
83 | self.meta_qemu = metadir + layer | ||
84 | runCmd('bitbake-layers add-layer "%s"' % self.meta_qemu) | 78 | runCmd('bitbake-layers add-layer "%s"' % self.meta_qemu) |
85 | else: | 79 | else: |
86 | self.meta_qemu = None | 80 | self.meta_qemu = None |
@@ -117,12 +111,7 @@ class ManualControlTests(OESelftestTestCase): | |||
117 | layer = "meta-updater-qemux86-64" | 111 | layer = "meta-updater-qemux86-64" |
118 | result = runCmd('bitbake-layers show-layers') | 112 | result = runCmd('bitbake-layers show-layers') |
119 | if re.search(layer, result.output) is None: | 113 | if re.search(layer, result.output) is None: |
120 | # Assume the directory layout for finding other layers. We could also | 114 | self.meta_qemu = metadir() + layer |
121 | # make assumptions by using 'show-layers', but either way, if the | ||
122 | # layers we need aren't where we expect them, we are out of like. | ||
123 | path = os.path.abspath(os.path.dirname(__file__)) | ||
124 | metadir = path + "/../../../../../" | ||
125 | self.meta_qemu = metadir + layer | ||
126 | runCmd('bitbake-layers add-layer "%s"' % self.meta_qemu) | 115 | runCmd('bitbake-layers add-layer "%s"' % self.meta_qemu) |
127 | else: | 116 | else: |
128 | self.meta_qemu = None | 117 | self.meta_qemu = None |
@@ -161,12 +150,7 @@ class DeviceCredProvTests(OESelftestTestCase): | |||
161 | layer = "meta-updater-qemux86-64" | 150 | layer = "meta-updater-qemux86-64" |
162 | result = runCmd('bitbake-layers show-layers') | 151 | result = runCmd('bitbake-layers show-layers') |
163 | if re.search(layer, result.output) is None: | 152 | if re.search(layer, result.output) is None: |
164 | # Assume the directory layout for finding other layers. We could also | 153 | self.meta_qemu = metadir() + layer |
165 | # make assumptions by using 'show-layers', but either way, if the | ||
166 | # layers we need aren't where we expect them, we are out of luck. | ||
167 | path = os.path.abspath(os.path.dirname(__file__)) | ||
168 | metadir = path + "/../../../../../" | ||
169 | self.meta_qemu = metadir + layer | ||
170 | runCmd('bitbake-layers add-layer "%s"' % self.meta_qemu) | 154 | runCmd('bitbake-layers add-layer "%s"' % self.meta_qemu) |
171 | else: | 155 | else: |
172 | self.meta_qemu = None | 156 | self.meta_qemu = None |
@@ -217,12 +201,7 @@ class DeviceCredProvHsmTests(OESelftestTestCase): | |||
217 | layer = "meta-updater-qemux86-64" | 201 | layer = "meta-updater-qemux86-64" |
218 | result = runCmd('bitbake-layers show-layers') | 202 | result = runCmd('bitbake-layers show-layers') |
219 | if re.search(layer, result.output) is None: | 203 | if re.search(layer, result.output) is None: |
220 | # Assume the directory layout for finding other layers. We could also | 204 | self.meta_qemu = metadir() + layer |
221 | # make assumptions by using 'show-layers', but either way, if the | ||
222 | # layers we need aren't where we expect them, we are out of luck. | ||
223 | path = os.path.abspath(os.path.dirname(__file__)) | ||
224 | metadir = path + "/../../../../../" | ||
225 | self.meta_qemu = metadir + layer | ||
226 | runCmd('bitbake-layers add-layer "%s"' % self.meta_qemu) | 205 | runCmd('bitbake-layers add-layer "%s"' % self.meta_qemu) |
227 | else: | 206 | else: |
228 | self.meta_qemu = None | 207 | self.meta_qemu = None |
@@ -399,12 +378,7 @@ class IpSecondaryTests(OESelftestTestCase): | |||
399 | layer = "meta-updater-qemux86-64" | 378 | layer = "meta-updater-qemux86-64" |
400 | result = runCmd('bitbake-layers show-layers') | 379 | result = runCmd('bitbake-layers show-layers') |
401 | if re.search(layer, result.output) is None: | 380 | if re.search(layer, result.output) is None: |
402 | # Assume the directory layout for finding other layers. We could also | 381 | self.meta_qemu = metadir() + layer |
403 | # make assumptions by using 'show-layers', but either way, if the | ||
404 | # layers we need aren't where we expect them, we are out of luck. | ||
405 | path = os.path.abspath(os.path.dirname(__file__)) | ||
406 | metadir = path + "/../../../../../" | ||
407 | self.meta_qemu = metadir + layer | ||
408 | runCmd('bitbake-layers add-layer "%s"' % self.meta_qemu) | 382 | runCmd('bitbake-layers add-layer "%s"' % self.meta_qemu) |
409 | else: | 383 | else: |
410 | self.meta_qemu = None | 384 | self.meta_qemu = None |
@@ -446,12 +420,7 @@ class ResourceControlTests(OESelftestTestCase): | |||
446 | layer = "meta-updater-qemux86-64" | 420 | layer = "meta-updater-qemux86-64" |
447 | result = runCmd('bitbake-layers show-layers') | 421 | result = runCmd('bitbake-layers show-layers') |
448 | if re.search(layer, result.output) is None: | 422 | if re.search(layer, result.output) is None: |
449 | # Assume the directory layout for finding other layers. We could also | 423 | self.meta_qemu = metadir() + layer |
450 | # make assumptions by using 'show-layers', but either way, if the | ||
451 | # layers we need aren't where we expect them, we are out of luck. | ||
452 | path = os.path.abspath(os.path.dirname(__file__)) | ||
453 | metadir = path + "/../../../../../" | ||
454 | self.meta_qemu = metadir + layer | ||
455 | runCmd('bitbake-layers add-layer "%s"' % self.meta_qemu) | 424 | runCmd('bitbake-layers add-layer "%s"' % self.meta_qemu) |
456 | else: | 425 | else: |
457 | self.meta_qemu = None | 426 | self.meta_qemu = None |
diff --git a/lib/oeqa/selftest/cases/updater_qemux86_64_ptest.py b/lib/oeqa/selftest/cases/updater_qemux86_64_ptest.py index 0f0f491..88e773b 100644 --- a/lib/oeqa/selftest/cases/updater_qemux86_64_ptest.py +++ b/lib/oeqa/selftest/cases/updater_qemux86_64_ptest.py | |||
@@ -4,7 +4,7 @@ import re | |||
4 | 4 | ||
5 | from oeqa.selftest.case import OESelftestTestCase | 5 | from oeqa.selftest.case import OESelftestTestCase |
6 | from oeqa.utils.commands import runCmd | 6 | from oeqa.utils.commands import runCmd |
7 | from testutils import qemu_launch, qemu_send_command, qemu_terminate | 7 | from testutils import metadir, qemu_launch, qemu_send_command, qemu_terminate |
8 | 8 | ||
9 | 9 | ||
10 | class PtestTests(OESelftestTestCase): | 10 | class PtestTests(OESelftestTestCase): |
@@ -13,12 +13,7 @@ class PtestTests(OESelftestTestCase): | |||
13 | layer = "meta-updater-qemux86-64" | 13 | layer = "meta-updater-qemux86-64" |
14 | result = runCmd('bitbake-layers show-layers') | 14 | result = runCmd('bitbake-layers show-layers') |
15 | if re.search(layer, result.output) is None: | 15 | if re.search(layer, result.output) is None: |
16 | # Assume the directory layout for finding other layers. We could also | 16 | self.meta_qemu = metadir() + layer |
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) | 17 | runCmd('bitbake-layers add-layer "%s"' % self.meta_qemu) |
23 | else: | 18 | else: |
24 | self.meta_qemu = None | 19 | self.meta_qemu = None |
diff --git a/lib/oeqa/selftest/cases/updater_raspberrypi.py b/lib/oeqa/selftest/cases/updater_raspberrypi.py index f6ae903..26d5c4c 100644 --- a/lib/oeqa/selftest/cases/updater_raspberrypi.py +++ b/lib/oeqa/selftest/cases/updater_raspberrypi.py | |||
@@ -7,6 +7,8 @@ import unittest | |||
7 | from oeqa.selftest.case import OESelftestTestCase | 7 | from oeqa.selftest.case import OESelftestTestCase |
8 | from oeqa.utils.commands import runCmd, bitbake, get_bb_var | 8 | from oeqa.utils.commands import runCmd, bitbake, get_bb_var |
9 | 9 | ||
10 | from testutils import metadir | ||
11 | |||
10 | 12 | ||
11 | class RpiTests(OESelftestTestCase): | 13 | class RpiTests(OESelftestTestCase): |
12 | 14 | ||
@@ -17,23 +19,18 @@ class RpiTests(OESelftestTestCase): | |||
17 | layer_rpi = "meta-raspberrypi" | 19 | layer_rpi = "meta-raspberrypi" |
18 | layer_upd_rpi = "meta-updater-raspberrypi" | 20 | layer_upd_rpi = "meta-updater-raspberrypi" |
19 | result = runCmd('bitbake-layers show-layers') | 21 | result = runCmd('bitbake-layers show-layers') |
20 | # Assume the directory layout for finding other layers. We could also | ||
21 | # make assumptions by using 'show-layers', but either way, if the | ||
22 | # layers we need aren't where we expect them, we are out of luck. | ||
23 | path = os.path.abspath(os.path.dirname(__file__)) | ||
24 | metadir = path + "/../../../../../" | ||
25 | if re.search(layer_python, result.output) is None: | 22 | if re.search(layer_python, result.output) is None: |
26 | self.meta_python = metadir + layer_python | 23 | self.meta_python = metadir() + layer_python |
27 | runCmd('bitbake-layers add-layer "%s"' % self.meta_python) | 24 | runCmd('bitbake-layers add-layer "%s"' % self.meta_python) |
28 | else: | 25 | else: |
29 | self.meta_python = None | 26 | self.meta_python = None |
30 | if re.search(layer_rpi, result.output) is None: | 27 | if re.search(layer_rpi, result.output) is None: |
31 | self.meta_rpi = metadir + layer_rpi | 28 | self.meta_rpi = metadir() + layer_rpi |
32 | runCmd('bitbake-layers add-layer "%s"' % self.meta_rpi) | 29 | runCmd('bitbake-layers add-layer "%s"' % self.meta_rpi) |
33 | else: | 30 | else: |
34 | self.meta_rpi = None | 31 | self.meta_rpi = None |
35 | if re.search(layer_upd_rpi, result.output) is None: | 32 | if re.search(layer_upd_rpi, result.output) is None: |
36 | self.meta_upd_rpi = metadir + layer_upd_rpi | 33 | self.meta_upd_rpi = metadir() + layer_upd_rpi |
37 | runCmd('bitbake-layers add-layer "%s"' % self.meta_upd_rpi) | 34 | runCmd('bitbake-layers add-layer "%s"' % self.meta_upd_rpi) |
38 | else: | 35 | else: |
39 | self.meta_upd_rpi = None | 36 | self.meta_upd_rpi = None |