summaryrefslogtreecommitdiffstats
path: root/meta/lib/oeqa
diff options
context:
space:
mode:
Diffstat (limited to 'meta/lib/oeqa')
-rw-r--r--meta/lib/oeqa/controllers/masterimage.py4
-rw-r--r--meta/lib/oeqa/oetest.py10
-rw-r--r--meta/lib/oeqa/runtime/files/test.py2
-rw-r--r--meta/lib/oeqa/runtime/parselogs.py4
-rw-r--r--meta/lib/oeqa/runtime/ping.py2
-rw-r--r--meta/lib/oeqa/runtime/systemd.py6
-rw-r--r--meta/lib/oeqa/selftest/_toaster.py4
-rw-r--r--meta/lib/oeqa/selftest/devtool.py2
-rw-r--r--meta/lib/oeqa/selftest/pkgdata.py56
-rw-r--r--meta/lib/oeqa/selftest/recipetool.py4
-rw-r--r--meta/lib/oeqa/selftest/sstatetests.py4
-rw-r--r--meta/lib/oeqa/targetcontrol.py4
-rw-r--r--meta/lib/oeqa/utils/commands.py6
-rw-r--r--meta/lib/oeqa/utils/decorators.py19
-rw-r--r--meta/lib/oeqa/utils/dump.py2
-rw-r--r--meta/lib/oeqa/utils/httpserver.py6
-rw-r--r--meta/lib/oeqa/utils/logparser.py2
-rw-r--r--meta/lib/oeqa/utils/qemurunner.py54
-rw-r--r--meta/lib/oeqa/utils/qemutinyrunner.py10
-rw-r--r--meta/lib/oeqa/utils/sshcontrol.py1
-rw-r--r--meta/lib/oeqa/utils/targetbuild.py4
-rw-r--r--meta/lib/oeqa/utils/testexport.py2
22 files changed, 117 insertions, 91 deletions
diff --git a/meta/lib/oeqa/controllers/masterimage.py b/meta/lib/oeqa/controllers/masterimage.py
index 522f9ebd76..4cb75539ee 100644
--- a/meta/lib/oeqa/controllers/masterimage.py
+++ b/meta/lib/oeqa/controllers/masterimage.py
@@ -24,9 +24,7 @@ from oeqa.utils import CommandError
24 24
25from abc import ABCMeta, abstractmethod 25from abc import ABCMeta, abstractmethod
26 26
27class MasterImageHardwareTarget(oeqa.targetcontrol.BaseTarget): 27class MasterImageHardwareTarget(oeqa.targetcontrol.BaseTarget, metaclass=ABCMeta):
28
29 __metaclass__ = ABCMeta
30 28
31 supported_image_fstypes = ['tar.gz', 'tar.bz2'] 29 supported_image_fstypes = ['tar.gz', 'tar.bz2']
32 30
diff --git a/meta/lib/oeqa/oetest.py b/meta/lib/oeqa/oetest.py
index 3ed5bb8c2b..869132273f 100644
--- a/meta/lib/oeqa/oetest.py
+++ b/meta/lib/oeqa/oetest.py
@@ -12,6 +12,7 @@ import unittest
12import inspect 12import inspect
13import subprocess 13import subprocess
14import signal 14import signal
15import functools
15try: 16try:
16 import bb 17 import bb
17except ImportError: 18except ImportError:
@@ -314,7 +315,14 @@ class TestContext(object):
314 for index, suite in enumerate(suites): 315 for index, suite in enumerate(suites):
315 set_suite_depth(suite) 316 set_suite_depth(suite)
316 suite.index = index 317 suite.index = index
317 suites.sort(cmp=lambda a,b: cmp((a.depth, a.index), (b.depth, b.index))) 318
319 def cmp(a, b):
320 return (a > b) - (a < b)
321
322 def cmpfunc(a, b):
323 return cmp((a.depth, a.index), (b.depth, b.index))
324
325 suites.sort(key=functools.cmp_to_key(cmpfunc))
318 326
319 self.suite = testloader.suiteClass(suites) 327 self.suite = testloader.suiteClass(suites)
320 328
diff --git a/meta/lib/oeqa/runtime/files/test.py b/meta/lib/oeqa/runtime/files/test.py
index f3a2273c52..f389225d72 100644
--- a/meta/lib/oeqa/runtime/files/test.py
+++ b/meta/lib/oeqa/runtime/files/test.py
@@ -3,4 +3,4 @@ import os
3os.system('touch /tmp/testfile.python') 3os.system('touch /tmp/testfile.python')
4 4
5a = 9.01e+21 - 9.01e+21 + 0.01 5a = 9.01e+21 - 9.01e+21 + 0.01
6print "the value of a is %s" % a 6print("the value of a is %s" % a)
diff --git a/meta/lib/oeqa/runtime/parselogs.py b/meta/lib/oeqa/runtime/parselogs.py
index a93660131d..242cd8cdd5 100644
--- a/meta/lib/oeqa/runtime/parselogs.py
+++ b/meta/lib/oeqa/runtime/parselogs.py
@@ -238,7 +238,7 @@ class ParseLogsTest(oeRuntimeTest):
238 result = None 238 result = None
239 thegrep = self.build_grepcmd(errors, ignore_errors, log) 239 thegrep = self.build_grepcmd(errors, ignore_errors, log)
240 try: 240 try:
241 result = subprocess.check_output(thegrep, shell=True) 241 result = subprocess.check_output(thegrep, shell=True).decode("utf-8")
242 except: 242 except:
243 pass 243 pass
244 if (result is not None): 244 if (result is not None):
@@ -246,7 +246,7 @@ class ParseLogsTest(oeRuntimeTest):
246 rez = result.splitlines() 246 rez = result.splitlines()
247 for xrez in rez: 247 for xrez in rez:
248 try: 248 try:
249 grep_output = subprocess.check_output(['grep', '-F', xrez, '-B', str(lines_before), '-A', str(lines_after), log]) 249 grep_output = subprocess.check_output(['grep', '-F', xrez, '-B', str(lines_before), '-A', str(lines_after), log]).decode("utf-8")
250 except: 250 except:
251 pass 251 pass
252 results[log.replace('target_logs/','')][xrez]=grep_output 252 results[log.replace('target_logs/','')][xrez]=grep_output
diff --git a/meta/lib/oeqa/runtime/ping.py b/meta/lib/oeqa/runtime/ping.py
index 80c460161b..0f27447926 100644
--- a/meta/lib/oeqa/runtime/ping.py
+++ b/meta/lib/oeqa/runtime/ping.py
@@ -14,7 +14,7 @@ class PingTest(oeRuntimeTest):
14 endtime = time.time() + 60 14 endtime = time.time() + 60
15 while count < 5 and time.time() < endtime: 15 while count < 5 and time.time() < endtime:
16 proc = subprocess.Popen("ping -c 1 %s" % self.target.ip, shell=True, stdout=subprocess.PIPE) 16 proc = subprocess.Popen("ping -c 1 %s" % self.target.ip, shell=True, stdout=subprocess.PIPE)
17 output += proc.communicate()[0] 17 output += proc.communicate()[0].decode("utf-8")
18 if proc.poll() == 0: 18 if proc.poll() == 0:
19 count += 1 19 count += 1
20 else: 20 else:
diff --git a/meta/lib/oeqa/runtime/systemd.py b/meta/lib/oeqa/runtime/systemd.py
index 2b2f10d71c..a96efa28dc 100644
--- a/meta/lib/oeqa/runtime/systemd.py
+++ b/meta/lib/oeqa/runtime/systemd.py
@@ -153,7 +153,7 @@ class SystemdJournalTests(SystemdTest):
153 if check_match: break 153 if check_match: break
154 # put the startup time in the test log 154 # put the startup time in the test log
155 if check_match: 155 if check_match:
156 print "%s" % check_match 156 print("%s" % check_match)
157 else: 157 else:
158 self.skipTest("Error at obtaining the boot time from journalctl") 158 self.skipTest("Error at obtaining the boot time from journalctl")
159 boot_time_sec = 0 159 boot_time_sec = 0
@@ -174,5 +174,5 @@ class SystemdJournalTests(SystemdTest):
174 self.skipTest("Error when parsing time from boot string") 174 self.skipTest("Error when parsing time from boot string")
175 #Assert the target boot time against systemd's unit start timeout 175 #Assert the target boot time against systemd's unit start timeout
176 if boot_time_sec > systemd_TimeoutStartSec: 176 if boot_time_sec > systemd_TimeoutStartSec:
177 print "Target boot time %s exceeds systemd's TimeoutStartSec %s"\ 177 print("Target boot time %s exceeds systemd's TimeoutStartSec %s"\
178 %(boot_time_sec, systemd_TimeoutStartSec) 178 %(boot_time_sec, systemd_TimeoutStartSec))
diff --git a/meta/lib/oeqa/selftest/_toaster.py b/meta/lib/oeqa/selftest/_toaster.py
index c424659fdc..15ea9df9ef 100644
--- a/meta/lib/oeqa/selftest/_toaster.py
+++ b/meta/lib/oeqa/selftest/_toaster.py
@@ -2,7 +2,7 @@ import unittest
2import os 2import os
3import sys 3import sys
4import shlex, subprocess 4import shlex, subprocess
5import urllib, commands, time, getpass, re, json, shlex 5import urllib.request, urllib.parse, urllib.error, subprocess, time, getpass, re, json, shlex
6 6
7import oeqa.utils.ftools as ftools 7import oeqa.utils.ftools as ftools
8from oeqa.selftest.base import oeSelfTest 8from oeqa.selftest.base import oeSelfTest
@@ -290,7 +290,7 @@ class Toaster_DB_Tests(ToasterSetup):
290 layers = Layer.objects.values('id', 'layer_index_url') 290 layers = Layer.objects.values('id', 'layer_index_url')
291 cnt_err = [] 291 cnt_err = []
292 for layer in layers: 292 for layer in layers:
293 resp = urllib.urlopen(layer['layer_index_url']) 293 resp = urllib.request.urlopen(layer['layer_index_url'])
294 if (resp.getcode() != 200): 294 if (resp.getcode() != 200):
295 cnt_err.append(layer['id']) 295 cnt_err.append(layer['id'])
296 self.assertEqual(len(cnt_err), 0, msg = 'Errors for layer id: %s' % cnt_err) 296 self.assertEqual(len(cnt_err), 0, msg = 'Errors for layer id: %s' % cnt_err)
diff --git a/meta/lib/oeqa/selftest/devtool.py b/meta/lib/oeqa/selftest/devtool.py
index 132a73d0ec..d0421e7177 100644
--- a/meta/lib/oeqa/selftest/devtool.py
+++ b/meta/lib/oeqa/selftest/devtool.py
@@ -50,7 +50,7 @@ class DevtoolBase(oeSelfTest):
50 50
51 51
52 missingvars = {} 52 missingvars = {}
53 for var, value in checkvars.iteritems(): 53 for var, value in checkvars.items():
54 if value is not None: 54 if value is not None:
55 missingvars[var] = value 55 missingvars[var] = value
56 self.assertEqual(missingvars, {}, 'Some expected variables not found in recipe: %s' % checkvars) 56 self.assertEqual(missingvars, {}, 'Some expected variables not found in recipe: %s' % checkvars)
diff --git a/meta/lib/oeqa/selftest/pkgdata.py b/meta/lib/oeqa/selftest/pkgdata.py
index 138b03aadb..5a63f89ff2 100644
--- a/meta/lib/oeqa/selftest/pkgdata.py
+++ b/meta/lib/oeqa/selftest/pkgdata.py
@@ -131,15 +131,15 @@ class OePkgdataUtilTests(oeSelfTest):
131 # Test recipe-space package name 131 # Test recipe-space package name
132 result = runCmd('oe-pkgdata-util list-pkg-files zlib-dev zlib-doc') 132 result = runCmd('oe-pkgdata-util list-pkg-files zlib-dev zlib-doc')
133 files = splitoutput(result.output) 133 files = splitoutput(result.output)
134 self.assertIn('zlib-dev', files.keys(), "listed pkgs. files: %s" %result.output) 134 self.assertIn('zlib-dev', list(files.keys()), "listed pkgs. files: %s" %result.output)
135 self.assertIn('zlib-doc', files.keys(), "listed pkgs. files: %s" %result.output) 135 self.assertIn('zlib-doc', list(files.keys()), "listed pkgs. files: %s" %result.output)
136 self.assertIn(os.path.join(includedir, 'zlib.h'), files['zlib-dev']) 136 self.assertIn(os.path.join(includedir, 'zlib.h'), files['zlib-dev'])
137 self.assertIn(os.path.join(mandir, 'man3/zlib.3'), files['zlib-doc']) 137 self.assertIn(os.path.join(mandir, 'man3/zlib.3'), files['zlib-doc'])
138 # Test runtime package name 138 # Test runtime package name
139 result = runCmd('oe-pkgdata-util list-pkg-files -r libz1 libz-dev') 139 result = runCmd('oe-pkgdata-util list-pkg-files -r libz1 libz-dev')
140 files = splitoutput(result.output) 140 files = splitoutput(result.output)
141 self.assertIn('libz1', files.keys(), "listed pkgs. files: %s" %result.output) 141 self.assertIn('libz1', list(files.keys()), "listed pkgs. files: %s" %result.output)
142 self.assertIn('libz-dev', files.keys(), "listed pkgs. files: %s" %result.output) 142 self.assertIn('libz-dev', list(files.keys()), "listed pkgs. files: %s" %result.output)
143 self.assertGreater(len(files['libz1']), 1) 143 self.assertGreater(len(files['libz1']), 1)
144 libspec = os.path.join(base_libdir, 'libz.so.1.*') 144 libspec = os.path.join(base_libdir, 'libz.so.1.*')
145 found = False 145 found = False
@@ -152,12 +152,12 @@ class OePkgdataUtilTests(oeSelfTest):
152 # Test recipe 152 # Test recipe
153 result = runCmd('oe-pkgdata-util list-pkg-files -p zlib') 153 result = runCmd('oe-pkgdata-util list-pkg-files -p zlib')
154 files = splitoutput(result.output) 154 files = splitoutput(result.output)
155 self.assertIn('zlib-dbg', files.keys(), "listed pkgs. files: %s" %result.output) 155 self.assertIn('zlib-dbg', list(files.keys()), "listed pkgs. files: %s" %result.output)
156 self.assertIn('zlib-doc', files.keys(), "listed pkgs. files: %s" %result.output) 156 self.assertIn('zlib-doc', list(files.keys()), "listed pkgs. files: %s" %result.output)
157 self.assertIn('zlib-dev', files.keys(), "listed pkgs. files: %s" %result.output) 157 self.assertIn('zlib-dev', list(files.keys()), "listed pkgs. files: %s" %result.output)
158 self.assertIn('zlib-staticdev', files.keys(), "listed pkgs. files: %s" %result.output) 158 self.assertIn('zlib-staticdev', list(files.keys()), "listed pkgs. files: %s" %result.output)
159 self.assertIn('zlib', files.keys(), "listed pkgs. files: %s" %result.output) 159 self.assertIn('zlib', list(files.keys()), "listed pkgs. files: %s" %result.output)
160 self.assertNotIn('zlib-locale', files.keys(), "listed pkgs. files: %s" %result.output) 160 self.assertNotIn('zlib-locale', list(files.keys()), "listed pkgs. files: %s" %result.output)
161 # (ignore ptest, might not be there depending on config) 161 # (ignore ptest, might not be there depending on config)
162 self.assertIn(os.path.join(includedir, 'zlib.h'), files['zlib-dev']) 162 self.assertIn(os.path.join(includedir, 'zlib.h'), files['zlib-dev'])
163 self.assertIn(os.path.join(mandir, 'man3/zlib.3'), files['zlib-doc']) 163 self.assertIn(os.path.join(mandir, 'man3/zlib.3'), files['zlib-doc'])
@@ -165,36 +165,36 @@ class OePkgdataUtilTests(oeSelfTest):
165 # Test recipe, runtime 165 # Test recipe, runtime
166 result = runCmd('oe-pkgdata-util list-pkg-files -p zlib -r') 166 result = runCmd('oe-pkgdata-util list-pkg-files -p zlib -r')
167 files = splitoutput(result.output) 167 files = splitoutput(result.output)
168 self.assertIn('libz-dbg', files.keys(), "listed pkgs. files: %s" %result.output) 168 self.assertIn('libz-dbg', list(files.keys()), "listed pkgs. files: %s" %result.output)
169 self.assertIn('libz-doc', files.keys(), "listed pkgs. files: %s" %result.output) 169 self.assertIn('libz-doc', list(files.keys()), "listed pkgs. files: %s" %result.output)
170 self.assertIn('libz-dev', files.keys(), "listed pkgs. files: %s" %result.output) 170 self.assertIn('libz-dev', list(files.keys()), "listed pkgs. files: %s" %result.output)
171 self.assertIn('libz-staticdev', files.keys(), "listed pkgs. files: %s" %result.output) 171 self.assertIn('libz-staticdev', list(files.keys()), "listed pkgs. files: %s" %result.output)
172 self.assertIn('libz1', files.keys(), "listed pkgs. files: %s" %result.output) 172 self.assertIn('libz1', list(files.keys()), "listed pkgs. files: %s" %result.output)
173 self.assertNotIn('libz-locale', files.keys(), "listed pkgs. files: %s" %result.output) 173 self.assertNotIn('libz-locale', list(files.keys()), "listed pkgs. files: %s" %result.output)
174 self.assertIn(os.path.join(includedir, 'zlib.h'), files['libz-dev']) 174 self.assertIn(os.path.join(includedir, 'zlib.h'), files['libz-dev'])
175 self.assertIn(os.path.join(mandir, 'man3/zlib.3'), files['libz-doc']) 175 self.assertIn(os.path.join(mandir, 'man3/zlib.3'), files['libz-doc'])
176 self.assertIn(os.path.join(libdir, 'libz.a'), files['libz-staticdev']) 176 self.assertIn(os.path.join(libdir, 'libz.a'), files['libz-staticdev'])
177 # Test recipe, unpackaged 177 # Test recipe, unpackaged
178 result = runCmd('oe-pkgdata-util list-pkg-files -p zlib -u') 178 result = runCmd('oe-pkgdata-util list-pkg-files -p zlib -u')
179 files = splitoutput(result.output) 179 files = splitoutput(result.output)
180 self.assertIn('zlib-dbg', files.keys(), "listed pkgs. files: %s" %result.output) 180 self.assertIn('zlib-dbg', list(files.keys()), "listed pkgs. files: %s" %result.output)
181 self.assertIn('zlib-doc', files.keys(), "listed pkgs. files: %s" %result.output) 181 self.assertIn('zlib-doc', list(files.keys()), "listed pkgs. files: %s" %result.output)
182 self.assertIn('zlib-dev', files.keys(), "listed pkgs. files: %s" %result.output) 182 self.assertIn('zlib-dev', list(files.keys()), "listed pkgs. files: %s" %result.output)
183 self.assertIn('zlib-staticdev', files.keys(), "listed pkgs. files: %s" %result.output) 183 self.assertIn('zlib-staticdev', list(files.keys()), "listed pkgs. files: %s" %result.output)
184 self.assertIn('zlib', files.keys(), "listed pkgs. files: %s" %result.output) 184 self.assertIn('zlib', list(files.keys()), "listed pkgs. files: %s" %result.output)
185 self.assertIn('zlib-locale', files.keys(), "listed pkgs. files: %s" %result.output) # this is the key one 185 self.assertIn('zlib-locale', list(files.keys()), "listed pkgs. files: %s" %result.output) # this is the key one
186 self.assertIn(os.path.join(includedir, 'zlib.h'), files['zlib-dev']) 186 self.assertIn(os.path.join(includedir, 'zlib.h'), files['zlib-dev'])
187 self.assertIn(os.path.join(mandir, 'man3/zlib.3'), files['zlib-doc']) 187 self.assertIn(os.path.join(mandir, 'man3/zlib.3'), files['zlib-doc'])
188 self.assertIn(os.path.join(libdir, 'libz.a'), files['zlib-staticdev']) 188 self.assertIn(os.path.join(libdir, 'libz.a'), files['zlib-staticdev'])
189 # Test recipe, runtime, unpackaged 189 # Test recipe, runtime, unpackaged
190 result = runCmd('oe-pkgdata-util list-pkg-files -p zlib -r -u') 190 result = runCmd('oe-pkgdata-util list-pkg-files -p zlib -r -u')
191 files = splitoutput(result.output) 191 files = splitoutput(result.output)
192 self.assertIn('libz-dbg', files.keys(), "listed pkgs. files: %s" %result.output) 192 self.assertIn('libz-dbg', list(files.keys()), "listed pkgs. files: %s" %result.output)
193 self.assertIn('libz-doc', files.keys(), "listed pkgs. files: %s" %result.output) 193 self.assertIn('libz-doc', list(files.keys()), "listed pkgs. files: %s" %result.output)
194 self.assertIn('libz-dev', files.keys(), "listed pkgs. files: %s" %result.output) 194 self.assertIn('libz-dev', list(files.keys()), "listed pkgs. files: %s" %result.output)
195 self.assertIn('libz-staticdev', files.keys(), "listed pkgs. files: %s" %result.output) 195 self.assertIn('libz-staticdev', list(files.keys()), "listed pkgs. files: %s" %result.output)
196 self.assertIn('libz1', files.keys(), "listed pkgs. files: %s" %result.output) 196 self.assertIn('libz1', list(files.keys()), "listed pkgs. files: %s" %result.output)
197 self.assertIn('libz-locale', files.keys(), "listed pkgs. files: %s" %result.output) # this is the key one 197 self.assertIn('libz-locale', list(files.keys()), "listed pkgs. files: %s" %result.output) # this is the key one
198 self.assertIn(os.path.join(includedir, 'zlib.h'), files['libz-dev']) 198 self.assertIn(os.path.join(includedir, 'zlib.h'), files['libz-dev'])
199 self.assertIn(os.path.join(mandir, 'man3/zlib.3'), files['libz-doc']) 199 self.assertIn(os.path.join(mandir, 'man3/zlib.3'), files['libz-doc'])
200 self.assertIn(os.path.join(libdir, 'libz.a'), files['libz-staticdev']) 200 self.assertIn(os.path.join(libdir, 'libz.a'), files['libz-staticdev'])
diff --git a/meta/lib/oeqa/selftest/recipetool.py b/meta/lib/oeqa/selftest/recipetool.py
index e72911b0aa..a93d18e275 100644
--- a/meta/lib/oeqa/selftest/recipetool.py
+++ b/meta/lib/oeqa/selftest/recipetool.py
@@ -1,7 +1,7 @@
1import os 1import os
2import logging 2import logging
3import tempfile 3import tempfile
4import urlparse 4import urllib.parse
5 5
6from oeqa.utils.commands import runCmd, bitbake, get_bb_var, create_temp_layer 6from oeqa.utils.commands import runCmd, bitbake, get_bb_var, create_temp_layer
7from oeqa.utils.decorators import testcase 7from oeqa.utils.decorators import testcase
@@ -471,7 +471,7 @@ class RecipetoolAppendsrcBase(RecipetoolBase):
471 '''Return the first file:// in SRC_URI for the specified recipe.''' 471 '''Return the first file:// in SRC_URI for the specified recipe.'''
472 src_uri = get_bb_var('SRC_URI', recipe).split() 472 src_uri = get_bb_var('SRC_URI', recipe).split()
473 for uri in src_uri: 473 for uri in src_uri:
474 p = urlparse.urlparse(uri) 474 p = urllib.parse.urlparse(uri)
475 if p.scheme == 'file': 475 if p.scheme == 'file':
476 return p.netloc + p.path 476 return p.netloc + p.path
477 477
diff --git a/meta/lib/oeqa/selftest/sstatetests.py b/meta/lib/oeqa/selftest/sstatetests.py
index a1e5d33580..cc64c6cb68 100644
--- a/meta/lib/oeqa/selftest/sstatetests.py
+++ b/meta/lib/oeqa/selftest/sstatetests.py
@@ -445,14 +445,14 @@ http_proxy = "http://example.com/"
445 files1 = get_files(topdir + "/tmp-sstatesamehash/stamps/") 445 files1 = get_files(topdir + "/tmp-sstatesamehash/stamps/")
446 files2 = get_files(topdir + "/tmp-sstatesamehash2/stamps/") 446 files2 = get_files(topdir + "/tmp-sstatesamehash2/stamps/")
447 # Remove items that are identical in both sets 447 # Remove items that are identical in both sets
448 for k,v in files1.viewitems() & files2.viewitems(): 448 for k,v in files1.items() & files2.items():
449 del files1[k] 449 del files1[k]
450 del files2[k] 450 del files2[k]
451 if not files1 and not files2: 451 if not files1 and not files2:
452 # No changes, so we're done 452 # No changes, so we're done
453 return 453 return
454 454
455 for k in files1.viewkeys() | files2.viewkeys(): 455 for k in files1.keys() | files2.keys():
456 if k in files1 and k in files2: 456 if k in files1 and k in files2:
457 print("%s differs:" % k) 457 print("%s differs:" % k)
458 print(subprocess.check_output(("bitbake-diffsigs", 458 print(subprocess.check_output(("bitbake-diffsigs",
diff --git a/meta/lib/oeqa/targetcontrol.py b/meta/lib/oeqa/targetcontrol.py
index 5422a617c4..1c57efaaef 100644
--- a/meta/lib/oeqa/targetcontrol.py
+++ b/meta/lib/oeqa/targetcontrol.py
@@ -43,9 +43,7 @@ def get_target_controller(d):
43 return controller(d) 43 return controller(d)
44 44
45 45
46class BaseTarget(object): 46class BaseTarget(object, metaclass=ABCMeta):
47
48 __metaclass__ = ABCMeta
49 47
50 supported_image_fstypes = [] 48 supported_image_fstypes = []
51 49
diff --git a/meta/lib/oeqa/utils/commands.py b/meta/lib/oeqa/utils/commands.py
index 48f6441290..18fe39ecfe 100644
--- a/meta/lib/oeqa/utils/commands.py
+++ b/meta/lib/oeqa/utils/commands.py
@@ -41,7 +41,7 @@ class Command(object):
41 self.data = data 41 self.data = data
42 42
43 self.options = dict(self.defaultopts) 43 self.options = dict(self.defaultopts)
44 if isinstance(self.cmd, basestring): 44 if isinstance(self.cmd, str):
45 self.options["shell"] = True 45 self.options["shell"] = True
46 if self.data: 46 if self.data:
47 self.options['stdin'] = subprocess.PIPE 47 self.options['stdin'] = subprocess.PIPE
@@ -78,7 +78,7 @@ class Command(object):
78 self.process.kill() 78 self.process.kill()
79 self.thread.join() 79 self.thread.join()
80 80
81 self.output = self.output.rstrip() 81 self.output = self.output.decode("utf-8").rstrip()
82 self.status = self.process.poll() 82 self.status = self.process.poll()
83 83
84 self.log.debug("Command '%s' returned %d as exit code." % (self.cmd, self.status)) 84 self.log.debug("Command '%s' returned %d as exit code." % (self.cmd, self.status))
@@ -123,7 +123,7 @@ def bitbake(command, ignore_status=False, timeout=None, postconfig=None, **optio
123 else: 123 else:
124 extra_args = "" 124 extra_args = ""
125 125
126 if isinstance(command, basestring): 126 if isinstance(command, str):
127 cmd = "bitbake " + extra_args + " " + command 127 cmd = "bitbake " + extra_args + " " + command
128 else: 128 else:
129 cmd = [ "bitbake" ] + [a for a in (command + extra_args.split(" ")) if a not in [""]] 129 cmd = [ "bitbake" ] + [a for a in (command + extra_args.split(" ")) if a not in [""]]
diff --git a/meta/lib/oeqa/utils/decorators.py b/meta/lib/oeqa/utils/decorators.py
index d52f326f1a..0b23565485 100644
--- a/meta/lib/oeqa/utils/decorators.py
+++ b/meta/lib/oeqa/utils/decorators.py
@@ -115,6 +115,8 @@ class NoParsingFilter(logging.Filter):
115 def filter(self, record): 115 def filter(self, record):
116 return record.levelno == 100 116 return record.levelno == 100
117 117
118import inspect
119
118def LogResults(original_class): 120def LogResults(original_class):
119 orig_method = original_class.run 121 orig_method = original_class.run
120 122
@@ -124,6 +126,19 @@ def LogResults(original_class):
124 logfile = os.path.join(os.getcwd(),'results-'+caller+'.'+timestamp+'.log') 126 logfile = os.path.join(os.getcwd(),'results-'+caller+'.'+timestamp+'.log')
125 linkfile = os.path.join(os.getcwd(),'results-'+caller+'.log') 127 linkfile = os.path.join(os.getcwd(),'results-'+caller+'.log')
126 128
129 def get_class_that_defined_method(meth):
130 if inspect.ismethod(meth):
131 for cls in inspect.getmro(meth.__self__.__class__):
132 if cls.__dict__.get(meth.__name__) is meth:
133 return cls
134 meth = meth.__func__ # fallback to __qualname__ parsing
135 if inspect.isfunction(meth):
136 cls = getattr(inspect.getmodule(meth),
137 meth.__qualname__.split('.<locals>', 1)[0].rsplit('.', 1)[0])
138 if isinstance(cls, type):
139 return cls
140 return None
141
127 #rewrite the run method of unittest.TestCase to add testcase logging 142 #rewrite the run method of unittest.TestCase to add testcase logging
128 def run(self, result, *args, **kws): 143 def run(self, result, *args, **kws):
129 orig_method(self, result, *args, **kws) 144 orig_method(self, result, *args, **kws)
@@ -135,7 +150,7 @@ def LogResults(original_class):
135 except AttributeError: 150 except AttributeError:
136 test_case = self._testMethodName 151 test_case = self._testMethodName
137 152
138 class_name = str(testMethod.im_class).split("'")[1] 153 class_name = str(get_class_that_defined_method(testMethod)).split("'")[1]
139 154
140 #create custom logging level for filtering. 155 #create custom logging level for filtering.
141 custom_log_level = 100 156 custom_log_level = 100
@@ -215,7 +230,7 @@ def tag(*args, **kwargs):
215 def wrap_ob(ob): 230 def wrap_ob(ob):
216 for name in args: 231 for name in args:
217 setattr(ob, __tag_prefix + name, True) 232 setattr(ob, __tag_prefix + name, True)
218 for name, value in kwargs.iteritems(): 233 for name, value in kwargs.items():
219 setattr(ob, __tag_prefix + name, value) 234 setattr(ob, __tag_prefix + name, value)
220 return ob 235 return ob
221 return wrap_ob 236 return wrap_ob
diff --git a/meta/lib/oeqa/utils/dump.py b/meta/lib/oeqa/utils/dump.py
index 63a591d366..71422a9aea 100644
--- a/meta/lib/oeqa/utils/dump.py
+++ b/meta/lib/oeqa/utils/dump.py
@@ -3,7 +3,7 @@ import sys
3import errno 3import errno
4import datetime 4import datetime
5import itertools 5import itertools
6from commands import runCmd 6from .commands import runCmd
7 7
8def get_host_dumper(d): 8def get_host_dumper(d):
9 cmds = d.getVar("testimage_dump_host", True) 9 cmds = d.getVar("testimage_dump_host", True)
diff --git a/meta/lib/oeqa/utils/httpserver.py b/meta/lib/oeqa/utils/httpserver.py
index 76518d8ef9..bd76f36468 100644
--- a/meta/lib/oeqa/utils/httpserver.py
+++ b/meta/lib/oeqa/utils/httpserver.py
@@ -1,8 +1,8 @@
1import SimpleHTTPServer 1import http.server
2import multiprocessing 2import multiprocessing
3import os 3import os
4 4
5class HTTPServer(SimpleHTTPServer.BaseHTTPServer.HTTPServer): 5class HTTPServer(http.server.HTTPServer):
6 6
7 def server_start(self, root_dir): 7 def server_start(self, root_dir):
8 import signal 8 import signal
@@ -10,7 +10,7 @@ class HTTPServer(SimpleHTTPServer.BaseHTTPServer.HTTPServer):
10 os.chdir(root_dir) 10 os.chdir(root_dir)
11 self.serve_forever() 11 self.serve_forever()
12 12
13class HTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler): 13class HTTPRequestHandler(http.server.SimpleHTTPRequestHandler):
14 14
15 def log_message(self, format_str, *args): 15 def log_message(self, format_str, *args):
16 pass 16 pass
diff --git a/meta/lib/oeqa/utils/logparser.py b/meta/lib/oeqa/utils/logparser.py
index 87b50354cd..b377dcd271 100644
--- a/meta/lib/oeqa/utils/logparser.py
+++ b/meta/lib/oeqa/utils/logparser.py
@@ -3,7 +3,7 @@
3import sys 3import sys
4import os 4import os
5import re 5import re
6import ftools 6from . import ftools
7 7
8 8
9# A parser that can be used to identify weather a line is a test result or a section statement. 9# A parser that can be used to identify weather a line is a test result or a section statement.
diff --git a/meta/lib/oeqa/utils/qemurunner.py b/meta/lib/oeqa/utils/qemurunner.py
index 4bede3421c..773cf588b1 100644
--- a/meta/lib/oeqa/utils/qemurunner.py
+++ b/meta/lib/oeqa/utils/qemurunner.py
@@ -22,9 +22,9 @@ import logging
22logger = logging.getLogger("BitBake.QemuRunner") 22logger = logging.getLogger("BitBake.QemuRunner")
23 23
24# Get Unicode non printable control chars 24# Get Unicode non printable control chars
25control_range = range(0,32)+range(127,160) 25control_range = list(range(0,32))+list(range(127,160))
26control_chars = [unichr(x) for x in control_range 26control_chars = [chr(x) for x in control_range
27 if unichr(x) not in string.printable] 27 if chr(x) not in string.printable]
28re_control_char = re.compile('[%s]' % re.escape("".join(control_chars))) 28re_control_char = re.compile('[%s]' % re.escape("".join(control_chars)))
29 29
30class QemuRunner: 30class QemuRunner:
@@ -71,7 +71,8 @@ class QemuRunner:
71 if self.logfile: 71 if self.logfile:
72 # It is needed to sanitize the data received from qemu 72 # It is needed to sanitize the data received from qemu
73 # because is possible to have control characters 73 # because is possible to have control characters
74 msg = re_control_char.sub('', unicode(msg, 'utf-8')) 74 msg = msg.decode("utf-8")
75 msg = re_control_char.sub('', msg)
75 with codecs.open(self.logfile, "a", encoding="utf-8") as f: 76 with codecs.open(self.logfile, "a", encoding="utf-8") as f:
76 f.write("%s" % msg) 77 f.write("%s" % msg)
77 78
@@ -79,7 +80,7 @@ class QemuRunner:
79 import fcntl 80 import fcntl
80 fl = fcntl.fcntl(o, fcntl.F_GETFL) 81 fl = fcntl.fcntl(o, fcntl.F_GETFL)
81 fcntl.fcntl(o, fcntl.F_SETFL, fl | os.O_NONBLOCK) 82 fcntl.fcntl(o, fcntl.F_SETFL, fl | os.O_NONBLOCK)
82 return os.read(o.fileno(), 1000000) 83 return os.read(o.fileno(), 1000000).decode("utf-8")
83 84
84 85
85 def handleSIGCHLD(self, signum, frame): 86 def handleSIGCHLD(self, signum, frame):
@@ -114,7 +115,7 @@ class QemuRunner:
114 try: 115 try:
115 threadsock, threadport = self.create_socket() 116 threadsock, threadport = self.create_socket()
116 self.server_socket, self.serverport = self.create_socket() 117 self.server_socket, self.serverport = self.create_socket()
117 except socket.error, msg: 118 except socket.error as msg:
118 logger.error("Failed to create listening socket: %s" % msg[1]) 119 logger.error("Failed to create listening socket: %s" % msg[1])
119 return False 120 return False
120 121
@@ -192,7 +193,7 @@ class QemuRunner:
192 else: 193 else:
193 self.ip = ips[0] 194 self.ip = ips[0]
194 self.server_ip = ips[1] 195 self.server_ip = ips[1]
195 except IndexError, ValueError: 196 except (IndexError, ValueError):
196 logger.info("Couldn't get ip from qemu process arguments! Here is the qemu command line used:\n%s\nand output from runqemu:\n%s" % (cmdline, self.getOutput(output))) 197 logger.info("Couldn't get ip from qemu process arguments! Here is the qemu command line used:\n%s\nand output from runqemu:\n%s" % (cmdline, self.getOutput(output)))
197 self._dump_host() 198 self._dump_host()
198 self.stop() 199 self.stop()
@@ -219,6 +220,7 @@ class QemuRunner:
219 stopread = False 220 stopread = False
220 qemusock = None 221 qemusock = None
221 bootlog = '' 222 bootlog = ''
223 data = b''
222 while time.time() < endtime and not stopread: 224 while time.time() < endtime and not stopread:
223 sread, swrite, serror = select.select(socklist, [], [], 5) 225 sread, swrite, serror = select.select(socklist, [], [], 5)
224 for sock in sread: 226 for sock in sread:
@@ -229,14 +231,19 @@ class QemuRunner:
229 socklist.remove(self.server_socket) 231 socklist.remove(self.server_socket)
230 logger.info("Connection from %s:%s" % addr) 232 logger.info("Connection from %s:%s" % addr)
231 else: 233 else:
232 data = sock.recv(1024) 234 data = data + sock.recv(1024)
233 if data: 235 if data:
234 bootlog += data 236 try:
235 if re.search(".* login:", bootlog): 237 data = data.decode("utf-8")
236 self.server_socket = qemusock 238 bootlog += data
237 stopread = True 239 data = b''
238 reachedlogin = True 240 if re.search(".* login:", bootlog):
239 logger.info("Reached login banner") 241 self.server_socket = qemusock
242 stopread = True
243 reachedlogin = True
244 logger.info("Reached login banner")
245 except UnicodeDecodeError:
246 continue
240 else: 247 else:
241 socklist.remove(sock) 248 socklist.remove(sock)
242 sock.close() 249 sock.close()
@@ -277,13 +284,14 @@ class QemuRunner:
277 if hasattr(self, "origchldhandler"): 284 if hasattr(self, "origchldhandler"):
278 signal.signal(signal.SIGCHLD, self.origchldhandler) 285 signal.signal(signal.SIGCHLD, self.origchldhandler)
279 if self.runqemu: 286 if self.runqemu:
280 os.kill(self.monitorpid, signal.SIGKILL) 287 if hasattr(self, "monitorpid"):
281 logger.info("Sending SIGTERM to runqemu") 288 os.kill(self.monitorpid, signal.SIGKILL)
282 try: 289 logger.info("Sending SIGTERM to runqemu")
283 os.killpg(os.getpgid(self.runqemu.pid), signal.SIGTERM) 290 try:
284 except OSError as e: 291 os.killpg(os.getpgid(self.runqemu.pid), signal.SIGTERM)
285 if e.errno != errno.ESRCH: 292 except OSError as e:
286 raise 293 if e.errno != errno.ESRCH:
294 raise
287 endtime = time.time() + self.runqemutime 295 endtime = time.time() + self.runqemutime
288 while self.runqemu.poll() is None and time.time() < endtime: 296 while self.runqemu.poll() is None and time.time() < endtime:
289 time.sleep(1) 297 time.sleep(1)
@@ -325,7 +333,7 @@ class QemuRunner:
325 # Walk the process tree from the process specified looking for a qemu-system. Return its [pid'cmd] 333 # Walk the process tree from the process specified looking for a qemu-system. Return its [pid'cmd]
326 # 334 #
327 ps = subprocess.Popen(['ps', 'axww', '-o', 'pid,ppid,command'], stdout=subprocess.PIPE).communicate()[0] 335 ps = subprocess.Popen(['ps', 'axww', '-o', 'pid,ppid,command'], stdout=subprocess.PIPE).communicate()[0]
328 processes = ps.split('\n') 336 processes = ps.decode("utf-8").split('\n')
329 nfields = len(processes[0].split()) - 1 337 nfields = len(processes[0].split()) - 1
330 pids = {} 338 pids = {}
331 commands = {} 339 commands = {}
@@ -442,7 +450,7 @@ class LoggingThread(threading.Thread):
442 def stop(self): 450 def stop(self):
443 self.logger.info("Stopping logging thread") 451 self.logger.info("Stopping logging thread")
444 if self.running: 452 if self.running:
445 os.write(self.writepipe, "stop") 453 os.write(self.writepipe, bytes("stop", "utf-8"))
446 454
447 def teardown(self): 455 def teardown(self):
448 self.logger.info("Tearing down logging thread") 456 self.logger.info("Tearing down logging thread")
diff --git a/meta/lib/oeqa/utils/qemutinyrunner.py b/meta/lib/oeqa/utils/qemutinyrunner.py
index e3d8c669e0..f733258bce 100644
--- a/meta/lib/oeqa/utils/qemutinyrunner.py
+++ b/meta/lib/oeqa/utils/qemutinyrunner.py
@@ -13,7 +13,7 @@ import re
13import socket 13import socket
14import select 14import select
15import bb 15import bb
16from qemurunner import QemuRunner 16from .qemurunner import QemuRunner
17 17
18class QemuTinyRunner(QemuRunner): 18class QemuTinyRunner(QemuRunner):
19 19
@@ -50,7 +50,7 @@ class QemuTinyRunner(QemuRunner):
50 self.server_socket.connect(self.socketfile) 50 self.server_socket.connect(self.socketfile)
51 bb.note("Created listening socket for qemu serial console.") 51 bb.note("Created listening socket for qemu serial console.")
52 tries = 0 52 tries = 0
53 except socket.error, msg: 53 except socket.error as msg:
54 self.server_socket.close() 54 self.server_socket.close()
55 bb.fatal("Failed to create listening socket.") 55 bb.fatal("Failed to create listening socket.")
56 tries -= 1 56 tries -= 1
@@ -102,7 +102,7 @@ class QemuTinyRunner(QemuRunner):
102 bb.note("Qemu pid didn't appeared in %s seconds" % self.runqemutime) 102 bb.note("Qemu pid didn't appeared in %s seconds" % self.runqemutime)
103 output = self.runqemu.stdout 103 output = self.runqemu.stdout
104 self.stop() 104 self.stop()
105 bb.note("Output from runqemu:\n%s" % output.read()) 105 bb.note("Output from runqemu:\n%s" % output.read().decode("utf-8"))
106 return False 106 return False
107 107
108 return self.is_alive() 108 return self.is_alive()
@@ -131,7 +131,7 @@ class QemuTinyRunner(QemuRunner):
131 # Walk the process tree from the process specified looking for a qemu-system. Return its [pid'cmd] 131 # Walk the process tree from the process specified looking for a qemu-system. Return its [pid'cmd]
132 # 132 #
133 ps = subprocess.Popen(['ps', 'axww', '-o', 'pid,ppid,command'], stdout=subprocess.PIPE).communicate()[0] 133 ps = subprocess.Popen(['ps', 'axww', '-o', 'pid,ppid,command'], stdout=subprocess.PIPE).communicate()[0]
134 processes = ps.split('\n') 134 processes = ps.decode("utf-8").split('\n')
135 nfields = len(processes[0].split()) - 1 135 nfields = len(processes[0].split()) - 1
136 pids = {} 136 pids = {}
137 commands = {} 137 commands = {}
@@ -167,4 +167,4 @@ class QemuTinyRunner(QemuRunner):
167 basecmd = commands[p].split()[0] 167 basecmd = commands[p].split()[0]
168 basecmd = os.path.basename(basecmd) 168 basecmd = os.path.basename(basecmd)
169 if "qemu-system" in basecmd and "-serial unix" in commands[p]: 169 if "qemu-system" in basecmd and "-serial unix" in commands[p]:
170 return [int(p),commands[p]] \ No newline at end of file 170 return [int(p),commands[p]]
diff --git a/meta/lib/oeqa/utils/sshcontrol.py b/meta/lib/oeqa/utils/sshcontrol.py
index ff88d37bd9..f5d46e03cc 100644
--- a/meta/lib/oeqa/utils/sshcontrol.py
+++ b/meta/lib/oeqa/utils/sshcontrol.py
@@ -58,6 +58,7 @@ class SSHProcess(object):
58 self.process.stdout.close() 58 self.process.stdout.close()
59 eof = True 59 eof = True
60 else: 60 else:
61 data = data.decode("utf-8")
61 output += data 62 output += data
62 self.log(data) 63 self.log(data)
63 endtime = time.time() + timeout 64 endtime = time.time() + timeout
diff --git a/meta/lib/oeqa/utils/targetbuild.py b/meta/lib/oeqa/utils/targetbuild.py
index f850d78df1..d538f6b65f 100644
--- a/meta/lib/oeqa/utils/targetbuild.py
+++ b/meta/lib/oeqa/utils/targetbuild.py
@@ -10,9 +10,7 @@ import bb.utils
10import subprocess 10import subprocess
11from abc import ABCMeta, abstractmethod 11from abc import ABCMeta, abstractmethod
12 12
13class BuildProject(): 13class BuildProject(metaclass=ABCMeta):
14
15 __metaclass__ = ABCMeta
16 14
17 def __init__(self, d, uri, foldername=None, tmpdir="/tmp/"): 15 def __init__(self, d, uri, foldername=None, tmpdir="/tmp/"):
18 self.d = d 16 self.d = d
diff --git a/meta/lib/oeqa/utils/testexport.py b/meta/lib/oeqa/utils/testexport.py
index 4fbf4bdcb3..57be2ca449 100644
--- a/meta/lib/oeqa/utils/testexport.py
+++ b/meta/lib/oeqa/utils/testexport.py
@@ -6,7 +6,7 @@
6 6
7import os, re, glob as g, shutil as sh,sys 7import os, re, glob as g, shutil as sh,sys
8from time import sleep 8from time import sleep
9from commands import runCmd 9from .commands import runCmd
10from difflib import SequenceMatcher as SM 10from difflib import SequenceMatcher as SM
11 11
12try: 12try: