summaryrefslogtreecommitdiffstats
path: root/scripts/oe-selftest
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/oe-selftest')
-rwxr-xr-xscripts/oe-selftest32
1 files changed, 25 insertions, 7 deletions
diff --git a/scripts/oe-selftest b/scripts/oe-selftest
index 4eb404b087..f3865e4e81 100755
--- a/scripts/oe-selftest
+++ b/scripts/oe-selftest
@@ -78,6 +78,9 @@ def get_args_parser():
78 group.add_argument('--list-modules', required=False, action="store_true", dest="list_modules", default=False, help='List all available test modules.') 78 group.add_argument('--list-modules', required=False, action="store_true", dest="list_modules", default=False, help='List all available test modules.')
79 group.add_argument('--list-classes', required=False, action="store_true", dest="list_allclasses", default=False, help='List all available test classes.') 79 group.add_argument('--list-classes', required=False, action="store_true", dest="list_allclasses", default=False, help='List all available test classes.')
80 parser.add_argument('--coverage', action="store_true", help="Run code coverage when testing") 80 parser.add_argument('--coverage', action="store_true", help="Run code coverage when testing")
81 parser.add_argument('--coverage-source', dest="coverage_source", nargs="+", help="Specifiy the directories to take coverage from")
82 parser.add_argument('--coverage-include', dest="coverage_include", nargs="+", help="Specify extra patterns to include into the coverage measurement")
83 parser.add_argument('--coverage-omit', dest="coverage_omit", nargs="+", help="Specify with extra patterns to exclude from the coverage measurement")
81 group.add_argument('--run-tests-by', required=False, dest='run_tests_by', default=False, nargs='*', 84 group.add_argument('--run-tests-by', required=False, dest='run_tests_by', default=False, nargs='*',
82 help='run-tests-by <name|class|module|id|tag> <list of tests|classes|modules|ids|tags>') 85 help='run-tests-by <name|class|module|id|tag> <list of tests|classes|modules|ids|tags>')
83 group.add_argument('--list-tests-by', required=False, dest='list_tests_by', default=False, nargs='*', 86 group.add_argument('--list-tests-by', required=False, dest='list_tests_by', default=False, nargs='*',
@@ -369,7 +372,7 @@ def list_tags():
369 372
370 print 'Tags:\t%s' % ', '.join(str(x) for x in tags) 373 print 'Tags:\t%s' % ', '.join(str(x) for x in tags)
371 374
372def coverage_setup(run_tests, run_all_tests): 375def coverage_setup(run_tests, run_all_tests, coverage_source, coverage_include, coverage_omit):
373 """ Set up the coverage measurement for the testcases to be run """ 376 """ Set up the coverage measurement for the testcases to be run """
374 builddir = os.environ.get("BUILDDIR") 377 builddir = os.environ.get("BUILDDIR")
375 coveragerc = "%s/.coveragerc" % builddir 378 coveragerc = "%s/.coveragerc" % builddir
@@ -384,10 +387,25 @@ def coverage_setup(run_tests, run_all_tests):
384 cps.write("branch = True\n") 387 cps.write("branch = True\n")
385 # Measure just BBLAYERS, scripts and bitbake folders 388 # Measure just BBLAYERS, scripts and bitbake folders
386 cps.write("source = \n") 389 cps.write("source = \n")
387 for layer in get_bb_var('BBLAYERS').split(): 390 if coverage_source:
388 cps.write(" %s\n" % layer) 391 for directory in coverage_source:
389 cps.write(" %s\n" % os.path.dirname(os.path.realpath(__file__))) 392 if not os.path.isdir(directory):
390 cps.write(" %s\n" % os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(__file__))),'bitbake')) 393 log.warn("Directory %s is not valid.", directory)
394 cps.write(" %s\n" % directory)
395 else:
396 for layer in get_bb_var('BBLAYERS').split():
397 cps.write(" %s\n" % layer)
398 cps.write(" %s\n" % os.path.dirname(os.path.realpath(__file__)))
399 cps.write(" %s\n" % os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(__file__))),'bitbake'))
400
401 if coverage_include:
402 cps.write("include = \n")
403 for pattern in coverage_include:
404 cps.write(" %s\n" % pattern)
405 if coverage_omit:
406 cps.write("omit = \n")
407 for pattern in coverage_omit:
408 cps.write(" %s\n" % pattern)
391 409
392 return coveragerc 410 return coveragerc
393 411
@@ -550,7 +568,7 @@ def buildResultClass(args):
550 568
551 def startTestRun(self): 569 def startTestRun(self):
552 """ Setup coverage before running any testcase """ 570 """ Setup coverage before running any testcase """
553 if args.coverage: 571 if args.coverage or args.coverage_source or args.coverage_include or args.coverage_omit:
554 try: 572 try:
555 # check if user can do coverage 573 # check if user can do coverage
556 import coverage 574 import coverage
@@ -561,7 +579,7 @@ def buildResultClass(args):
561 # value indicates where the coverage configuration file resides 579 # value indicates where the coverage configuration file resides
562 # More info on https://pypi.python.org/pypi/coverage 580 # More info on https://pypi.python.org/pypi/coverage
563 if not os.environ.get('COVERAGE_PROCESS_START'): 581 if not os.environ.get('COVERAGE_PROCESS_START'):
564 os.environ['COVERAGE_PROCESS_START'] = coverage_setup(args.run_tests, args.run_all_tests) 582 os.environ['COVERAGE_PROCESS_START'] = coverage_setup(args.run_tests, args.run_all_tests, args.coverage_source, args.coverage_include, args.coverage_omit)
565 583
566 self.coverage_installed = True 584 self.coverage_installed = True
567 except: 585 except: