rtemstoolkit: Fix execute's writer thread to not eval() the input.

The conversion to Python3 added an eval() call which is wrong.

Fix the spelling in execute.

Fix labels in the tester gdb locking.

Check the debug-trace arguments.

Close #2642.
This commit is contained in:
Chris Johns
2016-03-14 14:59:11 +11:00
parent a44fedf902
commit 6f8b07c3b6
4 changed files with 20 additions and 12 deletions

View File

@@ -43,6 +43,7 @@ import sys
import subprocess import subprocess
import threading import threading
import time import time
import traceback
# #
# Support to handle use in a package and as a unit test. # Support to handle use in a package and as a unit test.
@@ -138,7 +139,7 @@ class execute(object):
block and return None or False if this thread is to exit and True if this block and return None or False if this thread is to exit and True if this
is a timeout check.""" is a timeout check."""
if trace_threads: if trace_threads:
print('executte:_writethread: start') print('execute:_writethread: start')
encoding = True encoding = True
try: try:
tmp = bytes('temp', sys.stdin.encoding) tmp = bytes('temp', sys.stdin.encoding)
@@ -146,7 +147,9 @@ class execute(object):
encoding = False encoding = False
try: try:
while True: while True:
lines = eval(input()) if trace_threads:
print('execute:_writethread: call input', input)
lines = input()
if type(lines) == str or type(lines) == bytes: if type(lines) == str or type(lines) == bytes:
try: try:
if encoding: if encoding:
@@ -160,14 +163,15 @@ class execute(object):
break break
except: except:
if trace_threads: if trace_threads:
print('executte:_writethread: exception') print('execute:_writethread: exception')
print(traceback.format_exc())
pass pass
try: try:
fh.close() fh.close()
except: except:
pass pass
if trace_threads: if trace_threads:
print('executte:_writethread: finished') print('execute:_writethread: finished')
def _readthread(exe, fh, out, prefix = ''): def _readthread(exe, fh, out, prefix = ''):
"""Read from a file handle and write to the output handler """Read from a file handle and write to the output handler
@@ -184,7 +188,7 @@ class execute(object):
log.flush() log.flush()
if trace_threads: if trace_threads:
print('executte:_readthread: start') print('execute:_readthread: start')
count = 0 count = 0
line = '' line = ''
try: try:
@@ -206,7 +210,8 @@ class execute(object):
except: except:
raise raise
if trace_threads: if trace_threads:
print('executte:_readthread: exception') print('execute:_readthread: exception')
print(traceback.format_exc())
pass pass
try: try:
fh.close() fh.close()
@@ -215,7 +220,7 @@ class execute(object):
if len(line): if len(line):
_output_line(line, exe, prefix, out, 100) _output_line(line, exe, prefix, out, 100)
if trace_threads: if trace_threads:
print('executte:_readthread: finished') print('execute:_readthread: finished')
def _timerthread(exe, interval, function): def _timerthread(exe, interval, function):
"""Timer thread is used to timeout a process if no output is """Timer thread is used to timeout a process if no output is

View File

@@ -144,12 +144,12 @@ class gdb(object):
def _writer(self): def _writer(self):
try: try:
try: try:
self._lock('_open') self._lock('_writer')
try: try:
if self.process is None: if self.process is None:
return None return None
finally: finally:
self._unlock('_open') self._unlock('_writer')
line = self.input.get(timeout = 0.5) line = self.input.get(timeout = 0.5)
if self.trace: if self.trace:
print('>>> input: queue=%d' % (self.input.qsize()), line) print('>>> input: queue=%d' % (self.input.qsize()), line)

View File

@@ -145,6 +145,7 @@ class report(object):
if name not in self.results: if name not in self.results:
self.lock.release() self.lock.release()
raise error.general('test report missing: %s' % (name)) raise error.general('test report missing: %s' % (name))
exe = path.basename(self.results[name]['exe'])
result = self.results[name]['result'] result = self.results[name]['result']
time = self.results[name]['end'] - self.results[name]['start'] time = self.results[name]['end'] - self.results[name]['start']
if mode != 'none': if mode != 'none':
@@ -158,8 +159,7 @@ class report(object):
log.output(header) log.output(header)
if output: if output:
log.output(output) log.output(output)
if header: log.output('Result: %-10s Time: %s %s' % (result, str(time), exe))
log.output('Result: %-10s Time: %s' % (result, str(time)))
def summary(self): def summary(self):
def show_state(results, state, max_len): def show_state(results, state, max_len):

View File

@@ -217,7 +217,10 @@ def run(command_path = None):
opts.log_info() opts.log_info()
debug_trace = opts.find_arg('--debug-trace') debug_trace = opts.find_arg('--debug-trace')
if debug_trace: if debug_trace:
debug_trace = debug_trace[1] if len(debug_trace) != 1:
debug_trace = debug_trace[1]
else:
raise error.general('no debug flags, can be: console,gdb,output')
else: else:
debug_trace = '' debug_trace = ''
opts.defaults['debug_trace'] = debug_trace opts.defaults['debug_trace'] = debug_trace