diff options
Diffstat (limited to 'meta/lib/oeqa/utils')
| -rw-r--r-- | meta/lib/oeqa/utils/commands.py | 10 | ||||
| -rw-r--r-- | meta/lib/oeqa/utils/decorators.py | 84 |
2 files changed, 47 insertions, 47 deletions
diff --git a/meta/lib/oeqa/utils/commands.py b/meta/lib/oeqa/utils/commands.py index d29c1b1a68..5b601d9806 100644 --- a/meta/lib/oeqa/utils/commands.py +++ b/meta/lib/oeqa/utils/commands.py | |||
| @@ -110,11 +110,11 @@ def runCmd(command, ignore_status=False, timeout=None, assert_error=True, **opti | |||
| 110 | def bitbake(command, ignore_status=False, timeout=None, postconfig=None, **options): | 110 | def bitbake(command, ignore_status=False, timeout=None, postconfig=None, **options): |
| 111 | 111 | ||
| 112 | if postconfig: | 112 | if postconfig: |
| 113 | postconfig_file = os.path.join(os.environ.get('BUILDDIR'), 'oeqa-post.conf') | 113 | postconfig_file = os.path.join(os.environ.get('BUILDDIR'), 'oeqa-post.conf') |
| 114 | ftools.write_file(postconfig_file, postconfig) | 114 | ftools.write_file(postconfig_file, postconfig) |
| 115 | extra_args = "-R %s" % postconfig_file | 115 | extra_args = "-R %s" % postconfig_file |
| 116 | else: | 116 | else: |
| 117 | extra_args = "" | 117 | extra_args = "" |
| 118 | 118 | ||
| 119 | if isinstance(command, basestring): | 119 | if isinstance(command, basestring): |
| 120 | cmd = "bitbake " + extra_args + " " + command | 120 | cmd = "bitbake " + extra_args + " " + command |
| @@ -122,7 +122,7 @@ def bitbake(command, ignore_status=False, timeout=None, postconfig=None, **optio | |||
| 122 | cmd = [ "bitbake" ] + [a for a in (command + extra_args.split(" ")) if a not in [""]] | 122 | cmd = [ "bitbake" ] + [a for a in (command + extra_args.split(" ")) if a not in [""]] |
| 123 | 123 | ||
| 124 | try: | 124 | try: |
| 125 | return runCmd(cmd, ignore_status, timeout, **options) | 125 | return runCmd(cmd, ignore_status, timeout, **options) |
| 126 | finally: | 126 | finally: |
| 127 | if postconfig: | 127 | if postconfig: |
| 128 | os.remove(postconfig_file) | 128 | os.remove(postconfig_file) |
diff --git a/meta/lib/oeqa/utils/decorators.py b/meta/lib/oeqa/utils/decorators.py index 7f845dbb4b..1ae1162e33 100644 --- a/meta/lib/oeqa/utils/decorators.py +++ b/meta/lib/oeqa/utils/decorators.py | |||
| @@ -86,14 +86,14 @@ class testcase(object): | |||
| 86 | self.test_case = test_case | 86 | self.test_case = test_case |
| 87 | 87 | ||
| 88 | def __call__(self, func): | 88 | def __call__(self, func): |
| 89 | def wrapped_f(*args): | 89 | def wrapped_f(*args): |
| 90 | return func(*args) | 90 | return func(*args) |
| 91 | wrapped_f.test_case = self.test_case | 91 | wrapped_f.test_case = self.test_case |
| 92 | return wrapped_f | 92 | return wrapped_f |
| 93 | 93 | ||
| 94 | class NoParsingFilter(logging.Filter): | 94 | class NoParsingFilter(logging.Filter): |
| 95 | def filter(self, record): | 95 | def filter(self, record): |
| 96 | return record.levelno == 100 | 96 | return record.levelno == 100 |
| 97 | 97 | ||
| 98 | def LogResults(original_class): | 98 | def LogResults(original_class): |
| 99 | orig_method = original_class.run | 99 | orig_method = original_class.run |
| @@ -101,51 +101,51 @@ def LogResults(original_class): | |||
| 101 | #rewrite the run method of unittest.TestCase to add testcase logging | 101 | #rewrite the run method of unittest.TestCase to add testcase logging |
| 102 | def run(self, result, *args, **kws): | 102 | def run(self, result, *args, **kws): |
| 103 | orig_method(self, result, *args, **kws) | 103 | orig_method(self, result, *args, **kws) |
| 104 | passed = True | 104 | passed = True |
| 105 | testMethod = getattr(self, self._testMethodName) | 105 | testMethod = getattr(self, self._testMethodName) |
| 106 | 106 | ||
| 107 | #if test case is decorated then use it's number, else use it's name | 107 | #if test case is decorated then use it's number, else use it's name |
| 108 | try: | 108 | try: |
| 109 | test_case = testMethod.test_case | 109 | test_case = testMethod.test_case |
| 110 | except AttributeError: | 110 | except AttributeError: |
| 111 | test_case = self._testMethodName | 111 | test_case = self._testMethodName |
| 112 | 112 | ||
| 113 | #create custom logging level for filtering. | 113 | #create custom logging level for filtering. |
| 114 | custom_log_level = 100 | 114 | custom_log_level = 100 |
| 115 | logging.addLevelName(custom_log_level, 'RESULTS') | 115 | logging.addLevelName(custom_log_level, 'RESULTS') |
| 116 | caller = os.path.basename(sys.argv[0]) | 116 | caller = os.path.basename(sys.argv[0]) |
| 117 | 117 | ||
| 118 | def results(self, message, *args, **kws): | 118 | def results(self, message, *args, **kws): |
| 119 | if self.isEnabledFor(custom_log_level): | 119 | if self.isEnabledFor(custom_log_level): |
| 120 | self.log(custom_log_level, message, *args, **kws) | 120 | self.log(custom_log_level, message, *args, **kws) |
| 121 | logging.Logger.results = results | 121 | logging.Logger.results = results |
| 122 | 122 | ||
| 123 | logging.basicConfig(filename=os.path.join(os.getcwd(),'results-'+caller+'.log'), | 123 | logging.basicConfig(filename=os.path.join(os.getcwd(),'results-'+caller+'.log'), |
| 124 | filemode='w', | 124 | filemode='w', |
| 125 | format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', | 125 | format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', |
| 126 | datefmt='%H:%M:%S', | 126 | datefmt='%H:%M:%S', |
| 127 | level=custom_log_level) | 127 | level=custom_log_level) |
| 128 | for handler in logging.root.handlers: | 128 | for handler in logging.root.handlers: |
| 129 | handler.addFilter(NoParsingFilter()) | 129 | handler.addFilter(NoParsingFilter()) |
| 130 | local_log = logging.getLogger(caller) | 130 | local_log = logging.getLogger(caller) |
| 131 | 131 | ||
| 132 | #check status of tests and record it | 132 | #check status of tests and record it |
| 133 | for (name, msg) in result.errors: | 133 | for (name, msg) in result.errors: |
| 134 | if self._testMethodName == str(name).split(' ')[0]: | 134 | if self._testMethodName == str(name).split(' ')[0]: |
| 135 | local_log.results("Testcase "+str(test_case)+": ERROR") | 135 | local_log.results("Testcase "+str(test_case)+": ERROR") |
| 136 | local_log.results("Testcase "+str(test_case)+":\n"+msg) | 136 | local_log.results("Testcase "+str(test_case)+":\n"+msg) |
| 137 | passed = False | 137 | passed = False |
| 138 | for (name, msg) in result.failures: | 138 | for (name, msg) in result.failures: |
| 139 | if self._testMethodName == str(name).split(' ')[0]: | 139 | if self._testMethodName == str(name).split(' ')[0]: |
| 140 | local_log.results("Testcase "+str(test_case)+": FAILED") | 140 | local_log.results("Testcase "+str(test_case)+": FAILED") |
| 141 | local_log.results("Testcase "+str(test_case)+":\n"+msg) | 141 | local_log.results("Testcase "+str(test_case)+":\n"+msg) |
| 142 | passed = False | 142 | passed = False |
| 143 | for (name, msg) in result.skipped: | 143 | for (name, msg) in result.skipped: |
| 144 | if self._testMethodName == str(name).split(' ')[0]: | 144 | if self._testMethodName == str(name).split(' ')[0]: |
| 145 | local_log.results("Testcase "+str(test_case)+": SKIPPED") | 145 | local_log.results("Testcase "+str(test_case)+": SKIPPED") |
| 146 | passed = False | 146 | passed = False |
| 147 | if passed: | 147 | if passed: |
| 148 | local_log.results("Testcase "+str(test_case)+": PASSED") | 148 | local_log.results("Testcase "+str(test_case)+": PASSED") |
| 149 | 149 | ||
| 150 | original_class.run = run | 150 | original_class.run = run |
| 151 | return original_class | 151 | return original_class |
