summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorcajun-rat <phil@advancedtelematic.com>2017-11-17 09:02:02 +0100
committerGitHub <noreply@github.com>2017-11-17 09:02:02 +0100
commitd81696e8320ac7927467c681a370e6700ee681b1 (patch)
treec59496960f129484f104044f4d444bf25c0c921c /lib
parent55e61fdc92ba340eeb98f7de8fb38328c47ca435 (diff)
parentc687237422dc7f22b85d9718d112fe0b674007c3 (diff)
downloadmeta-updater-d81696e8320ac7927467c681a370e6700ee681b1.tar.gz
Merge pull request #180 from advancedtelematic/feat/PRO-4199/oe-selftest-qemu
Feat/pro 4199/oe selftest qemu
Diffstat (limited to 'lib')
-rw-r--r--lib/oeqa/selftest/updater.py52
1 files changed, 42 insertions, 10 deletions
diff --git a/lib/oeqa/selftest/updater.py b/lib/oeqa/selftest/updater.py
index 2723b4a..ad99964 100644
--- a/lib/oeqa/selftest/updater.py
+++ b/lib/oeqa/selftest/updater.py
@@ -113,8 +113,14 @@ class GeneralTests(oeSelfTest):
113 self.assertNotEqual(path1, path2, "Image paths are identical; image was not rebuilt.") 113 self.assertNotEqual(path1, path2, "Image paths are identical; image was not rebuilt.")
114 self.assertNotEqual(size1, size2, "Image sizes are identical; image was not rebuilt.") 114 self.assertNotEqual(size1, size2, "Image sizes are identical; image was not rebuilt.")
115 115
116 def test_qemu(self): 116
117 print('') 117class QemuTests(oeSelfTest):
118
119 @classmethod
120 def setUpClass(cls):
121 logger = logging.getLogger("selftest")
122 logger.info('Running bitbake to build core-image-minimal')
123 bitbake('core-image-minimal')
118 # Create empty object. 124 # Create empty object.
119 args = type('', (), {})() 125 args = type('', (), {})()
120 args.imagename = 'core-image-minimal' 126 args.imagename = 'core-image-minimal'
@@ -131,17 +137,43 @@ class GeneralTests(oeSelfTest):
131 args.overlay = None 137 args.overlay = None
132 args.dry_run = False 138 args.dry_run = False
133 139
134 qemu_command = QemuCommand(args) 140 cls.qemu = QemuCommand(args)
135 cmdline = qemu_command.command_line() 141 cmdline = cls.qemu.command_line()
136 print('Booting image with run-qemu-ota...') 142 print('Booting image with run-qemu-ota...')
137 s = subprocess.Popen(cmdline) 143 cls.s = subprocess.Popen(cmdline)
138 time.sleep(10) 144 time.sleep(10)
139 print('Machine name (hostname) of device is:') 145
140 ssh_cmd = ['ssh', '-q', '-o', 'UserKnownHostsFile=/dev/null', '-o', 'StrictHostKeyChecking=no', 'root@localhost', '-p', str(qemu_command.ssh_port), 'hostname'] 146 @classmethod
141 s2 = subprocess.Popen(ssh_cmd) 147 def tearDownClass(cls):
142 time.sleep(5)
143 try: 148 try:
144 s.terminate() 149 cls.s.terminate()
145 except KeyboardInterrupt: 150 except KeyboardInterrupt:
146 pass 151 pass
147 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
160 def test_hostname(self):
161 print('')
162 print('Checking machine name (hostname) of device:')
163 value, err = self.run_test_qemu('hostname')
164 machine = get_bb_var('MACHINE', 'core-image-minimal')
165 self.assertEqual(err, b'', 'Error: ' + err.decode())
166 # Strip off line ending.
167 value_str = value.decode()[:-1]
168 self.assertEqual(value_str, machine,
169 'MACHINE does not match hostname: ' + machine + ', ' + value_str)
170 print(value_str)
171
172 def test_var_sota(self):
173 print('')
174 print('Checking contents of /var/sota:')
175 value, err = self.run_test_qemu('ls /var/sota')
176 self.assertEqual(err, b'', 'Error: ' + err.decode())
177 print(value.decode())
178
179