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>
This commit is contained in:
parent
02986886fc
commit
ffe9604be2
|
@ -2,7 +2,7 @@ import argparse
|
||||||
|
|
||||||
def selftest_reverse(args, config, basepath, workspace):
|
def selftest_reverse(args, config, basepath, workspace):
|
||||||
"""Reverse the value passed to verify the plugin is executing."""
|
"""Reverse the value passed to verify the plugin is executing."""
|
||||||
print args.value[::-1]
|
print(args.value[::-1])
|
||||||
|
|
||||||
def register_commands(subparsers, context):
|
def register_commands(subparsers, context):
|
||||||
parser_build = subparsers.add_parser('selftest-reverse', help='Reverse value (for selftest)',
|
parser_build = subparsers.add_parser('selftest-reverse', help='Reverse value (for selftest)',
|
||||||
|
|
|
@ -148,4 +148,4 @@ if __name__ == "__main__":
|
||||||
import sys
|
import sys
|
||||||
elf = ELFFile(sys.argv[1])
|
elf = ELFFile(sys.argv[1])
|
||||||
elf.open()
|
elf.open()
|
||||||
print elf.isDynamic()
|
print(elf.isDynamic())
|
||||||
|
|
|
@ -265,7 +265,7 @@ class ThreadedWorker(Thread):
|
||||||
try:
|
try:
|
||||||
func(self, *args, **kargs)
|
func(self, *args, **kargs)
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
print e
|
print(e)
|
||||||
finally:
|
finally:
|
||||||
self.tasks.task_done()
|
self.tasks.task_done()
|
||||||
|
|
||||||
|
|
|
@ -3,4 +3,4 @@ import os
|
||||||
os.system('touch /tmp/testfile.python')
|
os.system('touch /tmp/testfile.python')
|
||||||
|
|
||||||
a = 9.01e+21 - 9.01e+21 + 0.01
|
a = 9.01e+21 - 9.01e+21 + 0.01
|
||||||
print "the value of a is %s" % a
|
print("the value of a is %s" % a)
|
||||||
|
|
|
@ -153,7 +153,7 @@ class SystemdJournalTests(SystemdTest):
|
||||||
if check_match: break
|
if check_match: break
|
||||||
# put the startup time in the test log
|
# put the startup time in the test log
|
||||||
if check_match:
|
if check_match:
|
||||||
print "%s" % check_match
|
print("%s" % check_match)
|
||||||
else:
|
else:
|
||||||
self.skipTest("Error at obtaining the boot time from journalctl")
|
self.skipTest("Error at obtaining the boot time from journalctl")
|
||||||
boot_time_sec = 0
|
boot_time_sec = 0
|
||||||
|
@ -174,5 +174,5 @@ class SystemdJournalTests(SystemdTest):
|
||||||
self.skipTest("Error when parsing time from boot string")
|
self.skipTest("Error when parsing time from boot string")
|
||||||
#Assert the target boot time against systemd's unit start timeout
|
#Assert the target boot time against systemd's unit start timeout
|
||||||
if boot_time_sec > systemd_TimeoutStartSec:
|
if boot_time_sec > systemd_TimeoutStartSec:
|
||||||
print "Target boot time %s exceeds systemd's TimeoutStartSec %s"\
|
print("Target boot time %s exceeds systemd's TimeoutStartSec %s"\
|
||||||
%(boot_time_sec, systemd_TimeoutStartSec)
|
%(boot_time_sec, systemd_TimeoutStartSec))
|
||||||
|
|
|
@ -67,7 +67,7 @@ class oeSelfTest(unittest.TestCase):
|
||||||
machine = custommachine
|
machine = custommachine
|
||||||
machine_conf = 'MACHINE ??= "%s"\n' % machine
|
machine_conf = 'MACHINE ??= "%s"\n' % machine
|
||||||
self.set_machine_config(machine_conf)
|
self.set_machine_config(machine_conf)
|
||||||
print 'MACHINE: %s' % machine
|
print('MACHINE: %s' % machine)
|
||||||
|
|
||||||
# tests might need their own setup
|
# tests might need their own setup
|
||||||
# but if they overwrite this one they have to call
|
# but if they overwrite this one they have to call
|
||||||
|
|
|
@ -220,12 +220,12 @@ def get_tests_from_module(tmod):
|
||||||
try:
|
try:
|
||||||
tid = vars(mod)[test].test_case
|
tid = vars(mod)[test].test_case
|
||||||
except:
|
except:
|
||||||
print 'DEBUG: tc id missing for ' + str(test)
|
print('DEBUG: tc id missing for ' + str(test))
|
||||||
tid = None
|
tid = None
|
||||||
try:
|
try:
|
||||||
ttag = vars(mod)[test].tag__feature
|
ttag = vars(mod)[test].tag__feature
|
||||||
except:
|
except:
|
||||||
# print 'DEBUG: feature tag missing for ' + str(test)
|
# print('DEBUG: feature tag missing for ' + str(test))
|
||||||
ttag = None
|
ttag = None
|
||||||
|
|
||||||
# NOTE: for some reason lstrip() doesn't work for mod.__module__
|
# NOTE: for some reason lstrip() doesn't work for mod.__module__
|
||||||
|
@ -320,17 +320,17 @@ def list_testsuite_by(criteria, keyword):
|
||||||
|
|
||||||
ts = sorted([ (tc.tcid, tc.tctag, tc.tcname, tc.tcclass, tc.tcmodule) for tc in get_testsuite_by(criteria, keyword) ])
|
ts = sorted([ (tc.tcid, tc.tctag, tc.tcname, tc.tcclass, tc.tcmodule) for tc in get_testsuite_by(criteria, keyword) ])
|
||||||
|
|
||||||
print '%-4s\t%-20s\t%-60s\t%-25s\t%-20s' % ('id', 'tag', 'name', 'class', 'module')
|
print('%-4s\t%-20s\t%-60s\t%-25s\t%-20s' % ('id', 'tag', 'name', 'class', 'module'))
|
||||||
print '_' * 150
|
print('_' * 150)
|
||||||
for t in ts:
|
for t in ts:
|
||||||
if isinstance(t[1], (tuple, list)):
|
if isinstance(t[1], (tuple, list)):
|
||||||
print '%-4s\t%-20s\t%-60s\t%-25s\t%-20s' % (t[0], ', '.join(t[1]), t[2], t[3], t[4])
|
print('%-4s\t%-20s\t%-60s\t%-25s\t%-20s' % (t[0], ', '.join(t[1]), t[2], t[3], t[4]))
|
||||||
else:
|
else:
|
||||||
print '%-4s\t%-20s\t%-60s\t%-25s\t%-20s' % t
|
print('%-4s\t%-20s\t%-60s\t%-25s\t%-20s' % t)
|
||||||
print '_' * 150
|
print('_' * 150)
|
||||||
print 'Filtering by:\t %s' % criteria
|
print('Filtering by:\t %s' % criteria)
|
||||||
print 'Looking for:\t %s' % ', '.join(str(x) for x in keyword)
|
print('Looking for:\t %s' % ', '.join(str(x) for x in keyword))
|
||||||
print 'Total found:\t %s' % len(ts)
|
print('Total found:\t %s' % len(ts))
|
||||||
|
|
||||||
|
|
||||||
def list_tests():
|
def list_tests():
|
||||||
|
@ -338,16 +338,15 @@ def list_tests():
|
||||||
|
|
||||||
ts = get_all_tests()
|
ts = get_all_tests()
|
||||||
|
|
||||||
print '%-4s\t%-10s\t%-50s' % ('id', 'tag', 'test')
|
print('%-4s\t%-10s\t%-50s' % ('id', 'tag', 'test'))
|
||||||
print '_' * 80
|
print('_' * 80)
|
||||||
for t in ts:
|
for t in ts:
|
||||||
if isinstance(t.tctag, (tuple, list)):
|
if isinstance(t.tctag, (tuple, list)):
|
||||||
print '%-4s\t%-10s\t%-50s' % (t.tcid, ', '.join(t.tctag), '.'.join([t.tcmodule, t.tcclass, t.tcname]))
|
print('%-4s\t%-10s\t%-50s' % (t.tcid, ', '.join(t.tctag), '.'.join([t.tcmodule, t.tcclass, t.tcname])))
|
||||||
else:
|
else:
|
||||||
print '%-4s\t%-10s\t%-50s' % (t.tcid, t.tctag, '.'.join([t.tcmodule, t.tcclass, t.tcname]))
|
print('%-4s\t%-10s\t%-50s' % (t.tcid, t.tctag, '.'.join([t.tcmodule, t.tcclass, t.tcname])))
|
||||||
print '_' * 80
|
print('_' * 80)
|
||||||
print 'Total found:\t %s' % len(ts)
|
print('Total found:\t %s' % len(ts))
|
||||||
|
|
||||||
|
|
||||||
def list_tags():
|
def list_tags():
|
||||||
# Get all tags set to test cases
|
# Get all tags set to test cases
|
||||||
|
@ -362,7 +361,7 @@ def list_tags():
|
||||||
else:
|
else:
|
||||||
tags.add(tc.tctag)
|
tags.add(tc.tctag)
|
||||||
|
|
||||||
print 'Tags:\t%s' % ', '.join(str(x) for x in tags)
|
print('Tags:\t%s' % ', '.join(str(x) for x in tags))
|
||||||
|
|
||||||
def coverage_setup(coverage_source, coverage_include, coverage_omit):
|
def coverage_setup(coverage_source, coverage_include, coverage_omit):
|
||||||
""" Set up the coverage measurement for the testcases to be run """
|
""" Set up the coverage measurement for the testcases to be run """
|
||||||
|
@ -443,12 +442,12 @@ def main():
|
||||||
bbpath = get_bb_var('BBPATH').split(':')
|
bbpath = get_bb_var('BBPATH').split(':')
|
||||||
layer_libdirs = [p for p in (os.path.join(l, 'lib') for l in bbpath) if os.path.exists(p)]
|
layer_libdirs = [p for p in (os.path.join(l, 'lib') for l in bbpath) if os.path.exists(p)]
|
||||||
sys.path.extend(layer_libdirs)
|
sys.path.extend(layer_libdirs)
|
||||||
reload(oeqa.selftest)
|
imp.reload(oeqa.selftest)
|
||||||
|
|
||||||
if args.run_tests_by and len(args.run_tests_by) >= 2:
|
if args.run_tests_by and len(args.run_tests_by) >= 2:
|
||||||
valid_options = ['name', 'class', 'module', 'id', 'tag']
|
valid_options = ['name', 'class', 'module', 'id', 'tag']
|
||||||
if args.run_tests_by[0] not in valid_options:
|
if args.run_tests_by[0] not in valid_options:
|
||||||
print '--run-tests-by %s not a valid option. Choose one of <name|class|module|id|tag>.' % args.run_tests_by[0]
|
print('--run-tests-by %s not a valid option. Choose one of <name|class|module|id|tag>.' % args.run_tests_by[0])
|
||||||
return 1
|
return 1
|
||||||
else:
|
else:
|
||||||
criteria = args.run_tests_by[0]
|
criteria = args.run_tests_by[0]
|
||||||
|
@ -458,7 +457,7 @@ def main():
|
||||||
if args.list_tests_by and len(args.list_tests_by) >= 2:
|
if args.list_tests_by and len(args.list_tests_by) >= 2:
|
||||||
valid_options = ['name', 'class', 'module', 'id', 'tag']
|
valid_options = ['name', 'class', 'module', 'id', 'tag']
|
||||||
if args.list_tests_by[0] not in valid_options:
|
if args.list_tests_by[0] not in valid_options:
|
||||||
print '--list-tests-by %s not a valid option. Choose one of <name|class|module|id|tag>.' % args.list_tests_by[0]
|
print('--list-tests-by %s not a valid option. Choose one of <name|class|module|id|tag>.' % args.list_tests_by[0])
|
||||||
return 1
|
return 1
|
||||||
else:
|
else:
|
||||||
criteria = args.list_tests_by[0]
|
criteria = args.list_tests_by[0]
|
||||||
|
@ -482,7 +481,7 @@ def main():
|
||||||
info = ''
|
info = ''
|
||||||
if module.startswith('_'):
|
if module.startswith('_'):
|
||||||
info = ' (hidden)'
|
info = ' (hidden)'
|
||||||
print module + info
|
print(module + info)
|
||||||
if args.list_allclasses:
|
if args.list_allclasses:
|
||||||
try:
|
try:
|
||||||
import importlib
|
import importlib
|
||||||
|
@ -490,13 +489,13 @@ def main():
|
||||||
for v in vars(modlib):
|
for v in vars(modlib):
|
||||||
t = vars(modlib)[v]
|
t = vars(modlib)[v]
|
||||||
if isinstance(t, type(oeSelfTest)) and issubclass(t, oeSelfTest) and t!=oeSelfTest:
|
if isinstance(t, type(oeSelfTest)) and issubclass(t, oeSelfTest) and t!=oeSelfTest:
|
||||||
print " --", v
|
print(" --", v)
|
||||||
for method in dir(t):
|
for method in dir(t):
|
||||||
if method.startswith("test_") and callable(vars(t)[method]):
|
if method.startswith("test_") and callable(vars(t)[method]):
|
||||||
print " -- --", method
|
print(" -- --", method)
|
||||||
|
|
||||||
except (AttributeError, ImportError) as e:
|
except (AttributeError, ImportError) as e:
|
||||||
print e
|
print(e)
|
||||||
pass
|
pass
|
||||||
|
|
||||||
if args.run_tests or args.run_all_tests or args.run_tests_by:
|
if args.run_tests or args.run_all_tests or args.run_tests_by:
|
||||||
|
|
Loading…
Reference in New Issue