summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2016-05-21 12:25:02 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-05-21 22:26:32 +0100
commitffe9604be2556b8b5c3f98bcc5283b00bf0c0dab (patch)
tree67685ecaeb22f93d6a78f707b69170b0bbd270b8
parent02986886fc40c0fcd33359a279ba9520fd5cac2a (diff)
downloadpoky-ffe9604be2556b8b5c3f98bcc5283b00bf0c0dab.tar.gz
meta/selftest/scripts: Use print function for python3 compatibility
Used print function instead of print statement to make the code work in python 3. [Changes from both Ed and Richard] (From OE-Core rev: ced1995694c394d92cb82fb9c25a33dc027a3b69) Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--meta-selftest/lib/devtool/test.py2
-rw-r--r--meta/lib/oe/qa.py2
-rw-r--r--meta/lib/oe/utils.py2
-rw-r--r--meta/lib/oeqa/runtime/files/test.py2
-rw-r--r--meta/lib/oeqa/runtime/systemd.py6
-rw-r--r--meta/lib/oeqa/selftest/base.py2
-rwxr-xr-xscripts/oe-selftest49
7 files changed, 32 insertions, 33 deletions
diff --git a/meta-selftest/lib/devtool/test.py b/meta-selftest/lib/devtool/test.py
index b7474b5eee..31190f58e7 100644
--- a/meta-selftest/lib/devtool/test.py
+++ b/meta-selftest/lib/devtool/test.py
@@ -2,7 +2,7 @@ import argparse
2 2
3def selftest_reverse(args, config, basepath, workspace): 3def selftest_reverse(args, config, basepath, workspace):
4 """Reverse the value passed to verify the plugin is executing.""" 4 """Reverse the value passed to verify the plugin is executing."""
5 print args.value[::-1] 5 print(args.value[::-1])
6 6
7def register_commands(subparsers, context): 7def register_commands(subparsers, context):
8 parser_build = subparsers.add_parser('selftest-reverse', help='Reverse value (for selftest)', 8 parser_build = subparsers.add_parser('selftest-reverse', help='Reverse value (for selftest)',
diff --git a/meta/lib/oe/qa.py b/meta/lib/oe/qa.py
index 3cfeee737b..cc2902f4af 100644
--- a/meta/lib/oe/qa.py
+++ b/meta/lib/oe/qa.py
@@ -148,4 +148,4 @@ if __name__ == "__main__":
148 import sys 148 import sys
149 elf = ELFFile(sys.argv[1]) 149 elf = ELFFile(sys.argv[1])
150 elf.open() 150 elf.open()
151 print elf.isDynamic() 151 print(elf.isDynamic())
diff --git a/meta/lib/oe/utils.py b/meta/lib/oe/utils.py
index 30d30629f1..d1dfbfb95d 100644
--- a/meta/lib/oe/utils.py
+++ b/meta/lib/oe/utils.py
@@ -265,7 +265,7 @@ class ThreadedWorker(Thread):
265 try: 265 try:
266 func(self, *args, **kargs) 266 func(self, *args, **kargs)
267 except Exception, e: 267 except Exception, e:
268 print e 268 print(e)
269 finally: 269 finally:
270 self.tasks.task_done() 270 self.tasks.task_done()
271 271
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/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/base.py b/meta/lib/oeqa/selftest/base.py
index e10455edc1..b5a52fe57a 100644
--- a/meta/lib/oeqa/selftest/base.py
+++ b/meta/lib/oeqa/selftest/base.py
@@ -67,7 +67,7 @@ class oeSelfTest(unittest.TestCase):
67 machine = custommachine 67 machine = custommachine
68 machine_conf = 'MACHINE ??= "%s"\n' % machine 68 machine_conf = 'MACHINE ??= "%s"\n' % machine
69 self.set_machine_config(machine_conf) 69 self.set_machine_config(machine_conf)
70 print 'MACHINE: %s' % machine 70 print('MACHINE: %s' % machine)
71 71
72 # tests might need their own setup 72 # tests might need their own setup
73 # but if they overwrite this one they have to call 73 # but if they overwrite this one they have to call
diff --git a/scripts/oe-selftest b/scripts/oe-selftest
index 8cc2095c53..900b3f4873 100755
--- a/scripts/oe-selftest
+++ b/scripts/oe-selftest
@@ -220,12 +220,12 @@ def get_tests_from_module(tmod):
220 try: 220 try:
221 tid = vars(mod)[test].test_case 221 tid = vars(mod)[test].test_case
222 except: 222 except:
223 print 'DEBUG: tc id missing for ' + str(test) 223 print('DEBUG: tc id missing for ' + str(test))
224 tid = None 224 tid = None
225 try: 225 try:
226 ttag = vars(mod)[test].tag__feature 226 ttag = vars(mod)[test].tag__feature
227 except: 227 except:
228 # print 'DEBUG: feature tag missing for ' + str(test) 228 # print('DEBUG: feature tag missing for ' + str(test))
229 ttag = None 229 ttag = None
230 230
231 # NOTE: for some reason lstrip() doesn't work for mod.__module__ 231 # NOTE: for some reason lstrip() doesn't work for mod.__module__
@@ -320,17 +320,17 @@ def list_testsuite_by(criteria, keyword):
320 320
321 ts = sorted([ (tc.tcid, tc.tctag, tc.tcname, tc.tcclass, tc.tcmodule) for tc in get_testsuite_by(criteria, keyword) ]) 321 ts = sorted([ (tc.tcid, tc.tctag, tc.tcname, tc.tcclass, tc.tcmodule) for tc in get_testsuite_by(criteria, keyword) ])
322 322
323 print '%-4s\t%-20s\t%-60s\t%-25s\t%-20s' % ('id', 'tag', 'name', 'class', 'module') 323 print('%-4s\t%-20s\t%-60s\t%-25s\t%-20s' % ('id', 'tag', 'name', 'class', 'module'))
324 print '_' * 150 324 print('_' * 150)
325 for t in ts: 325 for t in ts:
326 if isinstance(t[1], (tuple, list)): 326 if isinstance(t[1], (tuple, list)):
327 print '%-4s\t%-20s\t%-60s\t%-25s\t%-20s' % (t[0], ', '.join(t[1]), t[2], t[3], t[4]) 327 print('%-4s\t%-20s\t%-60s\t%-25s\t%-20s' % (t[0], ', '.join(t[1]), t[2], t[3], t[4]))
328 else: 328 else:
329 print '%-4s\t%-20s\t%-60s\t%-25s\t%-20s' % t 329 print('%-4s\t%-20s\t%-60s\t%-25s\t%-20s' % t)
330 print '_' * 150 330 print('_' * 150)
331 print 'Filtering by:\t %s' % criteria 331 print('Filtering by:\t %s' % criteria)
332 print 'Looking for:\t %s' % ', '.join(str(x) for x in keyword) 332 print('Looking for:\t %s' % ', '.join(str(x) for x in keyword))
333 print 'Total found:\t %s' % len(ts) 333 print('Total found:\t %s' % len(ts))
334 334
335 335
336def list_tests(): 336def list_tests():
@@ -338,16 +338,15 @@ def list_tests():
338 338
339 ts = get_all_tests() 339 ts = get_all_tests()
340 340
341 print '%-4s\t%-10s\t%-50s' % ('id', 'tag', 'test') 341 print('%-4s\t%-10s\t%-50s' % ('id', 'tag', 'test'))
342 print '_' * 80 342 print('_' * 80)
343 for t in ts: 343 for t in ts:
344 if isinstance(t.tctag, (tuple, list)): 344 if isinstance(t.tctag, (tuple, list)):
345 print '%-4s\t%-10s\t%-50s' % (t.tcid, ', '.join(t.tctag), '.'.join([t.tcmodule, t.tcclass, t.tcname])) 345 print('%-4s\t%-10s\t%-50s' % (t.tcid, ', '.join(t.tctag), '.'.join([t.tcmodule, t.tcclass, t.tcname])))
346 else: 346 else:
347 print '%-4s\t%-10s\t%-50s' % (t.tcid, t.tctag, '.'.join([t.tcmodule, t.tcclass, t.tcname])) 347 print('%-4s\t%-10s\t%-50s' % (t.tcid, t.tctag, '.'.join([t.tcmodule, t.tcclass, t.tcname])))
348 print '_' * 80 348 print('_' * 80)
349 print 'Total found:\t %s' % len(ts) 349 print('Total found:\t %s' % len(ts))
350
351 350
352def list_tags(): 351def list_tags():
353 # Get all tags set to test cases 352 # Get all tags set to test cases
@@ -362,7 +361,7 @@ def list_tags():
362 else: 361 else:
363 tags.add(tc.tctag) 362 tags.add(tc.tctag)
364 363
365 print 'Tags:\t%s' % ', '.join(str(x) for x in tags) 364 print('Tags:\t%s' % ', '.join(str(x) for x in tags))
366 365
367def coverage_setup(coverage_source, coverage_include, coverage_omit): 366def coverage_setup(coverage_source, coverage_include, coverage_omit):
368 """ Set up the coverage measurement for the testcases to be run """ 367 """ Set up the coverage measurement for the testcases to be run """
@@ -443,12 +442,12 @@ def main():
443 bbpath = get_bb_var('BBPATH').split(':') 442 bbpath = get_bb_var('BBPATH').split(':')
444 layer_libdirs = [p for p in (os.path.join(l, 'lib') for l in bbpath) if os.path.exists(p)] 443 layer_libdirs = [p for p in (os.path.join(l, 'lib') for l in bbpath) if os.path.exists(p)]
445 sys.path.extend(layer_libdirs) 444 sys.path.extend(layer_libdirs)
446 reload(oeqa.selftest) 445 imp.reload(oeqa.selftest)
447 446
448 if args.run_tests_by and len(args.run_tests_by) >= 2: 447 if args.run_tests_by and len(args.run_tests_by) >= 2:
449 valid_options = ['name', 'class', 'module', 'id', 'tag'] 448 valid_options = ['name', 'class', 'module', 'id', 'tag']
450 if args.run_tests_by[0] not in valid_options: 449 if args.run_tests_by[0] not in valid_options:
451 print '--run-tests-by %s not a valid option. Choose one of <name|class|module|id|tag>.' % args.run_tests_by[0] 450 print('--run-tests-by %s not a valid option. Choose one of <name|class|module|id|tag>.' % args.run_tests_by[0])
452 return 1 451 return 1
453 else: 452 else:
454 criteria = args.run_tests_by[0] 453 criteria = args.run_tests_by[0]
@@ -458,7 +457,7 @@ def main():
458 if args.list_tests_by and len(args.list_tests_by) >= 2: 457 if args.list_tests_by and len(args.list_tests_by) >= 2:
459 valid_options = ['name', 'class', 'module', 'id', 'tag'] 458 valid_options = ['name', 'class', 'module', 'id', 'tag']
460 if args.list_tests_by[0] not in valid_options: 459 if args.list_tests_by[0] not in valid_options:
461 print '--list-tests-by %s not a valid option. Choose one of <name|class|module|id|tag>.' % args.list_tests_by[0] 460 print('--list-tests-by %s not a valid option. Choose one of <name|class|module|id|tag>.' % args.list_tests_by[0])
462 return 1 461 return 1
463 else: 462 else:
464 criteria = args.list_tests_by[0] 463 criteria = args.list_tests_by[0]
@@ -482,7 +481,7 @@ def main():
482 info = '' 481 info = ''
483 if module.startswith('_'): 482 if module.startswith('_'):
484 info = ' (hidden)' 483 info = ' (hidden)'
485 print module + info 484 print(module + info)
486 if args.list_allclasses: 485 if args.list_allclasses:
487 try: 486 try:
488 import importlib 487 import importlib
@@ -490,13 +489,13 @@ def main():
490 for v in vars(modlib): 489 for v in vars(modlib):
491 t = vars(modlib)[v] 490 t = vars(modlib)[v]
492 if isinstance(t, type(oeSelfTest)) and issubclass(t, oeSelfTest) and t!=oeSelfTest: 491 if isinstance(t, type(oeSelfTest)) and issubclass(t, oeSelfTest) and t!=oeSelfTest:
493 print " --", v 492 print(" --", v)
494 for method in dir(t): 493 for method in dir(t):
495 if method.startswith("test_") and callable(vars(t)[method]): 494 if method.startswith("test_") and callable(vars(t)[method]):
496 print " -- --", method 495 print(" -- --", method)
497 496
498 except (AttributeError, ImportError) as e: 497 except (AttributeError, ImportError) as e:
499 print e 498 print(e)
500 pass 499 pass
501 500
502 if args.run_tests or args.run_all_tests or args.run_tests_by: 501 if args.run_tests or args.run_all_tests or args.run_tests_by: