diff options
Diffstat (limited to 'tester/rt')
-rw-r--r-- | tester/rt/config.py | 2 | ||||
-rw-r--r-- | tester/rt/console.py | 10 | ||||
-rw-r--r-- | tester/rt/gdb.py | 40 | ||||
-rw-r--r-- | tester/rt/options.py | 10 | ||||
-rwxr-xr-x | tester/rt/pygdb/mi_parser.py | 34 | ||||
-rw-r--r-- | tester/rt/pygdb/spark.py | 29 | ||||
-rw-r--r-- | tester/rt/stty.py | 6 | ||||
-rw-r--r-- | tester/rt/test.py | 22 | ||||
-rw-r--r-- | tester/rt/version.py | 8 |
9 files changed, 81 insertions, 80 deletions
diff --git a/tester/rt/config.py b/tester/rt/config.py index ac9c8aa..444420b 100644 --- a/tester/rt/config.py +++ b/tester/rt/config.py @@ -185,7 +185,7 @@ class file(config.file): def _realtime_trace(self, text): if self.realtime_trace: for l in text: - print ' '.join(l) + print(' '.join(l)) def run(self): self.load(self.name) diff --git a/tester/rt/console.py b/tester/rt/console.py index fa70541..a6d3161 100644 --- a/tester/rt/console.py +++ b/tester/rt/console.py @@ -100,7 +100,7 @@ class tty(console): def __del__(self): super(tty, self).__del__() if self._tracing(): - print ':: tty close', self.dev + print(':: tty close', self.dev) if fcntl is not None: fcntl.fcntl(me.tty.fd, fcntl.F_SETFL, fcntl.fcntl(me.tty.fd, fcntl.F_GETFL) & ~os.O_NONBLOCK) @@ -109,7 +109,7 @@ class tty(console): def open(self): def _readthread(me, x): if self._tracing(): - print ':: tty runner started', self.dev + print(':: tty runner started', self.dev) if fcntl is not None: fcntl.fcntl(me.tty.fd, fcntl.F_SETFL, fcntl.fcntl(me.tty.fd, fcntl.F_GETFL) | os.O_NONBLOCK) @@ -118,7 +118,7 @@ class tty(console): time.sleep(0.05) try: data = me.tty.fd.read() - except IOError, ioe: + except IOError as ioe: if ioe.errno == errno.EAGAIN: continue raise @@ -133,9 +133,9 @@ class tty(console): me.output(line) line = '' if self._tracing(): - print ':: tty runner finished', self.dev + print(':: tty runner finished', self.dev) if self._tracing(): - print ':: tty open', self.dev + print(':: tty open', self.dev) self.tty = stty.tty(self.dev) self.tty.set(self.setup) self.tty.on() diff --git a/tester/rt/gdb.py b/tester/rt/gdb.py index 2efd5c0..cbf2c0d 100644 --- a/tester/rt/gdb.py +++ b/tester/rt/gdb.py @@ -76,12 +76,12 @@ class gdb(object): def _lock(self, msg): if self.lock_trace: - print '|[ LOCK:%s ]|' % (msg) + print('|[ LOCK:%s ]|' % (msg)) self.lock.acquire() def _unlock(self, msg): if self.lock_trace: - print '|] UNLOCK:%s [|' % (msg) + print('|] UNLOCK:%s [|' % (msg)) self.lock.release() def _mi_lock(self): @@ -92,7 +92,7 @@ class gdb(object): def _put(self, text): if self.trace: - print ')))', text + print(')))', text) self.commands.put(text) def _input_commands(self): @@ -100,11 +100,11 @@ class gdb(object): return False try: if self.trace: - print '... input empty ', self.input.empty() + print('... input empty ', self.input.empty()) if self.input.empty(): line = self.commands.get(block = False) if self.trace: - print '+++', line + print('+++', line) self.input.put(line) except: pass @@ -113,12 +113,12 @@ class gdb(object): def _reader(self, line): self._lock('_reader') if self.trace: - print '<<<', line + print('<<<', line) try: self.lc += 1 if line.startswith('(gdb)'): if self.trace: - print '^^^ (gdb)' + print('^^^ (gdb)') if not self._input_commands(): self.gdb_expect() self._input_commands() @@ -138,7 +138,7 @@ class gdb(object): self._unlock('_open') line = self.input.get(timeout = 0.5) if self.trace: - print '>>> input: queue=%d' % (self.input.qsize()), line + print('>>> input: queue=%d' % (self.input.qsize()), line) except Queue.Empty: return True if line is None: @@ -146,10 +146,10 @@ class gdb(object): return line + os.linesep except: if self.trace: - print 'writer exception' + print('writer exception') pass if self.trace: - print 'writer closing' + print('writer closing') return False def _timeout(self): @@ -206,7 +206,7 @@ class gdb(object): self.gdb_console('gdb: %s' % (' '.join(cmds))) ec, proc = self.process.open(cmds, timeout = (timeout, self._timeout)) if self.trace: - print 'gdb done', ec + print('gdb done', ec) if ec > 0: raise error.general('gdb exec: %s: %s' % (cmds[0], os.strerror(ec))) except: @@ -219,7 +219,7 @@ class gdb(object): def gdb_expect(self): if self.trace: - print '}}} gdb-expect' + print('}}} gdb-expect') if self.process and not self.running and self.script is not None: if self.script_line == len(self.script): self._put(None) @@ -238,12 +238,12 @@ class gdb(object): self._mi_lock() try: if self.mi_trace: - print 'mi-data:', lines + print('mi-data:', lines) rec = pygdb.mi_parser.process(lines) finally: self._mi_unlock() if self.mi_trace: - print 'mi-rec:', rec + print('mi-rec:', rec) if rec.record_type == 'result': if rec.type == 'result': if rec.class_ == 'error': @@ -255,12 +255,12 @@ class gdb(object): elif rec.type == 'exec': if rec.class_ == 'running': if self.trace: - print '*** running' + print('*** running') self._put('') self.running = True elif rec.class_ == 'stopped': if self.trace: - print '*** stopped' + print('*** stopped') self.running = False #self._put('-data-list-register-values') elif rec.type == 'breakpoint': @@ -283,13 +283,13 @@ class gdb(object): if last_lf >= 0: lines = self.output_buffer[:last_lf] if self.trace: - print '/// console output' + print('/// console output') for line in lines.splitlines(): self.output(line) self.output_buffer = self.output_buffer[last_lf + 1:] except: if self.trace: - print '/// console output' + print('/// console output') for line in lines.splitlines(): self.output(line) @@ -297,9 +297,9 @@ if __name__ == "__main__": stdtty = console.save() try: def output(text): - print ']', text + print(']', text) def gdb_console(text): - print '>', text + print('>', text) script = ['target sim'] if len(sys.argv) > 1: executable = sys.argv[1] diff --git a/tester/rt/options.py b/tester/rt/options.py index a916cbb..c49a288 100644 --- a/tester/rt/options.py +++ b/tester/rt/options.py @@ -114,13 +114,13 @@ def run(args): log.notice(str(_opts)) log.notice('Defaults:') log.notice(str(_opts.defaults)) - except error.general, gerr: - print gerr + except error.general as gerr: + print(gerr) sys.exit(1) - except error.internal, ierr: - print ierr + except error.internal as ierr: + print(ierr) sys.exit(1) - except error.exit, eerr: + except error.exit: pass except KeyboardInterrupt: log.notice('abort: user terminated') diff --git a/tester/rt/pygdb/mi_parser.py b/tester/rt/pygdb/mi_parser.py index 65ea5e0..7ec8e34 100755 --- a/tester/rt/pygdb/mi_parser.py +++ b/tester/rt/pygdb/mi_parser.py @@ -93,7 +93,7 @@ def __private(): def t_default(self, s): r'( . | \n )+' - raise Exception, "Specification error: unmatched input for '%s'" % s + raise Exception("Specification error: unmatched input for '%s'" % s) def __unescape(self, s): s = re.sub(r'\\r', r'\r', s) @@ -167,8 +167,8 @@ def __private(): def error(self, token, i=0, tokens=None): if i > 2: - print '%s %s %s %s' % (tokens[i-3], tokens[i-2], tokens[i-1], tokens[i]) - raise Exception, "Syntax error at or near %d:'%s' token" % (i, token) + print('%s %s %s %s' % (tokens[i-3], tokens[i-2], tokens[i-1], tokens[i])) + raise Exception("Syntax error at or near %d:'%s' token" % (i, token)) class GdbMiInterpreter(spark.GenericASTTraversal): def __init__(self, ast): @@ -190,7 +190,7 @@ def __private(): def n_result(self, node): # result ::= variable = value node.value = { node[0].value: node[2].value } - #print 'result: %s' % node.value + #print('result: %s' % node.value) def n_tuple(self, node): if len(node) == 2: @@ -205,7 +205,7 @@ def __private(): for result in node[2].value: for n, v in result.items(): if node.value.has_key(n): - #print '**********list conversion: [%s] %s -> %s' % (n, node.value[n], v) + #print('**********list conversion: [%s] %s -> %s' % (n, node.value[n], v)) old = node.value[n] if not isinstance(old, list): node.value[n] = [ node.value[n] ] @@ -213,8 +213,8 @@ def __private(): else: node.value[n] = v else: - raise Exception, 'Invalid tuple' - #print 'tuple: %s' % node.value + raise Exception('Invalid tuple') + #print('tuple: %s' % node.value) def n_list(self, node): if len(node) == 2: @@ -230,7 +230,7 @@ def __private(): #list ::= [ result result_list ] #list ::= { value } #list ::= { value value_list } - #print 'list %s' % node.value + #print('list %s' % node.value) def n_value_list(self, node): if len(node) == 2: @@ -247,7 +247,7 @@ def __private(): else: # result_list ::= , result result_list node.value = [ node[1].value ] + node[2].value - #print 'result_list: %s' % node.value + #print('result_list: %s' % node.value) def n_result_record(self, node): node.value = node[0].value @@ -257,7 +257,7 @@ def __private(): elif len(node) == 2: # result_record ::= result_header nl pass - #print 'result_record: %s' % (node.value) + #print('result_record: %s' % (node.value)) def n_result_header(self, node): if len(node) == 3: @@ -284,7 +284,7 @@ def __private(): 'value': node[1].value, 'record_type': 'stream' } - #print 'stream_record: %s' % node.value + #print('stream_record: %s' % node.value) def n_record_list(self, node): if len(node) == 1: @@ -293,10 +293,10 @@ def __private(): elif len(node) == 2: # record_list ::= generic_record record_list node.value = [ node[0].value ] + node[1].value - #print 'record_list: %s' % node.value + #print('record_list: %s' % node.value) #def default(self, node): - #print 'default: ' + node.type + #print('default: ' + node.type) class GdbDynamicObject: def __init__(self, dict_): @@ -363,7 +363,7 @@ def parse(tokens): def process(input): tokens = scan(input) - ast = parse(tokens) + ast = parse(tokens) __the_interpreter(ast) return __the_output(ast.value) @@ -373,9 +373,9 @@ if __name__ == '__main__': print for token in tokens: if token.value: - print token.type + ': ' + token.value + print(token.type + ': ' + token.value) else: - print token.type + print(token.type) def run_test(test): lines = test.splitlines() @@ -386,7 +386,7 @@ if __name__ == '__main__': ast = parse(tokens) __the_interpreter(ast) output = __the_output(ast.value) - print output + print(output) x = '"No symbol table is loaded. Use the \\"file\\" command."' m = re.match('\".*?(?<![\\\\])\"', x) diff --git a/tester/rt/pygdb/spark.py b/tester/rt/pygdb/spark.py index aab2d19..7dc1358 100644 --- a/tester/rt/pygdb/spark.py +++ b/tester/rt/pygdb/spark.py @@ -60,7 +60,7 @@ class GenericScanner: return string.join(rv, '|') def error(self, s, pos): - print "Lexical error at position %s" % pos + print("Lexical error at position %s" % pos) raise SystemExit def position(self, newpos=None): @@ -86,7 +86,7 @@ class GenericScanner: def t_default(self, s): r'( . | \n )+' - print "Specification error: unmatched input" + print("Specification error: unmatched input") raise SystemExit # @@ -303,7 +303,7 @@ class GenericParser: return None def error(self, token): - print "Syntax error at or near `%s' token" % token + print("Syntax error at or near `%s' token" % token) raise SystemExit def parse(self, tokens): @@ -349,7 +349,8 @@ class GenericParser: # return self._NULLABLE == sym[0:len(self._NULLABLE)] - def skip(self, (lhs, rhs), pos=0): + def skip(self, lhs_rhs, pos=0): + lhs, rhs = lhs_rhs n = len(rhs) while pos < n: if not self.isnullable(rhs[pos]): @@ -612,7 +613,7 @@ class GenericParser: rule = self.ambiguity(self.newrules[nt]) else: rule = self.newrules[nt][0] - #print rule + #print(rule) rhs = rule[1] attr = [None] * len(rhs) @@ -631,7 +632,7 @@ class GenericParser: rule = choices[0] if len(choices) > 1: rule = self.ambiguity(choices) - #print rule + #print(rule) rhs = rule[1] attr = [None] * len(rhs) @@ -668,7 +669,7 @@ class GenericParser: sortlist.append((len(rhs), name)) name2index[name] = i sortlist.sort() - list = map(lambda (a,b): b, sortlist) + list = list(map(lambda a,b: b, sortlist)) return rules[name2index[self.resolve(list)]] def resolve(self, list): @@ -833,15 +834,15 @@ class GenericASTMatcher(GenericParser): def _dump(tokens, sets, states): for i in range(len(sets)): - print 'set', i + print('set', i) for item in sets[i]: - print '\t', item + print('\t', item) for (lhs, rhs), pos in states[item[0]].items: - print '\t\t', lhs, '::=', - print string.join(rhs[:pos]), - print '.', - print string.join(rhs[pos:]) + print('\t\t', lhs, '::=',) + print(string.join(rhs[:pos]),) + print('.',) + print(string.join(rhs[pos:])) if i < len(tokens): print - print 'token', str(tokens[i]) + print('token', str(tokens[i])) print diff --git a/tester/rt/stty.py b/tester/rt/stty.py index d059b40..b6f0204 100644 --- a/tester/rt/stty.py +++ b/tester/rt/stty.py @@ -72,7 +72,7 @@ class tty: raise error.general('dev not found: %s' % (dev)) try: self.fd = open(dev, 'rw') - except IOError, ioe: + except IOError as ioe: raise error.general('opening tty dev: %s: %s' % (dev, ioe)) except: raise error.general('opening tty dev: %s: unknown' % (dev)) @@ -558,9 +558,9 @@ if __name__ == "__main__": t.control('CRTSCTS', False) t.vmin(1) t.vtime(2) - print t + print(t) t.set('B115200,~BRKINT,IGNBRK,IGNCR,~ICANON,~ISIG,~IEXTEN,~ECHO,CLOCAL,~CRTSCTS') - print t + print(t) t.on() while True: c = t.fd.read(1) diff --git a/tester/rt/test.py b/tester/rt/test.py index 551c8b5..ff211d2 100644 --- a/tester/rt/test.py +++ b/tester/rt/test.py @@ -118,7 +118,7 @@ class test_run(object): def reraise(self): if self.result is not None: - raise self.result[0], self.result[1], self.result[2] + raise (self.result[0], self.result[1], self.result[2]) def kill(self): if self.test: @@ -157,9 +157,9 @@ def report_finished(reports, report_mode, reporting, finished, job_trace): if len(reported): del reported[:] if job_trace: - print '}} threading:', threading.active_count() + print('}} threading:', threading.active_count()) for t in threading.enumerate(): - print '}} ', t.name + print('}} ', t.name) return reporting def _job_trace(tst, msg, total, exe, active, reporting): @@ -302,20 +302,20 @@ def run(command_path = None): end_time = datetime.datetime.now() log.notice('Average test time: %s' % (str((end_time - start_time) / total))) log.notice('Testing time : %s' % (str(end_time - start_time))) - except error.general, gerr: - print gerr + except error.general as gerr: + print(gerr) sys.exit(1) - except error.internal, ierr: - print ierr + except error.internal as ierr: + print(ierr) sys.exit(1) - except error.exit, eerr: + except error.exit: sys.exit(2) except KeyboardInterrupt: if opts is not None and opts.find_arg('--stacktrace'): - print '}} dumping:', threading.active_count() + print('}} dumping:', threading.active_count()) for t in threading.enumerate(): - print '}} ', t.name - print stacktraces.trace() + print('}} ', t.name) + print(stacktraces.trace()) log.notice('abort: user terminated') killall(tests) sys.exit(1) diff --git a/tester/rt/version.py b/tester/rt/version.py index 0cc1fca..743d38a 100644 --- a/tester/rt/version.py +++ b/tester/rt/version.py @@ -42,7 +42,7 @@ def str(): return '%d.%d.%d'% (major, minor, revision) if __name__ == '__main__': - print 'major = %d' % (major) - print 'minor = %d' % (minor) - print 'revision = %d' % (revision) - print 'Version: %s' % (str()) + print('major = %d' % (major)) + print('minor = %d' % (minor)) + print('revision = %d' % (revision)) + print('Version: %s' % (str())) |