summaryrefslogtreecommitdiffstats
path: root/bitbake
diff options
context:
space:
mode:
authorAlexandru DAMIAN <alexandru.damian@intel.com>2015-07-30 19:25:18 +0300
committerRichard Purdie <richard.purdie@linuxfoundation.org>2015-08-01 11:27:55 +0100
commit1da5e0a793adee9248ecce927952ba8c00bdcb0e (patch)
treef4cfb5f9e7db9c346b94b8eb1ef2aabae7e67864 /bitbake
parente6419ccd93e87e730c0a6dba7a15e0ba2b986fff (diff)
downloadpoky-1da5e0a793adee9248ecce927952ba8c00bdcb0e.tar.gz
bitbake: toaster: tts: execute tests in numeric order
As the tests are verifying different type of the functionality, it is usually the case that a failing early test will completely make the subsequent tests failing, e.g. if the system cannot start due to a bug, there is little point in testing other functions. In order to prevent uneeded test runs, and to generate repeatable test patterns, the test cases have now a numeric order in the class name (e.g. Test01XXX). The tests are executed in this order, and the first test failing will stop the test run. (Bitbake rev: 639c46a08e524902018e28367fcb4e26362cd3e3) Signed-off-by: Alexandru DAMIAN <alexandru.damian@intel.com> Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake')
-rwxr-xr-xbitbake/lib/toaster/contrib/tts/runner.py11
-rw-r--r--bitbake/lib/toaster/contrib/tts/tests.py6
2 files changed, 10 insertions, 7 deletions
diff --git a/bitbake/lib/toaster/contrib/tts/runner.py b/bitbake/lib/toaster/contrib/tts/runner.py
index 6fc3e77523..bed665196e 100755
--- a/bitbake/lib/toaster/contrib/tts/runner.py
+++ b/bitbake/lib/toaster/contrib/tts/runner.py
@@ -31,7 +31,7 @@ from __future__ import print_function
31import sys, os 31import sys, os
32import unittest, importlib 32import unittest, importlib
33import logging, pprint, json 33import logging, pprint, json
34 34import re
35from shellutils import ShellCmdException, mkdirhier, run_shell_cmd 35from shellutils import ShellCmdException, mkdirhier, run_shell_cmd
36 36
37import config 37import config
@@ -121,13 +121,16 @@ def execute_tests(dir_under_test, testname):
121 # pylint: disable=broad-except 121 # pylint: disable=broad-except
122 # we disable the broad-except because we want to actually catch all possible exceptions 122 # we disable the broad-except because we want to actually catch all possible exceptions
123 try: 123 try:
124 # sorting the tests by the numeric order in the class name
125 tests = sorted(tests, key=lambda x: int(re.search(r"[0-9]+", x[1]).group(0)))
124 config.logger.debug("Discovered test clases: %s", pprint.pformat(tests)) 126 config.logger.debug("Discovered test clases: %s", pprint.pformat(tests))
125 unittest.installHandler() 127 unittest.installHandler()
126 suite = unittest.TestSuite() 128 suite = unittest.TestSuite()
127 loader = unittest.TestLoader() 129 loader = unittest.TestLoader()
128 result = unittest.TestResult() 130 result = unittest.TestResult()
129 for module_file, name in tests: 131 result.failfast = True
130 suite.addTest(loader.loadTestsFromName("%s.%s" % (module_file, name))) 132 for module_file, test_name in tests:
133 suite.addTest(loader.loadTestsFromName("%s.%s" % (module_file, test_name)))
131 config.logger.info("Running %d test(s)", suite.countTestCases()) 134 config.logger.info("Running %d test(s)", suite.countTestCases())
132 suite.run(result) 135 suite.run(result)
133 136
@@ -202,7 +205,7 @@ def main():
202 config.TESTDIR = testdir # we let tests know where to run 205 config.TESTDIR = testdir # we let tests know where to run
203 206
204 # ensure that the test dir only contains no *.pyc leftovers 207 # ensure that the test dir only contains no *.pyc leftovers
205 run_shell_cmd("find '%s' -type f -name *.pyc -exec rm {} \;" % testdir) 208 run_shell_cmd("find '%s' -type f -name *.pyc -exec rm {} \\;" % testdir)
206 209
207 no_failures = execute_tests(testdir, options.singletest) 210 no_failures = execute_tests(testdir, options.singletest)
208 211
diff --git a/bitbake/lib/toaster/contrib/tts/tests.py b/bitbake/lib/toaster/contrib/tts/tests.py
index 9acef46a38..3a4eed1e9f 100644
--- a/bitbake/lib/toaster/contrib/tts/tests.py
+++ b/bitbake/lib/toaster/contrib/tts/tests.py
@@ -30,7 +30,7 @@ import config
30import pexpect 30import pexpect
31import sys, os, signal, time 31import sys, os, signal, time
32 32
33class TestPyCompilable(unittest.TestCase): 33class Test00PyCompilable(unittest.TestCase):
34 ''' Verifies that all Python files are syntactically correct ''' 34 ''' Verifies that all Python files are syntactically correct '''
35 def test_compile_file(self): 35 def test_compile_file(self):
36 try: 36 try:
@@ -38,7 +38,7 @@ class TestPyCompilable(unittest.TestCase):
38 except ShellCmdException as exc: 38 except ShellCmdException as exc:
39 self.fail("Error compiling python files: %s" % (exc)) 39 self.fail("Error compiling python files: %s" % (exc))
40 40
41class TestPySystemStart(unittest.TestCase): 41class Test01PySystemStart(unittest.TestCase):
42 ''' Attempts to start Toaster, verify that it is succesfull, and stop it ''' 42 ''' Attempts to start Toaster, verify that it is succesfull, and stop it '''
43 def setUp(self): 43 def setUp(self):
44 run_shell_cmd("bash -c 'rm -f build/*log'") 44 run_shell_cmd("bash -c 'rm -f build/*log'")
@@ -55,7 +55,7 @@ class TestPySystemStart(unittest.TestCase):
55 except ShellCmdException as exc: 55 except ShellCmdException as exc:
56 self.fail("Failed starting managed mode: %s" % (exc)) 56 self.fail("Failed starting managed mode: %s" % (exc))
57 57
58class TestHTML5Compliance(unittest.TestCase): 58class Test02HTML5Compliance(unittest.TestCase):
59 def setUp(self): 59 def setUp(self):
60 self.origdir = os.getcwd() 60 self.origdir = os.getcwd()
61 self.crtdir = os.path.dirname(config.TESTDIR) 61 self.crtdir = os.path.dirname(config.TESTDIR)