diff options
author | cajun-rat <phil@advancedtelematic.com> | 2018-01-18 13:48:44 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-01-18 13:48:44 +0100 |
commit | 0f064ae564321e949f18b156342a52a96e51d2a9 (patch) | |
tree | d7e4ab954d85112a01296867bddb9359bc66d74e /lib | |
parent | 623c51d713f359210874dd50c1394bcc901228ec (diff) | |
parent | b5b2458b320bd88599bcd3af02566712c8877c1c (diff) | |
download | meta-updater-0f064ae564321e949f18b156342a52a96e51d2a9.tar.gz |
Merge pull request #230 from advancedtelematic/bugfix/update-rocko
Bugfix/update rocko
Diffstat (limited to 'lib')
l--------- | lib/oeqa/selftest/cases/qemucommand.py | 1 | ||||
-rw-r--r-- | lib/oeqa/selftest/cases/updater.py (renamed from lib/oeqa/selftest/updater.py) | 142 | ||||
l--------- | lib/oeqa/selftest/qemucommand.py | 1 |
3 files changed, 87 insertions, 57 deletions
diff --git a/lib/oeqa/selftest/cases/qemucommand.py b/lib/oeqa/selftest/cases/qemucommand.py new file mode 120000 index 0000000..075cdb8 --- /dev/null +++ b/lib/oeqa/selftest/cases/qemucommand.py | |||
@@ -0,0 +1 @@ | |||
../../../../scripts/qemucommand.py \ No newline at end of file | |||
diff --git a/lib/oeqa/selftest/updater.py b/lib/oeqa/selftest/cases/updater.py index ad99964..7d7bde7 100644 --- a/lib/oeqa/selftest/updater.py +++ b/lib/oeqa/selftest/cases/updater.py | |||
@@ -1,15 +1,15 @@ | |||
1 | import unittest | ||
2 | import os | 1 | import os |
3 | import logging | 2 | import logging |
4 | import subprocess | 3 | import subprocess |
5 | import time | 4 | import time |
5 | import unittest | ||
6 | 6 | ||
7 | from oeqa.selftest.base import oeSelfTest | 7 | from oeqa.selftest.case import OESelftestTestCase |
8 | from oeqa.utils.commands import runCmd, bitbake, get_bb_var, get_bb_vars | 8 | from oeqa.utils.commands import runCmd, bitbake, get_bb_var, get_bb_vars |
9 | from oeqa.selftest.qemucommand import QemuCommand | 9 | from qemucommand import QemuCommand |
10 | 10 | ||
11 | 11 | ||
12 | class SotaToolsTests(oeSelfTest): | 12 | class SotaToolsTests(OESelftestTestCase): |
13 | 13 | ||
14 | @classmethod | 14 | @classmethod |
15 | def setUpClass(cls): | 15 | def setUpClass(cls): |
@@ -31,31 +31,22 @@ class SotaToolsTests(oeSelfTest): | |||
31 | result = runCmd('%s --help' % p, ignore_status=True) | 31 | result = runCmd('%s --help' % p, ignore_status=True) |
32 | self.assertEqual(result.status, 0, "Status not equal to 0. output: %s" % result.output) | 32 | self.assertEqual(result.status, 0, "Status not equal to 0. output: %s" % result.output) |
33 | 33 | ||
34 | 34 | def test_garagesign_help(self): | |
35 | class GarageSignTests(oeSelfTest): | 35 | bb_vars = get_bb_vars(['SYSROOT_DESTDIR', 'bindir'], 'aktualizr-native') |
36 | |||
37 | @classmethod | ||
38 | def setUpClass(cls): | ||
39 | logger = logging.getLogger("selftest") | ||
40 | logger.info('Running bitbake to build garage-sign-native') | ||
41 | bitbake('garage-sign-native') | ||
42 | |||
43 | def test_help(self): | ||
44 | bb_vars = get_bb_vars(['SYSROOT_DESTDIR', 'bindir'], 'garage-sign-native') | ||
45 | p = bb_vars['SYSROOT_DESTDIR'] + bb_vars['bindir'] + "/" + "garage-sign" | 36 | p = bb_vars['SYSROOT_DESTDIR'] + bb_vars['bindir'] + "/" + "garage-sign" |
46 | self.assertTrue(os.path.isfile(p), msg = "No garage-sign found (%s)" % p) | 37 | self.assertTrue(os.path.isfile(p), msg = "No garage-sign found (%s)" % p) |
47 | result = runCmd('%s --help' % p, ignore_status=True) | 38 | result = runCmd('%s --help' % p, ignore_status=True) |
48 | self.assertEqual(result.status, 0, "Status not equal to 0. output: %s" % result.output) | 39 | self.assertEqual(result.status, 0, "Status not equal to 0. output: %s" % result.output) |
49 | 40 | ||
50 | 41 | ||
51 | class HsmTests(oeSelfTest): | 42 | class HsmTests(OESelftestTestCase): |
52 | 43 | ||
53 | def test_hsm(self): | 44 | def test_hsm(self): |
54 | self.write_config('SOTA_CLIENT_FEATURES="hsm hsm-test"') | 45 | self.write_config('SOTA_CLIENT_FEATURES="hsm"') |
55 | bitbake('core-image-minimal') | 46 | bitbake('core-image-minimal') |
56 | 47 | ||
57 | 48 | ||
58 | class GeneralTests(oeSelfTest): | 49 | class GeneralTests(OESelftestTestCase): |
59 | 50 | ||
60 | def test_feature_sota(self): | 51 | def test_feature_sota(self): |
61 | result = get_bb_var('DISTRO_FEATURES').find('sota') | 52 | result = get_bb_var('DISTRO_FEATURES').find('sota') |
@@ -114,53 +105,20 @@ class GeneralTests(oeSelfTest): | |||
114 | self.assertNotEqual(size1, size2, "Image sizes are identical; image was not rebuilt.") | 105 | self.assertNotEqual(size1, size2, "Image sizes are identical; image was not rebuilt.") |
115 | 106 | ||
116 | 107 | ||
117 | class QemuTests(oeSelfTest): | 108 | class QemuTests(OESelftestTestCase): |
118 | 109 | ||
119 | @classmethod | 110 | @classmethod |
120 | def setUpClass(cls): | 111 | def setUpClass(cls): |
121 | logger = logging.getLogger("selftest") | 112 | cls.qemu, cls.s = qemu_launch(machine='qemux86-64') |
122 | logger.info('Running bitbake to build core-image-minimal') | ||
123 | bitbake('core-image-minimal') | ||
124 | # Create empty object. | ||
125 | args = type('', (), {})() | ||
126 | args.imagename = 'core-image-minimal' | ||
127 | args.mac = None | ||
128 | # Could use DEPLOY_DIR_IMAGE here but it's already in the machine | ||
129 | # subdirectory. | ||
130 | args.dir = 'tmp/deploy/images' | ||
131 | args.efi = False | ||
132 | args.machine = None | ||
133 | args.kvm = None # Autodetect | ||
134 | args.no_gui = True | ||
135 | args.gdb = False | ||
136 | args.pcap = None | ||
137 | args.overlay = None | ||
138 | args.dry_run = False | ||
139 | |||
140 | cls.qemu = QemuCommand(args) | ||
141 | cmdline = cls.qemu.command_line() | ||
142 | print('Booting image with run-qemu-ota...') | ||
143 | cls.s = subprocess.Popen(cmdline) | ||
144 | time.sleep(10) | ||
145 | 113 | ||
146 | @classmethod | 114 | @classmethod |
147 | def tearDownClass(cls): | 115 | def tearDownClass(cls): |
148 | try: | 116 | qemu_terminate(cls.s) |
149 | cls.s.terminate() | ||
150 | except KeyboardInterrupt: | ||
151 | pass | ||
152 | |||
153 | def run_test_qemu(self, command): | ||
154 | command = ['ssh -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no root@localhost -p ' + | ||
155 | str(self.qemu.ssh_port) + ' "' + command + '"'] | ||
156 | s2 = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) | ||
157 | value, err = s2.communicate() | ||
158 | return value, err | ||
159 | 117 | ||
160 | def test_hostname(self): | 118 | def test_hostname(self): |
161 | print('') | 119 | print('') |
162 | print('Checking machine name (hostname) of device:') | 120 | print('Checking machine name (hostname) of device:') |
163 | value, err = self.run_test_qemu('hostname') | 121 | value, err = qemu_send_command(self.qemu.ssh_port, 'hostname') |
164 | machine = get_bb_var('MACHINE', 'core-image-minimal') | 122 | machine = get_bb_var('MACHINE', 'core-image-minimal') |
165 | self.assertEqual(err, b'', 'Error: ' + err.decode()) | 123 | self.assertEqual(err, b'', 'Error: ' + err.decode()) |
166 | # Strip off line ending. | 124 | # Strip off line ending. |
@@ -172,8 +130,80 @@ class QemuTests(oeSelfTest): | |||
172 | def test_var_sota(self): | 130 | def test_var_sota(self): |
173 | print('') | 131 | print('') |
174 | print('Checking contents of /var/sota:') | 132 | print('Checking contents of /var/sota:') |
175 | value, err = self.run_test_qemu('ls /var/sota') | 133 | value, err = qemu_send_command(self.qemu.ssh_port, 'ls /var/sota') |
176 | self.assertEqual(err, b'', 'Error: ' + err.decode()) | 134 | self.assertEqual(err, b'', 'Error: ' + err.decode()) |
177 | print(value.decode()) | 135 | print(value.decode()) |
178 | 136 | ||
179 | 137 | ||
138 | class GrubTests(OESelftestTestCase): | ||
139 | |||
140 | def setUpLocal(self): | ||
141 | # This is a bit of a hack but I can't see a better option. | ||
142 | path = os.path.abspath(os.path.dirname(__file__)) | ||
143 | metadir = path + "/../../../../" | ||
144 | grub_config = 'OSTREE_BOOTLOADER = "grub"\nMACHINE = "intel-corei7-64"' | ||
145 | self.append_config(grub_config) | ||
146 | self.meta_intel = metadir + "meta-intel" | ||
147 | self.meta_minnow = metadir + "meta-updater-minnowboard" | ||
148 | runCmd('bitbake-layers add-layer "%s"' % self.meta_intel) | ||
149 | runCmd('bitbake-layers add-layer "%s"' % self.meta_minnow) | ||
150 | self.qemu, self.s = qemu_launch(efi=True, machine='intel-corei7-64') | ||
151 | |||
152 | def tearDownLocal(self): | ||
153 | qemu_terminate(self.s) | ||
154 | runCmd('bitbake-layers remove-layer "%s"' % self.meta_intel, ignore_status=True) | ||
155 | runCmd('bitbake-layers remove-layer "%s"' % self.meta_minnow, ignore_status=True) | ||
156 | |||
157 | def test_grub(self): | ||
158 | print('') | ||
159 | print('Checking machine name (hostname) of device:') | ||
160 | value, err = qemu_send_command(self.qemu.ssh_port, 'hostname') | ||
161 | machine = get_bb_var('MACHINE', 'core-image-minimal') | ||
162 | self.assertEqual(err, b'', 'Error: ' + err.decode()) | ||
163 | # Strip off line ending. | ||
164 | value_str = value.decode()[:-1] | ||
165 | self.assertEqual(value_str, machine, | ||
166 | 'MACHINE does not match hostname: ' + machine + ', ' + value_str) | ||
167 | print(value_str) | ||
168 | |||
169 | |||
170 | def qemu_launch(efi=False, machine=None): | ||
171 | logger = logging.getLogger("selftest") | ||
172 | logger.info('Running bitbake to build core-image-minimal') | ||
173 | bitbake('core-image-minimal') | ||
174 | # Create empty object. | ||
175 | args = type('', (), {})() | ||
176 | args.imagename = 'core-image-minimal' | ||
177 | args.mac = None | ||
178 | # Could use DEPLOY_DIR_IMAGE here but it's already in the machine | ||
179 | # subdirectory. | ||
180 | args.dir = 'tmp/deploy/images' | ||
181 | args.efi = efi | ||
182 | args.machine = machine | ||
183 | args.kvm = None # Autodetect | ||
184 | args.no_gui = True | ||
185 | args.gdb = False | ||
186 | args.pcap = None | ||
187 | args.overlay = None | ||
188 | args.dry_run = False | ||
189 | |||
190 | qemu = QemuCommand(args) | ||
191 | cmdline = qemu.command_line() | ||
192 | print('Booting image with run-qemu-ota...') | ||
193 | s = subprocess.Popen(cmdline) | ||
194 | time.sleep(10) | ||
195 | return qemu, s | ||
196 | |||
197 | def qemu_terminate(s): | ||
198 | try: | ||
199 | s.terminate() | ||
200 | except KeyboardInterrupt: | ||
201 | pass | ||
202 | |||
203 | def qemu_send_command(port, command): | ||
204 | command = ['ssh -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no root@localhost -p ' + | ||
205 | str(port) + ' "' + command + '"'] | ||
206 | s2 = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) | ||
207 | value, err = s2.communicate() | ||
208 | return value, err | ||
209 | |||
diff --git a/lib/oeqa/selftest/qemucommand.py b/lib/oeqa/selftest/qemucommand.py deleted file mode 120000 index bc06dde..0000000 --- a/lib/oeqa/selftest/qemucommand.py +++ /dev/null | |||
@@ -1 +0,0 @@ | |||
1 | ../../../scripts/qemucommand.py \ No newline at end of file | ||