summaryrefslogtreecommitdiffstats
path: root/scripts/oe-selftest
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/oe-selftest')
-rwxr-xr-xscripts/oe-selftest37
1 files changed, 28 insertions, 9 deletions
diff --git a/scripts/oe-selftest b/scripts/oe-selftest
index e77768b292..4eb404b087 100755
--- a/scripts/oe-selftest
+++ b/scripts/oe-selftest
@@ -42,7 +42,7 @@ import argparse_oe
42import oeqa.selftest 42import oeqa.selftest
43import oeqa.utils.ftools as ftools 43import oeqa.utils.ftools as ftools
44from oeqa.utils.commands import runCmd, get_bb_var, get_test_layer 44from oeqa.utils.commands import runCmd, get_bb_var, get_test_layer
45from oeqa.selftest.base import oeSelfTest 45from oeqa.selftest.base import oeSelfTest, get_available_machines
46 46
47def logger_create(): 47def logger_create():
48 log_file = "oe-selftest-" + t.strftime("%Y-%m-%d_%H:%M:%S") + ".log" 48 log_file = "oe-selftest-" + t.strftime("%Y-%m-%d_%H:%M:%S") + ".log"
@@ -86,6 +86,8 @@ def get_args_parser():
86 help='List all available tests.') 86 help='List all available tests.')
87 group.add_argument('--list-tags', required=False, dest='list_tags', default=False, action="store_true", 87 group.add_argument('--list-tags', required=False, dest='list_tags', default=False, action="store_true",
88 help='List all tags that have been set to test cases.') 88 help='List all tags that have been set to test cases.')
89 parser.add_argument('--machine', required=False, dest='machine', choices=['random', 'all'], default=None,
90 help='Run tests on different machines (random/all).')
89 return parser 91 return parser
90 92
91 93
@@ -117,7 +119,7 @@ def add_include():
117 not in ftools.read_file(os.path.join(builddir, "conf/local.conf")): 119 not in ftools.read_file(os.path.join(builddir, "conf/local.conf")):
118 log.info("Adding: \"include selftest.inc\" in local.conf") 120 log.info("Adding: \"include selftest.inc\" in local.conf")
119 ftools.append_file(os.path.join(builddir, "conf/local.conf"), \ 121 ftools.append_file(os.path.join(builddir, "conf/local.conf"), \
120 "\n#include added by oe-selftest.py\ninclude selftest.inc") 122 "\n#include added by oe-selftest.py\ninclude machine.inc\ninclude selftest.inc")
121 123
122 if "#include added by oe-selftest.py" \ 124 if "#include added by oe-selftest.py" \
123 not in ftools.read_file(os.path.join(builddir, "conf/bblayers.conf")): 125 not in ftools.read_file(os.path.join(builddir, "conf/bblayers.conf")):
@@ -133,13 +135,13 @@ def remove_include():
133 in ftools.read_file(os.path.join(builddir, "conf/local.conf")): 135 in ftools.read_file(os.path.join(builddir, "conf/local.conf")):
134 log.info("Removing the include from local.conf") 136 log.info("Removing the include from local.conf")
135 ftools.remove_from_file(os.path.join(builddir, "conf/local.conf"), \ 137 ftools.remove_from_file(os.path.join(builddir, "conf/local.conf"), \
136 "#include added by oe-selftest.py\ninclude selftest.inc") 138 "\n#include added by oe-selftest.py\ninclude machine.inc\ninclude selftest.inc")
137 139
138 if "#include added by oe-selftest.py" \ 140 if "#include added by oe-selftest.py" \
139 in ftools.read_file(os.path.join(builddir, "conf/bblayers.conf")): 141 in ftools.read_file(os.path.join(builddir, "conf/bblayers.conf")):
140 log.info("Removing the include from bblayers.conf") 142 log.info("Removing the include from bblayers.conf")
141 ftools.remove_from_file(os.path.join(builddir, "conf/bblayers.conf"), \ 143 ftools.remove_from_file(os.path.join(builddir, "conf/bblayers.conf"), \
142 "#include added by oe-selftest.py\ninclude bblayers.inc") 144 "\n#include added by oe-selftest.py\ninclude bblayers.inc")
143 145
144def remove_inc_files(): 146def remove_inc_files():
145 try: 147 try:
@@ -151,10 +153,11 @@ def remove_inc_files():
151 except (AttributeError, OSError,) as e: # AttributeError may happen if BUILDDIR is not set 153 except (AttributeError, OSError,) as e: # AttributeError may happen if BUILDDIR is not set
152 pass 154 pass
153 155
154 try: 156 for incl_file in ['conf/bblayers.inc', 'conf/machine.inc']:
155 os.remove(os.path.join(os.environ.get("BUILDDIR"), "conf/bblayers.inc")) 157 try:
156 except: 158 os.remove(os.path.join(os.environ.get("BUILDDIR"), incl_file))
157 pass 159 except:
160 pass
158 161
159def get_tests(exclusive_modules=[], include_hidden=False): 162def get_tests(exclusive_modules=[], include_hidden=False):
160 testslist = [] 163 testslist = []
@@ -506,7 +509,23 @@ def main():
506 log.error(e) 509 log.error(e)
507 return 1 510 return 1
508 add_include() 511 add_include()
509 result = runner.run(suite) 512
513 if args.machine:
514 # Custom machine sets only weak default values (??=) for MACHINE in machine.inc
515 # This let test cases that require a specific MACHINE to be able to override it, using (?= or =)
516 log.info('Custom machine mode enabled. MACHINE set to %s' % args.machine)
517 if args.machine == 'random':
518 os.environ['CUSTOMMACHINE'] = 'random'
519 result = runner.run(suite)
520 else: # all
521 machines = get_available_machines()
522 for m in machines:
523 log.info('Run tests with custom MACHINE set to: %s' % m)
524 os.environ['CUSTOMMACHINE'] = m
525 result = runner.run(suite)
526 else:
527 result = runner.run(suite)
528
510 log.info("Finished") 529 log.info("Finished")
511 530
512 if result.wasSuccessful(): 531 if result.wasSuccessful():