[rtems-tools commit] tester: Fix the handling of the version and tools recs when running parallel jobs

Chris Johns chrisj at rtems.org
Tue Nov 27 02:55:44 UTC 2018


Module:    rtems-tools
Branch:    master
Commit:    a4fbd167ebf67900480363b819d030e1934cff75
Changeset: http://git.rtems.org/rtems-tools/commit/?id=a4fbd167ebf67900480363b819d030e1934cff75

Author:    Chris Johns <chrisj at rtems.org>
Date:      Mon Nov 26 14:38:37 2018 +1100

tester: Fix the handling of the version and tools recs when running parallel jobs

---

 tester/rt/config.py |  82 +++++++++++++-------------
 tester/rt/report.py | 164 +++++++++++++++++++++++++++-------------------------
 2 files changed, 128 insertions(+), 118 deletions(-)

diff --git a/tester/rt/config.py b/tester/rt/config.py
index 448581f..673c39b 100644
--- a/tester/rt/config.py
+++ b/tester/rt/config.py
@@ -349,52 +349,56 @@ class file(config.file):
         self.load(self.name)
 
     def capture(self, text):
-        if not self.test_started:
-            s = text.find('*** BEGIN OF TEST ')
-            if s >= 0:
-                self.test_started = True
-                e = text[s + 3:].find('***')
-                if e >= 0:
-                    self.test_label = text[s + len('*** BEGIN OF TEST '):s + e + 3 - 1]
-                self.capture_console('test start: %s' % (self.test_label))
-        ok_to_kill = '*** TEST STATE: USER_INPUT' in text or \
-                     '*** TEST STATE: BENCHMARK' in text
-        if ok_to_kill:
-            reset_target = True
-        else:
-            reset_target = False
-        if self.test_started and self.target_start_regx is not None:
-            if self.target_start_regx.match(text):
-                self.capture_console('target start detected')
-                ok_to_kill = True
-        if not reset_target and self.target_reset_regx is not None:
-            if self.target_reset_regx.match(text):
-                self.capture_console('target reset condition detected')
-                self._target_command('reset')
-        if self.kill_on_end:
-            if not ok_to_kill and '*** END OF TEST ' in text:
-                self.capture_console('test end: %s' % (self.test_label))
-                if self.test_label is not None:
-                    ok_to_kill = '*** END OF TEST %s ***' % (self.test_label) in text
-        text = [(self.console_prefix, l) for l in text.replace(chr(13), '').splitlines()]
         self._lock()
-        if self.output is not None:
-            if self.realtime_trace:
-                self._realtime_trace(text)
-            self.output += text
-        if reset_target:
-            if self.index == self.total:
-                self._target_command('off')
+        try:
+            if not self.test_started:
+                s = text.find('*** BEGIN OF TEST ')
+                if s >= 0:
+                    self.test_started = True
+                    e = text[s + 3:].find('***')
+                    if e >= 0:
+                        self.test_label = text[s + len('*** BEGIN OF TEST '):s + e + 3 - 1]
+                    self._capture_console('test start: %s' % (self.test_label))
+            ok_to_kill = '*** TEST STATE: USER_INPUT' in text or \
+                         '*** TEST STATE: BENCHMARK' in text
+            if ok_to_kill:
+                reset_target = True
             else:
-                self._target_command('reset')
-        self._unlock()
+                reset_target = False
+            if self.test_started and self.target_start_regx is not None:
+                if self.target_start_regx.match(text):
+                    self._capture_console('target start detected')
+                    ok_to_kill = True
+            if not reset_target and self.target_reset_regx is not None:
+                if self.target_reset_regx.match(text):
+                    self._capture_console('target reset condition detected')
+                    self._target_command('reset')
+            if self.kill_on_end:
+                if not ok_to_kill and '*** END OF TEST ' in text:
+                    self._capture_console('test end: %s' % (self.test_label))
+                    if self.test_label is not None:
+                        ok_to_kill = '*** END OF TEST %s ***' % (self.test_label) in text
+            text = [(self.console_prefix, l) for l in text.replace(chr(13), '').splitlines()]
+            if self.output is not None:
+                if self.realtime_trace:
+                    self._realtime_trace(text)
+                self.output += text
+            if reset_target:
+                if self.index == self.total:
+                    self._target_command('off')
+                else:
+                    self._target_command('reset')
+        finally:
+            self._unlock()
         if ok_to_kill:
             self._ok_kill()
 
     def capture_console(self, text):
         self._lock()
-        self._capture_console(text)
-        self._unlock()
+        try:
+            self._capture_console(text)
+        finally:
+            self._unlock()
 
     def exe_trace(self, flag):
         dt = self.macros['exe_trace']
diff --git a/tester/rt/report.py b/tester/rt/report.py
index 4bf6ef4..06acb21 100644
--- a/tester/rt/report.py
+++ b/tester/rt/report.py
@@ -32,6 +32,8 @@
 # RTEMS Testing Reports
 #
 
+from __future__ import print_function
+
 import datetime
 import os
 import threading
@@ -147,88 +149,92 @@ class report(object):
                         tools = banner[11:].strip()
             prefixed_output += [line[0] + ' ' + line[1]]
         self.lock.acquire()
-        if name not in self.results:
-            self.lock.release()
-            raise error.general('test report missing: %s' % (name))
-        if self.results[name]['end'] is not None:
-            self.lock.release()
-            raise error.general('test already finished: %s' % (name))
-        self.results[name]['end'] = datetime.datetime.now()
-        if version:
-            if 'version' not in self.config:
-                self.config['version'] = version
-            else:
-                if version != self.config['version']:
-                    state = 'WRONG-VERSION'
-        if build:
-            if 'build' not in self.config:
-                self.config['build'] = build
-            else:
-                if build != self.config['build']:
-                    state = 'WRONG-BUILD'
-        if tools:
-            if 'tools' not in self.config:
-                self.config['tools'] = tools
-            else:
-                if tools != self.config['tools']:
-                    state = 'WRONG-TOOLS'
-        if state is None or state == 'EXPECTED-PASS':
-            if start and end:
-                if state is None or state == 'EXPECTED-PASS':
-                    status = 'passed'
-                    self.passed += 1
-            elif timeout:
-                status = 'timeout'
-                self.timeouts += 1
-            elif start:
-                if not end:
-                    status = 'failed'
-                    self.failed += 1
-            else:
-                exe_name = path.basename(name).split('.')[0]
-                if exe_name in test_fail_excludes:
-                    status = 'passed'
-                    self.passed += 1
-                else:
-                    status = 'invalid'
-                    self.invalids += 1
-        else:
-            if state == 'EXPECTED_FAIL':
-                if start and end:
-                    status = 'passed'
-                    self.passed += 1
-                else:
-                    status = 'expected-fail'
-                    self.expected_fail += 1
-            elif state == 'USER_INPUT':
-                status = 'user-input'
-                self.user_input += 1
-            elif state == 'INDETERMINATE':
+        try:
+            if name not in self.results:
+                raise error.general('test report missing: %s' % (name))
+            if self.results[name]['end'] is not None:
+                raise error.general('test already finished: %s' % (name))
+            self.results[name]['end'] = datetime.datetime.now()
+            if state is not None and state not in ['BENCHMARK',
+                                                   'EXPECTED_FAIL',
+                                                   'INDETERMINATE',
+                                                   'USER_INPUT']:
+                if version:
+                    if 'version' not in self.config:
+                        self.config['version'] = version
+                    else:
+                        if version != self.config['version']:
+                            state = 'WRONG-VERSION'
+                if build:
+                    if 'build' not in self.config:
+                        self.config['build'] = build
+                    else:
+                        if build != self.config['build']:
+                            state = 'WRONG-BUILD'
+                if tools:
+                    if 'tools' not in self.config:
+                        self.config['tools'] = tools
+                    else:
+                        if tools != self.config['tools']:
+                            state = 'WRONG-TOOLS'
+            if state is None or state == 'EXPECTED-PASS':
                 if start and end:
-                    status = 'passed'
-                    self.passed += 1
+                    if state is None or state == 'EXPECTED-PASS':
+                        status = 'passed'
+                        self.passed += 1
+                elif timeout:
+                    status = 'timeout'
+                    self.timeouts += 1
+                elif start:
+                    if not end:
+                        status = 'failed'
+                        self.failed += 1
                 else:
-                    status = 'indeterminate'
-                    self.indeterminate += 1
-            elif state == 'BENCHMARK':
-                status = 'benchmark'
-                self.benchmark += 1
-            elif state == 'WRONG-VERSION':
-                status = 'wrong-version'
-                self.wrong_version += 1
-            elif state == 'WRONG-BUILD':
-                status = 'wrong-build'
-                self.wrong_build += 1
-            elif state == 'WRONG-TOOLS':
-                status = 'wrong-tools'
-                self.wrong_tools += 1
+                    exe_name = path.basename(name).split('.')[0]
+                    if exe_name in test_fail_excludes:
+                        status = 'passed'
+                        self.passed += 1
+                    else:
+                        status = 'invalid'
+                        self.invalids += 1
             else:
-                raise error.general('invalid test state: %s: %s' % (name, state))
-        self.results[name]['result'] = status
-        self.results[name]['output'] = prefixed_output
-        if self.name_max_len < len(path.basename(name)):
-            self.name_max_len = len(path.basename(name))
-        self.lock.release()
+                if state == 'EXPECTED_FAIL':
+                    if start and end:
+                        status = 'passed'
+                        self.passed += 1
+                    else:
+                        status = 'expected-fail'
+                        self.expected_fail += 1
+                elif state == 'USER_INPUT':
+                    status = 'user-input'
+                    self.user_input += 1
+                elif state == 'INDETERMINATE':
+                    if start and end:
+                        status = 'passed'
+                        self.passed += 1
+                    else:
+                        status = 'indeterminate'
+                        self.indeterminate += 1
+                elif state == 'BENCHMARK':
+                    status = 'benchmark'
+                    self.benchmark += 1
+                elif state == 'WRONG-VERSION':
+                    status = 'wrong-version'
+                    self.wrong_version += 1
+                elif state == 'WRONG-BUILD':
+                    status = 'wrong-build'
+                    self.wrong_build += 1
+                elif state == 'WRONG-TOOLS':
+                    status = 'wrong-tools'
+                    self.wrong_tools += 1
+                else:
+                    raise error.general('invalid test state: %s: %s' % (name, state))
+            self.results[name]['result'] = status
+            self.results[name]['output'] = prefixed_output
+            if self.name_max_len < len(path.basename(name)):
+                self.name_max_len = len(path.basename(name))
+        finally:
+            self.lock.release()
         return status
 
     def log(self, name, mode):



More information about the vc mailing list