summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLaurent Bonnans <laurent.bonnans@here.com>2019-07-08 11:28:34 +0200
committerLaurent Bonnans <laurent.bonnans@here.com>2019-07-15 15:28:26 +0200
commiteeaa391f3043bcf5cf3bd7645792fa6d01ee43c8 (patch)
treebbd1916152115c05aa07a6d424a57270dd603d1c
parent69d8dc6ed1405a6a05faca12f482e79cb6e0471b (diff)
downloadmeta-updater-eeaa391f3043bcf5cf3bd7645792fa6d01ee43c8.tar.gz
Factor out ugly function in oe-selftests
Signed-off-by: Laurent Bonnans <laurent.bonnans@here.com>
-rw-r--r--lib/oeqa/selftest/cases/testutils.py10
-rw-r--r--lib/oeqa/selftest/cases/updater_minnowboard.py12
-rw-r--r--lib/oeqa/selftest/cases/updater_qemux86_64.py47
-rw-r--r--lib/oeqa/selftest/cases/updater_qemux86_64_ptest.py9
-rw-r--r--lib/oeqa/selftest/cases/updater_raspberrypi.py11
5 files changed, 27 insertions, 62 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
72def 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
72def akt_native_run(testInst, cmd, **kwargs): 82def 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 @@
1import os
2import re 1import re
3 2
4from oeqa.selftest.case import OESelftestTestCase 3from oeqa.selftest.case import OESelftestTestCase
5from oeqa.utils.commands import runCmd, get_bb_var 4from oeqa.utils.commands import runCmd, get_bb_var
6from testutils import qemu_launch, qemu_send_command, qemu_terminate, verifyProvisioned 5from testutils import metadir, qemu_launch, qemu_send_command, qemu_terminate, verifyProvisioned
7 6
8 7
9class MinnowTests(OESelftestTestCase): 8class 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 04d9a6f..f09aa46 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
9from oeqa.selftest.case import OESelftestTestCase 9from oeqa.selftest.case import OESelftestTestCase
10from oeqa.utils.commands import runCmd, bitbake, get_bb_var, get_bb_vars 10from oeqa.utils.commands import runCmd, bitbake, get_bb_var, get_bb_vars
11from testutils import qemu_launch, qemu_send_command, qemu_terminate, \ 11from 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
15class GeneralTests(OESelftestTestCase): 16class 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
5from oeqa.selftest.case import OESelftestTestCase 5from oeqa.selftest.case import OESelftestTestCase
6from oeqa.utils.commands import runCmd 6from oeqa.utils.commands import runCmd
7from testutils import qemu_launch, qemu_send_command, qemu_terminate 7from testutils import metadir, qemu_launch, qemu_send_command, qemu_terminate
8 8
9 9
10class PtestTests(OESelftestTestCase): 10class 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 e976100..8efc941 100644
--- a/lib/oeqa/selftest/cases/updater_raspberrypi.py
+++ b/lib/oeqa/selftest/cases/updater_raspberrypi.py
@@ -7,6 +7,8 @@ import unittest
7from oeqa.selftest.case import OESelftestTestCase 7from oeqa.selftest.case import OESelftestTestCase
8from oeqa.utils.commands import runCmd, bitbake, get_bb_var 8from oeqa.utils.commands import runCmd, bitbake, get_bb_var
9 9
10from testutils import metadir
11
10 12
11class RpiTests(OESelftestTestCase): 13class RpiTests(OESelftestTestCase):
12 14
@@ -16,18 +18,13 @@ class RpiTests(OESelftestTestCase):
16 layer_rpi = "meta-raspberrypi" 18 layer_rpi = "meta-raspberrypi"
17 layer_upd_rpi = "meta-updater-raspberrypi" 19 layer_upd_rpi = "meta-updater-raspberrypi"
18 result = runCmd('bitbake-layers show-layers') 20 result = runCmd('bitbake-layers show-layers')
19 # Assume the directory layout for finding other layers. We could also
20 # make assumptions by using 'show-layers', but either way, if the
21 # layers we need aren't where we expect them, we are out of luck.
22 path = os.path.abspath(os.path.dirname(__file__))
23 metadir = path + "/../../../../../"
24 if re.search(layer_rpi, result.output) is None: 21 if re.search(layer_rpi, result.output) is None:
25 self.meta_rpi = metadir + layer_rpi 22 self.meta_rpi = metadir() + layer_rpi
26 runCmd('bitbake-layers add-layer "%s"' % self.meta_rpi) 23 runCmd('bitbake-layers add-layer "%s"' % self.meta_rpi)
27 else: 24 else:
28 self.meta_rpi = None 25 self.meta_rpi = None
29 if re.search(layer_upd_rpi, result.output) is None: 26 if re.search(layer_upd_rpi, result.output) is None:
30 self.meta_upd_rpi = metadir + layer_upd_rpi 27 self.meta_upd_rpi = metadir() + layer_upd_rpi
31 runCmd('bitbake-layers add-layer "%s"' % self.meta_upd_rpi) 28 runCmd('bitbake-layers add-layer "%s"' % self.meta_upd_rpi)
32 else: 29 else:
33 self.meta_upd_rpi = None 30 self.meta_upd_rpi = None