Index: tester/rt/config.py
===================================================================
--- tester/rt/config.py	(revision 29f9e10ed4c1650d7fdcab8e3fb24b2cbbf5a0d5)
+++ tester/rt/config.py	(revision a4fbd167ebf67900480363b819d030e1934cff75)
@@ -350,43 +350,45 @@
 
     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()
@@ -394,6 +396,8 @@
     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):
Index: tester/rt/report.py
===================================================================
--- tester/rt/report.py	(revision 29f9e10ed4c1650d7fdcab8e3fb24b2cbbf5a0d5)
+++ tester/rt/report.py	(revision a4fbd167ebf67900480363b819d030e1934cff75)
@@ -32,4 +32,6 @@
 # RTEMS Testing Reports
 #
+
+from __future__ import print_function
 
 import datetime
@@ -148,86 +150,90 @@
             prefixed_output += [line[0] + ' ' + line[1]]
         self.lock.acquire()
-        if name not in self.results:
+        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:
+                    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':
+                    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()
-            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':
-                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))
-        self.lock.release()
         return status
 
