summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Johns <chrisj@rtems.org>2016-03-03 16:46:18 +1100
committerChris Johns <chrisj@rtems.org>2016-03-03 16:53:39 +1100
commitb0fa2ae9981b0ccf6a66cb8df2241caa5038eb36 (patch)
treed4f7f225cd35334ff18c3189bf1cdefa0d3335b4
parentAdd aarch64 and x86_64 binutils and gdb patches. (diff)
downloadrtems-tools-b0fa2ae9981b0ccf6a66cb8df2241caa5038eb36.tar.bz2
Update rtems-tool to support Python 2 and 3.
Add solaris and netbsd. Close #2619.
-rw-r--r--rtemstoolkit/__init__.py17
-rw-r--r--rtemstoolkit/check.py33
-rw-r--r--rtemstoolkit/config.py67
-rw-r--r--rtemstoolkit/darwin.py11
-rw-r--r--rtemstoolkit/error.py4
-rwxr-xr-xrtemstoolkit/execute.py59
-rw-r--r--rtemstoolkit/freebsd.py14
-rw-r--r--rtemstoolkit/git.py58
-rw-r--r--rtemstoolkit/linux.py18
-rwxr-xr-xrtemstoolkit/log.py15
-rw-r--r--rtemstoolkit/macros.py44
-rw-r--r--rtemstoolkit/mailer.py19
-rw-r--r--rtemstoolkit/netbsd.py96
-rw-r--r--rtemstoolkit/options.py86
-rw-r--r--rtemstoolkit/path.py16
-rw-r--r--rtemstoolkit/solaris.py90
-rw-r--r--rtemstoolkit/version.py19
-rw-r--r--rtemstoolkit/windows.py14
-rw-r--r--tester/rt/config.py6
-rw-r--r--tester/rt/console.py4
-rw-r--r--tester/rt/gdb.py26
-rw-r--r--tester/rt/options.py9
-rw-r--r--tester/rt/pygdb/__init__.py5
-rwxr-xr-xtester/rt/pygdb/mi_parser.py34
-rw-r--r--tester/rt/pygdb/spark.py70
-rw-r--r--tester/rt/test.py14
-rw-r--r--tester/rt/version.py48
-rwxr-xr-xtester/rtems-test3
28 files changed, 643 insertions, 256 deletions
diff --git a/rtemstoolkit/__init__.py b/rtemstoolkit/__init__.py
index 33f49f0..f3fbbcd 100644
--- a/rtemstoolkit/__init__.py
+++ b/rtemstoolkit/__init__.py
@@ -1,6 +1,6 @@
#
# RTEMS Tools Project (http://www.rtems.org/)
-# Copyright 2010-2014 Chris Johns (chrisj@rtems.org)
+# Copyright 2010-2016 Chris Johns (chrisj@rtems.org)
# All rights reserved.
#
# This file is part of the RTEMS Tools package in 'rtems-tools'.
@@ -37,4 +37,17 @@ all = ['check',
'macros',
'mailer',
'options',
- 'path']
+ 'path',
+ 'version']
+
+from . import check
+from . import config
+from . import error
+from . import execute
+from . import git
+from . import log
+from . import macros
+from . import mailer
+from . import options
+from . import path
+from . import version
diff --git a/rtemstoolkit/check.py b/rtemstoolkit/check.py
index 19d4dfa..cbec3a3 100644
--- a/rtemstoolkit/check.py
+++ b/rtemstoolkit/check.py
@@ -1,6 +1,6 @@
#
# RTEMS Tools Project (http://www.rtems.org/)
-# Copyright 2010-2014 Chris Johns (chrisj@rtems.org)
+# Copyright 2010-2016 Chris Johns (chrisj@rtems.org)
# All rights reserved.
#
# This file is part of the RTEMS Tools package in 'rtems-tools'.
@@ -32,14 +32,28 @@
# Check the defaults for a specific host.
#
+from __future__ import print_function
+
import os
-import error
-import execute
-import log
-import options
-import path
-import version
+#
+# Support to handle use in a package and as a unit test.
+# If there is a better way to let us know.
+#
+try:
+ from . import error
+ from . import execute
+ from . import log
+ from . import options
+ from . import path
+ from . import version
+except (ValueError, SystemError):
+ import error
+ import execute
+ import log
+ import options
+ import path
+ import version
def _check_none(_opts, macro, value, constraint):
return True
@@ -117,7 +131,7 @@ def host_setup(opts):
sane = True
- for d in opts.defaults.keys():
+ for d in list(opts.defaults.keys()):
try:
(test, constraint, value) = opts.defaults.get(d)
except:
@@ -152,7 +166,8 @@ def check_dir(label, path):
def run():
import sys
try:
- _opts = options.load(args = sys.argv)
+ _opts = options.command_line(argv = sys.argv)
+ options.load(_opts)
log.notice('RTEMS Source Builder - Check, v%s' % (version.str()))
if host_setup(_opts):
print('Environment is ok')
diff --git a/rtemstoolkit/config.py b/rtemstoolkit/config.py
index ee7cb1c..4b2e8e1 100644
--- a/rtemstoolkit/config.py
+++ b/rtemstoolkit/config.py
@@ -1,6 +1,6 @@
#
# RTEMS Tools Project (http://www.rtems.org/)
-# Copyright 2010-2014 Chris Johns (chrisj@rtems.org)
+# Copyright 2010-2016 Chris Johns (chrisj@rtems.org)
# All rights reserved.
#
# This file is part of the RTEMS Tools package in 'rtems-tools'.
@@ -36,29 +36,26 @@
# other software modules.
#
+from __future__ import print_function
+
import copy
+import functools
import os
import re
import sys
-import error
-import execute
-import log
-import options
-import path
-
try:
- import error
- import execute
- import log
- import options
- import path
-except KeyboardInterrupt:
- print('user terminated')
- sys.exit(1)
-except:
- print('error: unknown application load error')
- sys.exit(1)
+ from . import error
+ from . import execute
+ from . import log
+ from . import options
+ from . import path
+except (ValueError, SystemError):
+ import error
+ import execute
+ import log
+ import options
+ import path
def _check_bool(value):
if value.isdigit():
@@ -96,6 +93,8 @@ class file(object):
self.macros.define(label)
self._includes = []
self.load_depth = 0
+ self.lc = 0
+ self.name = 'none'
def __del__(self):
pass
@@ -104,7 +103,7 @@ class file(object):
def _dict(dd):
s = ''
- ddl = dd.keys()
+ ddl = list(dd.keys())
ddl.sort()
for d in ddl:
s += ' ' + d + ': ' + dd[d] + '\n'
@@ -438,13 +437,13 @@ class file(object):
else:
istrue = _check_bool(ifls[0])
if istrue == None:
- self._error('invalid if bool value: ' + reduce(add, ls, ''))
+ self._error('invalid if bool value: ' + functools.reduce(add, ls, ''))
istrue = False
elif len(ifls) == 2:
if ifls[0] == '!':
istrue = _check_bool(ifls[1])
if istrue == None:
- self._error('invalid if bool value: ' + reduce(add, ls, ''))
+ self._error('invalid if bool value: ' + functools.reduce(add, ls, ''))
istrue = False
else:
istrue = not istrue
@@ -460,7 +459,7 @@ class file(object):
elif ifls[1] == '!=':
istrue = True
else:
- self._error('invalid if bool operator: ' + reduce(add, ls, ''))
+ self._error('invalid if bool operator: ' + functools.reduce(add, ls, ''))
elif len(ifls) == 3:
if ifls[1] == '==':
if ifls[0] == ifls[2]:
@@ -493,9 +492,9 @@ class file(object):
else:
istrue = False
else:
- self._error('invalid %if operator: ' + reduce(add, ls, ''))
+ self._error('invalid %if operator: ' + functools.reduce(add, ls, ''))
else:
- self._error('malformed if: ' + reduce(add, ls, ''))
+ self._error('malformed if: ' + functools.reduce(add, ls, ''))
if invert:
istrue = not istrue
log.trace('config: %s: _if: %s %s' % (self.init_name, ifls, str(istrue)))
@@ -842,12 +841,20 @@ def run():
#
# Run where defaults.mc is located
#
- opts = options.load(sys.argv, defaults = 'defaults.mc')
- log.trace('config: count %d' % (len(opts.config_files())))
- for config_file in opts.config_files():
- s = file(config_file, opts)
- print(s)
- del s
+ long_opts = {
+ # key macro handler param defs init
+ '--file' : ('_file', 'path', True, None, False)
+ }
+ opts = options.command_line(base_path = '.',
+ argv = sys.argv,
+ long_opts = long_opts)
+ options.load(opts)
+ if '_file' not in opts.defaults:
+ raise error.general('no --file option provided')
+ s = file(opts.defaults['_file'], opts)
+ s.load(opts.defaults['_file'])
+ print(s)
+ del s
except error.general as gerr:
print(gerr)
sys.exit(1)
diff --git a/rtemstoolkit/darwin.py b/rtemstoolkit/darwin.py
index 1d092cb..57c8197 100644
--- a/rtemstoolkit/darwin.py
+++ b/rtemstoolkit/darwin.py
@@ -1,6 +1,6 @@
#
# RTEMS Tools Project (http://www.rtems.org/)
-# Copyright 2010-2014 Chris Johns (chrisj@rtems.org)
+# Copyright 2010-2016 Chris Johns (chrisj@rtems.org)
# All rights reserved.
#
# This file is part of the RTEMS Tools package in 'rtems-tools'.
@@ -35,7 +35,14 @@
import os
-import execute
+#
+# Support to handle use in a package and as a unit test.
+# If there is a better way to let us know.
+#
+try:
+ from . import execute
+except (ValueError, SystemError):
+ import execute
def load():
uname = os.uname()
diff --git a/rtemstoolkit/error.py b/rtemstoolkit/error.py
index ea6b71d..e3a43c1 100644
--- a/rtemstoolkit/error.py
+++ b/rtemstoolkit/error.py
@@ -1,6 +1,6 @@
#
# RTEMS Tools Project (http://www.rtems.org/)
-# Copyright 2010-2014 Chris Johns (chrisj@rtems.org)
+# Copyright 2010-2016 Chris Johns (chrisj@rtems.org)
# All rights reserved.
#
# This file is part of the RTEMS Tools package in 'rtems-tools'.
@@ -32,6 +32,8 @@
# Various errors we can raise.
#
+from __future__ import print_function
+
class error(Exception):
"""Base class for Builder exceptions."""
def set_output(self, msg):
diff --git a/rtemstoolkit/execute.py b/rtemstoolkit/execute.py
index 3f8e3e6..982e35f 100755
--- a/rtemstoolkit/execute.py
+++ b/rtemstoolkit/execute.py
@@ -1,6 +1,6 @@
#
# RTEMS Tools Project (http://www.rtems.org/)
-# Copyright 2010-2014 Chris Johns (chrisj@rtems.org)
+# Copyright 2010-2016 Chris Johns (chrisj@rtems.org)
# All rights reserved.
#
# This file is part of the RTEMS Tools package in 'rtems-tools'.
@@ -34,6 +34,9 @@
# Note, the subprocess module is only in Python 2.4 or higher.
#
+from __future__ import print_function
+
+import functools
import os
import re
import sys
@@ -41,8 +44,16 @@ import subprocess
import threading
import time
-import error
-import log
+#
+# Support to handle use in a package and as a unit test.
+# If there is a better way to let us know.
+#
+try:
+ from . import error
+ from . import log
+except (ValueError, SystemError):
+ import error
+ import log
# Trace exceptions
trace_threads = False
@@ -96,7 +107,7 @@ def arg_subst(command, substs):
def arg_subst_str(command, subst):
cmd = arg_subst(command, subst)
def add(x, y): return x + ' ' + str(y)
- return reduce(add, cmd, '')
+ return functools.reduce(add, cmd, '')
class execute(object):
"""Execute commands or scripts. The 'output' is a funtion that handles the
@@ -118,7 +129,7 @@ class execute(object):
self.timing_out = False
self.proc = None
- def _capture(self, command, proc, timeout = None):
+ def capture(self, proc, command = 'pipe', timeout = None):
"""Create 3 threads to read stdout and stderr and send to the output handler
and call an input handler is provided. Based on the 'communicate' code
in the subprocess module."""
@@ -128,11 +139,18 @@ class execute(object):
is a timeout check."""
if trace_threads:
print('executte:_writethread: start')
+ encoding = True
+ try:
+ tmp = bytes('temp', sys.stdin.encoding)
+ except:
+ encoding = False
try:
while True:
- lines = input()
- if type(lines) == str:
+ lines = eval(input())
+ if type(lines) == str or type(lines) == bytes:
try:
+ if encoding:
+ lines = bytes(lines, sys.stdin.encoding)
fh.write(lines)
except:
break
@@ -155,10 +173,9 @@ class execute(object):
"""Read from a file handle and write to the output handler
until the file closes."""
def _output_line(line, exe, prefix, out, count):
- #print 'LINE:%d: %s' % (count, line)
- exe.lock.acquire()
+ #exe.lock.acquire()
#exe.outputting = True
- exe.lock.release()
+ #exe.lock.release()
if out:
out(prefix + line)
else:
@@ -175,7 +192,8 @@ class execute(object):
data = fh.read(1)
if len(data) == 0:
break
- #print '))))) %02x "%s"' % (ord(data), data)
+ if type(data) == bytes:
+ data = data.decode(sys.stdout.encoding)
for c in data:
line += c
if c == '\n':
@@ -305,11 +323,13 @@ class execute(object):
s = command
if type(command) is list:
def add(x, y): return x + ' ' + str(y)
- s = reduce(add, command, '')[1:]
+ s = functools.reduce(add, command, '')[1:]
what = 'spawn'
if shell:
what = 'shell'
log.output(what + ': ' + s)
+ if self.output is None:
+ raise error.general('capture needs an output handler')
if shell and self.shell_exe:
command = arg_list(command)
command[:0] = self.shell_exe
@@ -342,7 +362,7 @@ class execute(object):
return (0, proc)
if self.output is None:
raise error.general('capture needs an output handler')
- exit_code = self._capture(command, proc, timeout)
+ exit_code = self.capture(proc, command, timeout)
if self.verbose:
log.output('exit: ' + str(exit_code))
except OSError as ose:
@@ -395,7 +415,7 @@ class execute(object):
shell = shell or self.shell_commands,
cwd = cwd, env = env,
stdin = stdin, stdout = stdout, stderr = stderr,
- itmeout = timeout)
+ timeout = timeout)
def set_shell(self, execute):
"""Set the shell to execute when issuing a shell command."""
@@ -519,11 +539,18 @@ if __name__ == "__main__":
if ec == 0:
print('piping input into ' + commands['pipe'][0] + ': ' + \
commands['pipe'][2])
- proc.stdin.write(commands['pipe'][2])
+ try:
+ out = bytes(commands['pipe'][2], sys.stdin.encoding)
+ except:
+ out = commands['pipe'][2]
+ proc.stdin.write(out)
proc.stdin.close()
e.capture(proc)
del proc
+ def capture_output(text):
+ print(text, end = '')
+
cmd_shell_test = 'if "%OS%" == "Windows_NT" (echo It is WinNT) else echo Is is not WinNT'
sh_shell_test = 'x="me"; if [ $x = "me" ]; then echo "It was me"; else "It was him"; fi'
@@ -549,7 +576,7 @@ if __name__ == "__main__":
print(arg_subst(['nothing', 'xx-%0-yyy', '%1', '%2-something'],
['subst0', 'subst1', 'subst2']))
- e = execute(error_prefix = 'ERR: ', verbose = True)
+ e = execute(error_prefix = 'ERR: ', output = capture_output, verbose = True)
if sys.platform == "win32":
run_tests(e, commands['windows'], False)
if os.path.exists('c:\\msys\\1.0\\bin\\sh.exe'):
diff --git a/rtemstoolkit/freebsd.py b/rtemstoolkit/freebsd.py
index 11a827f..499d7dd 100644
--- a/rtemstoolkit/freebsd.py
+++ b/rtemstoolkit/freebsd.py
@@ -1,6 +1,6 @@
#
# RTEMS Tools Project (http://www.rtems.org/)
-# Copyright 2010-2014 Chris Johns (chrisj@rtems.org)
+# Copyright 2010-2016 Chris Johns (chrisj@rtems.org)
# All rights reserved.
#
# This file is part of the RTEMS Tools package in 'rtems-tools'.
@@ -36,8 +36,16 @@
import pprint
import os
-import check
-import execute
+#
+# Support to handle use in a package and as a unit test.
+# If there is a better way to let us know.
+#
+try:
+ from . import check
+ from . import execute
+except (ValueError, SystemError):
+ import check
+ import execute
def load():
uname = os.uname()
diff --git a/rtemstoolkit/git.py b/rtemstoolkit/git.py
index 20a1aa6..5f3af58 100644
--- a/rtemstoolkit/git.py
+++ b/rtemstoolkit/git.py
@@ -1,6 +1,6 @@
#
# RTEMS Tools Project (http://www.rtems.org/)
-# Copyright 2010-2015 Chris Johns (chrisj@rtems.org)
+# Copyright 2010-2016 Chris Johns (chrisj@rtems.org)
# All rights reserved.
#
# This file is part of the RTEMS Tools package in 'rtems-tools'.
@@ -31,17 +31,28 @@
import os
-import error
-import execute
-import log
-import options
-import path
+#
+# Support to handle use in a package and as a unit test.
+# If there is a better way to let us know.
+#
+try:
+ from . import error
+ from . import execute
+ from . import log
+ from . import path
+except (ValueError, SystemError):
+ import error
+ import execute
+ import log
+ import path
class repo:
"""An object to manage a git repo."""
- def _git_exit_code(self, ec):
+ def _git_exit_code(self, ec, cmd, output):
if ec:
+ log.notice('git: cmd: ' + ' '.join(cmd))
+ log.notice('git: output: ' + output)
raise error.general('git command failed (%s): %d' % (self.git, ec))
def _run(self, args, check = False):
@@ -55,7 +66,7 @@ class repo:
exit_code, proc, output = e.spawn(cmd, cwd = path.host(cwd))
log.trace(output)
if check:
- self._git_exit_code(exit_code)
+ self._git_exit_code(exit_code, cmd, output)
return exit_code, output
def __init__(self, _path, opts = None, macros = None):
@@ -76,9 +87,11 @@ class repo:
if len(gvs) < 3:
raise error.general('invalid version string from git: %s' % (output))
vs = gvs[2].split('.')
- if len(vs) != 4:
- raise error.general('invalid version number from git: %s' % (gvs[2]))
- return (int(vs[0]), int(vs[1]), int(vs[2]), int(vs[3]))
+ if len(vs) == 4:
+ return (int(vs[0]), int(vs[1]), int(vs[2]), int(vs[3]))
+ if len(vs) == 3:
+ return (int(vs[0]), int(vs[1]), int(vs[2]))
+ raise error.general('invalid version number from git: %s' % (gvs[2]))
def clone(self, url, _path):
ec, output = self._run(['clone', url, path.host(_path)], check = True)
@@ -207,12 +220,19 @@ class repo:
if __name__ == '__main__':
import sys
- opts = options.load(sys.argv)
+ import options
+ long_opts = {
+ # key macro handler param defs init
+ }
+ opts = options.command_line(base_path = '.',
+ argv = sys.argv,
+ long_opts = long_opts)
+ options.load(opts)
g = repo('.', opts)
- print(g.git_version())
- print(g.valid())
- print(g.status())
- print(g.clean())
- print(g.remotes())
- print(g.email())
- print(g.head())
+ print('version:', g.git_version())
+ print('valid:', g.valid())
+ print('status:', g.status())
+ print('dirty:', g.dirty())
+ print('remotes:', g.remotes())
+ print('email:', g.email())
+ print('head:', g.head())
diff --git a/rtemstoolkit/linux.py b/rtemstoolkit/linux.py
index 022bcd0..7aea43e 100644
--- a/rtemstoolkit/linux.py
+++ b/rtemstoolkit/linux.py
@@ -1,6 +1,6 @@
#
# RTEMS Tools Project (http://www.rtems.org/)
-# Copyright 2010-2014 Chris Johns (chrisj@rtems.org)
+# Copyright 2010-2016 Chris Johns (chrisj@rtems.org)
# All rights reserved.
#
# This file is part of the RTEMS Tools package in 'rtems-tools'.
@@ -35,10 +35,18 @@
import pprint
import os
-
import platform
-import execute
-import path
+
+#
+# Support to handle use in a package and as a unit test.
+# If there is a better way to let us know.
+#
+try:
+ from . import execute
+ from . import path
+except (ValueError, SystemError):
+ import execute
+ import path
def load():
uname = os.uname()
@@ -130,7 +138,7 @@ def load():
'__chown': ('exe', 'required', '/usr/sbin/chown') },
}
- if variations.has_key(distro):
+ if distro in variations:
for v in variations[distro]:
if path.exists(variations[distro][v][2]):
defines[v] = variations[distro][v]
diff --git a/rtemstoolkit/log.py b/rtemstoolkit/log.py
index 1308203..61a3b02 100755
--- a/rtemstoolkit/log.py
+++ b/rtemstoolkit/log.py
@@ -1,6 +1,6 @@
#
# RTEMS Tools Project (http://www.rtems.org/)
-# Copyright 2010-2014 Chris Johns (chrisj@rtems.org)
+# Copyright 2010-2016 Chris Johns (chrisj@rtems.org)
# All rights reserved.
#
# This file is part of the RTEMS Tools package in 'rtems-testing'.
@@ -32,11 +32,20 @@
# Log output to stdout and/or a file.
#
+from __future__ import print_function
+
import os
import sys
import threading
-import error
+#
+# Support to handle use in a package and as a unit test.
+# If there is a better way to let us know.
+#
+try:
+ from . import error
+except (ValueError, SystemError):
+ import error
#
# A global log.
@@ -126,7 +135,7 @@ class log:
self.fhs[1] = sys.stderr
else:
try:
- self.fhs.append(file(s, 'w'))
+ self.fhs.append(open(s, 'w'))
except IOError as ioe:
raise error.general("creating log file '" + s + \
"': " + str(ioe))
diff --git a/rtemstoolkit/macros.py b/rtemstoolkit/macros.py
index 632be87..c92a6c9 100644
--- a/rtemstoolkit/macros.py
+++ b/rtemstoolkit/macros.py
@@ -1,6 +1,6 @@
#
# RTEMS Tools Project (http://www.rtems.org/)
-# Copyright 2010-2014 Chris Johns (chrisj@rtems.org)
+# Copyright 2010-2016 Chris Johns (chrisj@rtems.org)
# All rights reserved.
#
# This file is part of the RTEMS Tools package in 'rtems-tools'.
@@ -32,14 +32,24 @@
# Macro tables.
#
+from __future__ import print_function
+
import copy
import inspect
import re
import os
import string
-import error
-import path
+#
+# Support to handle use in a package and as a unit test.
+# If there is a better way to let us know.
+#
+try:
+ from . import error
+ from . import path
+except (ValueError, SystemError):
+ import error
+ import path
#
# Macro tables
@@ -54,7 +64,7 @@ class macros:
def __iter__(self):
return self
- def next(self):
+ def __next__(self):
if self.index < len(self.keys):
key = self.keys[self.index]
self.index += 1
@@ -64,6 +74,19 @@ class macros:
def iterkeys(self):
return self.keys
+ def _unicode_to_str(self, us):
+ try:
+ if type(us) == unicode:
+ return us.encode('ascii', 'replace')
+ except:
+ pass
+ try:
+ if type(us) == bytes:
+ return us.encode('ascii', 'replace')
+ except:
+ pass
+ return us
+
def __init__(self, name = None, original = None, rtdir = '.'):
self.files = []
self.macro_filter = re.compile(r'%{[^}]+}')
@@ -167,12 +190,17 @@ class macros:
def __setitem__(self, key, value):
if type(key) is not str:
raise TypeError('bad key type (want str): %s' % (type(key)))
+ if type(value) is not tuple:
+ value = self._unicode_to_str(value)
if type(value) is str:
value = ('none', 'none', value)
if type(value) is not tuple:
raise TypeError('bad value type (want tuple): %s' % (type(value)))
if len(value) != 3:
raise TypeError('bad value tuple (len not 3): %d' % (len(value)))
+ value = (self._unicode_to_str(value[0]),
+ self._unicode_to_str(value[1]),
+ self._unicode_to_str(value[2]))
if type(value[0]) is not str:
raise TypeError('bad value tuple type field: %s' % (type(value[0])))
if type(value[1]) is not str:
@@ -195,10 +223,10 @@ class macros:
return self.has_key(key)
def __len__(self):
- return len(self.keys())
+ return len(list(self.keys()))
def keys(self):
- keys = self.macros['global'].keys()
+ keys = list(self.macros['global'].keys())
for rm in self.get_read_maps():
for mk in self.macros[rm]:
if self.macros[rm][mk][1] == 'undefine':
@@ -211,7 +239,7 @@ class macros:
def has_key(self, key):
if type(key) is not str:
raise TypeError('bad key type (want str): %s' % (type(key)))
- if self.key_filter(key) not in self.keys():
+ if self.key_filter(key) not in list(self.keys()):
return False
return True
@@ -491,7 +519,7 @@ if __name__ == "__main__":
import copy
import sys
print(inspect.getfile(macros))
- m = macros(name = 'defaults.mc')
+ m = macros()
d = copy.copy(m)
m['test1'] = 'something'
if d.has_key('test1'):
diff --git a/rtemstoolkit/mailer.py b/rtemstoolkit/mailer.py
index e24ed12..7f71d10 100644
--- a/rtemstoolkit/mailer.py
+++ b/rtemstoolkit/mailer.py
@@ -1,6 +1,6 @@
#
# RTEMS Tools Project (http://www.rtems.org/)
-# Copyright 2013-2014 Chris Johns (chrisj@rtems.org)
+# Copyright 2013-2016 Chris Johns (chrisj@rtems.org)
# All rights reserved.
#
# This file is part of the RTEMS Tools package in 'rtems-tools'.
@@ -32,13 +32,24 @@
# Manage emailing results or reports.
#
+from __future__ import print_function
+
import os
import smtplib
import socket
-import error
-import options
-import path
+#
+# Support to handle use in a package and as a unit test.
+# If there is a better way to let us know.
+#
+try:
+ from . import error
+ from . import options
+ from . import path
+except (ValueError, SystemError):
+ import error
+ import options
+ import path
def append_options(opts):
opts['--mail'] = 'Send email report or results.'
diff --git a/rtemstoolkit/netbsd.py b/rtemstoolkit/netbsd.py
new file mode 100644
index 0000000..5883682
--- /dev/null
+++ b/rtemstoolkit/netbsd.py
@@ -0,0 +1,96 @@
+#
+# RTEMS Tools Project (http://www.rtems.org/)
+# Copyright 2010-2016 Chris Johns (chrisj@rtems.org)
+# All rights reserved.
+#
+# This file is part of the RTEMS Tools package in 'rtems-tools'.
+#
+# RTEMS Tools is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# RTEMS Tools is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with RTEMS Tools. If not, see <http://www.gnu.org/licenses/>.
+#
+
+#
+# This code is based on what ever doco about spec files I could find and
+# RTEMS project's spec files.
+#
+
+import pprint
+import os
+
+try:
+ from . import check
+ from . import execute
+except (ValueError, SystemError):
+ import check
+ import execute
+
+def load():
+ uname = os.uname()
+ sysctl = '/sbin/sysctl '
+ e = execute.capture_execution()
+ exit_code, proc, output = e.shell(sysctl + 'hw.ncpu')
+ if exit_code == 0:
+ ncpus = output.split(' ')[1].strip()
+ else:
+ ncpus = '1'
+ if uname[4] == 'amd64':
+ cpu = 'x86_64'
+ else:
+ cpu = uname[4]
+ version = uname[2]
+ if version.find('-') > 0:
+ version = version.split('-')[0]
+ defines = {
+ '_ncpus': ('none', 'none', '1'),
+ '_os': ('none', 'none', 'netbsd'),
+ '_host': ('triplet', 'required', cpu + '-netbsd' + version),
+ '_host_vendor': ('none', 'none', 'pc'),
+ '_host_os': ('none', 'none', 'netbsd'),
+ '_host_os_version': ('none', 'none', version),
+ '_host_cpu': ('none', 'none', cpu),
+ '_host_alias': ('none', 'none', '%{nil}'),
+ '_host_arch': ('none', 'none', cpu),
+ '_usr': ('dir', 'required', '/usr'),
+ '_var': ('dir', 'optional', '/var'),
+ 'optincludes_build': ('none', 'none', '-I/usr/pkg/include -L/usr/pkg/lib'),
+ '__bash': ('exe', 'optional', '/usr/pkg/bin/bash'),
+ '__bison': ('exe', 'required', '/usr/pkg/bin/bison'),
+ '__git': ('exe', 'required', '/usr/pkg/bin/git'),
+ '__svn': ('exe', 'required', '/usr/pkg/bin/svn'),
+ '__xz': ('exe', 'optional', '/usr/pkg/bin/xz'),
+ '__make': ('exe', 'required', 'gmake'),
+ '__patch_opts': ('none', 'none', '-E')
+ }
+
+ defines['_build'] = defines['_host']
+ defines['_build_vendor'] = defines['_host_vendor']
+ defines['_build_os'] = defines['_host_os']
+ defines['_build_cpu'] = defines['_host_cpu']
+ defines['_build_alias'] = defines['_host_alias']
+ defines['_build_arch'] = defines['_host_arch']
+
+ for gv in ['47', '48', '49']:
+ gcc = '%s-portbld-netbsd%s-gcc%s' % (cpu, version, gv)
+ if check.check_exe(gcc, gcc):
+ defines['__cc'] = gcc
+ break
+ for gv in ['47', '48', '49']:
+ gxx = '%s-portbld-netbsd%s-g++%s' % (cpu, version, gv)
+ if check.check_exe(gxx, gxx):
+ defines['__cxx'] = gxx
+ break
+
+ return defines
+
+if __name__ == '__main__':
+ pprint.pprint(load())
diff --git a/rtemstoolkit/options.py b/rtemstoolkit/options.py
index 132445e..8ff9bb2 100644
--- a/rtemstoolkit/options.py
+++ b/rtemstoolkit/options.py
@@ -1,6 +1,6 @@
#
# RTEMS Tools Project (http://www.rtems.org/)
-# Copyright 2010-2014 Chris Johns (chrisj@rtems.org)
+# Copyright 2010-2016 Chris Johns (chrisj@rtems.org)
# All rights reserved.
#
# This file is part of the RTEMS Tools package in 'rtems-tools'.
@@ -32,22 +32,36 @@
# Determine the defaults and load the specific file.
#
+from __future__ import print_function
+
import copy
import glob
import pprint
import re
import os
import string
-
-import error
-import execute
-import git
-import log
-import macros
-import path
import sys
-import version
+#
+# Support to handle use in a package and as a unit test.
+# If there is a better way to let us know.
+#
+try:
+ from . import error
+ from . import execute
+ from . import git
+ from . import log
+ from . import macros
+ from . import path
+ from . import version
+except (ValueError, SystemError):
+ import error
+ import execute
+ import git
+ import log
+ import macros
+ import path
+ import version
basepath = 'tb'
@@ -61,7 +75,7 @@ class command_line(object):
def __init__(self, base_path = None, argv = None, optargs = None,
defaults = None, long_opts = None, long_opts_help = None,
- command_path = None, log_default = None):
+ command_path = '', log_default = None):
if argv is None:
return
@@ -69,7 +83,7 @@ class command_line(object):
global basepath
if long_opts == None:
- raise error.general('No options provided')
+ long_opts = {}
basepath = base_path
@@ -77,6 +91,9 @@ class command_line(object):
raise error.general('log default is a list')
self.log_default = log_default
+ if defaults is None:
+ defaults = macros.macros()
+
self.long_opts = {
# key macro handler param defs init
'--jobs' : ('_jobs', self._lo_jobs, True, 'default', True),
@@ -128,7 +145,7 @@ class command_line(object):
elif long_opts[lo][1] == 'string':
handler = self._lo_string
elif long_opts[lo][1] == 'path':
- hanlder = self._lo_path
+ handler = self._lo_path
elif long_opts[lo][1] == 'jobs':
handler = self._lo_jobs
elif long_opts[lo][1] == 'bool':
@@ -139,9 +156,10 @@ class command_line(object):
raise error.general('invalid option handler: %s: %s' % (lo, long_opts[lo][1]))
self.long_opts[lo] = (long_opts[lo][0], handler, long_opts[lo][2],
long_opts[lo][3], long_opts[lo][4])
- if lo not in long_opts_help:
- raise error.general('no help for option: %s' % (lo))
- self.long_opts_help[lo] = long_opts_help[lo]
+ if long_opts_help is not None:
+ if lo not in long_opts_help:
+ raise error.general('no help for option: %s' % (lo))
+ self.long_opts_help[lo] = long_opts_help[lo]
def __copy__(self):
new = type(self)()
@@ -159,7 +177,7 @@ class command_line(object):
def __str__(self):
def _dict(dd):
s = ''
- ddl = dd.keys()
+ ddl = list(dd.keys())
ddl.sort()
for d in ddl:
s += ' ' + d + ': ' + str(dd[d]) + '\n'
@@ -276,7 +294,7 @@ class command_line(object):
print('%s: [options] [args]' % (self.command_name))
print('RTEMS Tools Project (c) 2012-2015 Chris Johns')
print('Options and arguments:')
- opts = self.long_opts_help.keys()
+ opts = list(self.long_opts_help.keys())
if self.optargs:
opts += self.optargs.keys()
indent = self._help_indent()
@@ -518,6 +536,9 @@ def load(opts):
command line.
"""
+ if not isinstance(opts, command_line):
+ raise error.general('invalid options type passed to options loader')
+
global host_windows
overrides = None
@@ -532,20 +553,41 @@ def load(opts):
uname = os.uname()
try:
if uname[0].startswith('CYGWIN_NT'):
- import windows
+ try:
+ from . import windows
+ except:
+ import windows
overrides = windows.load()
elif uname[0] == 'Darwin':
- import darwin
+ try:
+ from . import darwin
+ except:
+ import darwin
overrides = darwin.load()
elif uname[0] == 'FreeBSD':
- import freebsd
+ try:
+ from . import freebsd
+ except:
+ import freebsd
overrides = freebsd.load()
elif uname[0] == 'NetBSD':
- import netbsd
+ try:
+ from . import netbsd
+ except:
+ import netbsd
overrides = netbsd.load()
elif uname[0] == 'Linux':
- import linux
+ try:
+ from . import linux
+ except:
+ import linux
overrides = linux.load()
+ elif uname[0] == 'SunOS':
+ try:
+ from . import solaris
+ except:
+ import solaris
+ overrides = solaris.load()
except:
raise error.general('failed to load %s host support' % (uname[0]))
else:
diff --git a/rtemstoolkit/path.py b/rtemstoolkit/path.py
index df51005..15dad1b 100644
--- a/rtemstoolkit/path.py
+++ b/rtemstoolkit/path.py
@@ -1,6 +1,6 @@
#
# RTEMS Tools Project (http://www.rtems.org/)
-# Copyright 2010-2014 Chris Johns (chrisj@rtems.org)
+# Copyright 2010-2016 Chris Johns (chrisj@rtems.org)
# All rights reserved.
#
# This file is part of the RTEMS Tools package in 'rtems-tools'.
@@ -34,13 +34,23 @@
# level. This allows macro expansion to work.
#
+from __future__ import print_function
+
import glob
import os
import shutil
import string
-import error
-import log
+#
+# Support to handle use in a package and as a unit test.
+# If there is a better way to let us know.
+#
+try:
+ from . import error
+ from . import log
+except (ValueError, SystemError):
+ import error
+ import log
windows = os.name == 'nt'
diff --git a/rtemstoolkit/solaris.py b/rtemstoolkit/solaris.py
new file mode 100644
index 0000000..397df68
--- /dev/null
+++ b/rtemstoolkit/solaris.py
@@ -0,0 +1,90 @@
+#
+# RTEMS Tools Project (http://www.rtems.org/)
+# Copyright 2010-2016 Chris Johns (chrisj@rtems.org)
+# All rights reserved.
+#
+# This file is part of the RTEMS Tools package in 'rtems-tools'.
+#
+# Permission to use, copy, modify, and/or distribute this software for any
+# purpose with or without fee is hereby granted, provided that the above
+# copyright notice and this permission notice appear in all copies.
+#
+# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+#
+# This code is based on what ever doco about spec files I could find and
+# RTEMS project's spec files.
+#
+
+import pprint
+import os
+
+try:
+ from . import check
+ from . import error
+ from . import execute
+except (ValueError, SystemError):
+ import check
+ import error
+ import execute
+
+def load():
+ uname = os.uname()
+ psrinfo = '/sbin/psrinfo|wc -l'
+ e = execute.capture_execution()
+ exit_code, proc, output = e.shell(psrinfo)
+ if exit_code == 0:
+ ncpus = output
+ else:
+ ncpus = '1'
+ if uname[4] == 'i86pc':
+ cpu = 'i386'
+ else:
+ cpu = uname[4]
+ version = uname[2]
+ if version.find('-') > 0:
+ version = version.split('-')[0]
+ defines = {
+ '_ncpus': ('none', 'none', ncpus),
+ '_os': ('none', 'none', 'solaris'),
+ '_host': ('triplet', 'required', cpu + '-pc-solaris2'),
+ '_host_vendor': ('none', 'none', 'pc'),
+ '_host_os': ('none', 'none', 'solaris'),
+ '_host_os_version': ('none', 'none', version),
+ '_host_cpu': ('none', 'none', cpu),
+ '_host_alias': ('none', 'none', '%{nil}'),
+ '_host_arch': ('none', 'none', cpu),
+ '_usr': ('dir', 'required', '/usr'),
+ '_var': ('dir', 'optional', '/var'),
+ '__bash': ('exe', 'optional', '/usr/bin/bash'),
+ '__bison': ('exe', 'required', '/usr/bin/bison'),
+ '__git': ('exe', 'required', '/usr/bin/git'),
+ '__svn': ('exe', 'required', '/usr/bin/svn'),
+ '__cvs': ('exe', 'required', '/usr/bin/cvs'),
+ '__xz': ('exe', 'optional', '/usr/bin/xz'),
+ '__make': ('exe', 'required', 'gmake'),
+ '__patch_opts': ('none', 'none', '-E'),
+ '__chown': ('exe', 'required', '/usr/bin/chown'),
+ '__install': ('exe', 'required', '/usr/bin/ginstall'),
+ '__cc': ('exe', 'required', '/usr/bin/gcc'),
+ '__cxx': ('exe', 'required', '/usr/bin/g++'),
+ 'with_iconv': ('none', 'none', '0')
+ }
+
+ defines['_build'] = defines['_host']
+ defines['_build_vendor'] = defines['_host_vendor']
+ defines['_build_os'] = defines['_host_os']
+ defines['_build_cpu'] = defines['_host_cpu']
+ defines['_build_alias'] = defines['_host_alias']
+ defines['_build_arch'] = defines['_host_arch']
+
+ return defines
+
+if __name__ == '__main__':
+ pprint.pprint(load())
diff --git a/rtemstoolkit/version.py b/rtemstoolkit/version.py
index f8b8a7b..3af70a3 100644
--- a/rtemstoolkit/version.py
+++ b/rtemstoolkit/version.py
@@ -1,6 +1,6 @@
#
# RTEMS Tools Project (http://www.rtems.org/)
-# Copyright 2010-2015 Chris Johns (chrisj@rtems.org)
+# Copyright 2010-2016 Chris Johns (chrisj@rtems.org)
# All rights reserved.
#
# This file is part of the RTEMS Tools package in 'rtems-tools'.
@@ -33,10 +33,22 @@
# file to the top directory.
#
+from __future__ import print_function
+
import sys
-import error
-import path
+#
+# Support to handle use in a package and as a unit test.
+# If there is a better way to let us know.
+#
+try:
+ from . import error
+ from . import git
+ from . import path
+except (ValueError, SystemError):
+ import error
+ import git
+ import path
#
# Default to an internal string.
@@ -67,7 +79,6 @@ def _load_released_version():
return _released
def _load_git_version():
- import git
global _git
global _version_str
repo = git.repo(_at())
diff --git a/rtemstoolkit/windows.py b/rtemstoolkit/windows.py
index be4e1f6..2c08258 100644
--- a/rtemstoolkit/windows.py
+++ b/rtemstoolkit/windows.py
@@ -1,6 +1,6 @@
#
# RTEMS Tools Project (http://www.rtems.org/)
-# Copyright 2010-2014 Chris Johns (chrisj@rtems.org)
+# Copyright 2010-2016 Chris Johns (chrisj@rtems.org)
# All rights reserved.
#
# This file is part of the RTEMS Tools package in 'rtems-tools'.
@@ -32,11 +32,19 @@
# Windows specific support and overrides.
#
-import error
import pprint
import os
-import execute
+#
+# Support to handle use in a package and as a unit test.
+# If there is a better way to let us know.
+#
+try:
+ from . import error
+ from . import execute
+except (ValueError, SystemError):
+ import error
+ import execute
def load():
# Default to the native Windows Python.
diff --git a/tester/rt/config.py b/tester/rt/config.py
index 444420b..e9bb378 100644
--- a/tester/rt/config.py
+++ b/tester/rt/config.py
@@ -32,6 +32,8 @@
# RTEMS Testing Config
#
+from __future__ import print_function
+
import datetime
import os
import threading
@@ -42,8 +44,8 @@ from rtemstoolkit import execute
from rtemstoolkit import log
from rtemstoolkit import path
-import console
-import gdb
+from . import console
+from . import gdb
timeout = 15
diff --git a/tester/rt/console.py b/tester/rt/console.py
index a6d3161..ca66e66 100644
--- a/tester/rt/console.py
+++ b/tester/rt/console.py
@@ -32,6 +32,8 @@
# RTEMS Testing Consoles
#
+from __future__ import print_function
+
import errno
import os
import threading
@@ -42,7 +44,7 @@ import time
#
if os.name != 'nt':
import fcntl
- import stty
+ from . import stty
else:
fcntl = None
stty = None
diff --git a/tester/rt/gdb.py b/tester/rt/gdb.py
index cbf2c0d..4045f17 100644
--- a/tester/rt/gdb.py
+++ b/tester/rt/gdb.py
@@ -32,8 +32,14 @@
# RTEMS Testing GDB Interface
#
+from __future__ import print_function
+
import os
-import Queue
+try:
+ import Queue
+ queue = Queue
+except ImportError:
+ import queue
import sys
import threading
@@ -42,8 +48,16 @@ from rtemstoolkit import execute
from rtemstoolkit import options
from rtemstoolkit import path
-import console
-import pygdb
+#
+# Support to handle use in a package and as a unit test.
+# If there is a better way to let us know.
+#
+try:
+ from . import console
+ from . import pygdb
+except (ValueError, SystemError):
+ import console
+ import pygdb
#
# The MI parser needs a global lock. It has global objects.
@@ -64,8 +78,8 @@ class gdb(object):
self.bsp_arch = bsp_arch
self.output = None
self.gdb_console = None
- self.input = Queue.Queue()
- self.commands = Queue.Queue()
+ self.input = queue.Queue()
+ self.commands = queue.Queue()
self.process = None
self.state = {}
self.running = False
@@ -139,7 +153,7 @@ class gdb(object):
line = self.input.get(timeout = 0.5)
if self.trace:
print('>>> input: queue=%d' % (self.input.qsize()), line)
- except Queue.Empty:
+ except queue.Empty:
return True
if line is None:
return None
diff --git a/tester/rt/options.py b/tester/rt/options.py
index c49a288..d41b721 100644
--- a/tester/rt/options.py
+++ b/tester/rt/options.py
@@ -32,6 +32,8 @@
# Determine the defaults and load the specific file.
#
+from __future__ import print_function
+
import glob
import pprint
import re
@@ -45,8 +47,7 @@ from rtemstoolkit import log
from rtemstoolkit import macros
from rtemstoolkit import options
from rtemstoolkit import path
-
-import version
+from rtemstoolkit import version
#
# The path for the defaults.
@@ -115,10 +116,10 @@ def run(args):
log.notice('Defaults:')
log.notice(str(_opts.defaults))
except error.general as gerr:
- print(gerr)
+ print(gerr, file = sys.stderr)
sys.exit(1)
except error.internal as ierr:
- print(ierr)
+ print(ierr, file = sys.stderr)
sys.exit(1)
except error.exit:
pass
diff --git a/tester/rt/pygdb/__init__.py b/tester/rt/pygdb/__init__.py
index b52f6f9..00b3364 100644
--- a/tester/rt/pygdb/__init__.py
+++ b/tester/rt/pygdb/__init__.py
@@ -17,5 +17,6 @@
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
all = ['mi_parser']
-from mi_parser import scan
-from mi_parser import process
+from . import mi_parser
+scan = mi_parser.scan
+process = mi_parser.process
diff --git a/tester/rt/pygdb/mi_parser.py b/tester/rt/pygdb/mi_parser.py
index 7ec8e34..dd1d08f 100755
--- a/tester/rt/pygdb/mi_parser.py
+++ b/tester/rt/pygdb/mi_parser.py
@@ -28,10 +28,12 @@
# $Id$
+from __future__ import print_function
import re
import pprint
-import spark
+
+from . import spark
def __private():
class Token:
@@ -190,7 +192,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:
@@ -203,9 +205,9 @@ def __private():
# tuple ::= { result result_list }
node.value = node[1].value
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))
+ for n, v in list(result.items()):
+ if n in node.value:
+ #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] ]
@@ -214,7 +216,7 @@ def __private():
node.value[n] = v
else:
raise Exception('Invalid tuple')
- #print('tuple: %s' % node.value)
+ #print 'tuple: %s' % node.value
def n_list(self, node):
if len(node) == 2:
@@ -230,7 +232,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 +249,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 +259,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 +286,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 +295,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_):
@@ -305,7 +307,7 @@ def __private():
def __repr__(self):
return pprint.pformat(self.__dict__)
- def __nonzero__(self):
+ def __bool__(self):
return len(self.__dict__) > 0
def __getitem__(self, i):
@@ -320,7 +322,7 @@ def __private():
return None
def graft(self, dict_):
- for name, value in dict_.items():
+ for name, value in list(dict_.items()):
name = name.replace('-', '_')
if isinstance(value, dict):
value = GdbDynamicObject(value)
@@ -336,7 +338,7 @@ def __private():
class GdbMiRecord:
def __init__(self, record):
self.result = None
- for name, value in record[0].items():
+ for name, value in list(record[0].items()):
name = name.replace('-', '_')
if name == 'results':
for result in value:
@@ -370,7 +372,7 @@ def process(input):
if __name__ == '__main__':
def main():
def print_tokens(tokens):
- print
+ print()
for token in tokens:
if token.value:
print(token.type + ': ' + token.value)
diff --git a/tester/rt/pygdb/spark.py b/tester/rt/pygdb/spark.py
index 7dc1358..0eac365 100644
--- a/tester/rt/pygdb/spark.py
+++ b/tester/rt/pygdb/spark.py
@@ -19,6 +19,8 @@
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+from __future__ import print_function
+
__version__ = 'SPARK-0.7 (pre-alpha-7)'
import re
@@ -30,8 +32,8 @@ def _namelist(instance):
for c in classlist:
for b in c.__bases__:
classlist.append(b)
- for name in c.__dict__.keys():
- if not namedict.has_key(name):
+ for name in list(c.__dict__.keys()):
+ if name not in namedict:
namelist.append(name)
namedict[name] = 1
return namelist
@@ -42,7 +44,7 @@ class GenericScanner:
self.re = re.compile(pattern, re.VERBOSE|flags)
self.index2func = {}
- for name, number in self.re.groupindex.items():
+ for name, number in list(self.re.groupindex.items()):
self.index2func[number-1] = getattr(self, 't_' + name)
def makeRE(self, name):
@@ -57,7 +59,7 @@ class GenericScanner:
rv.append(self.makeRE(name))
rv.append(self.makeRE('t_default'))
- return string.join(rv, '|')
+ return '|'.join(rv)
def error(self, s, pos):
print("Lexical error at position %s" % pos)
@@ -81,7 +83,7 @@ class GenericScanner:
groups = m.groups()
self.pos = m.end()
for i in range(len(groups)):
- if groups[i] is not None and self.index2func.has_key(i):
+ if groups[i] is not None and i in self.index2func:
self.index2func[i](groups[i])
def t_default(self, s):
@@ -145,14 +147,14 @@ class GenericParser:
changes = 1
while changes:
changes = 0
- for k, v in self.edges.items():
+ for k, v in list(self.edges.items()):
if v is None:
state, sym = k
- if self.states.has_key(state):
+ if state in self.states:
self.goto(state, sym)
changes = 1
rv = self.__dict__.copy()
- for s in self.states.values():
+ for s in list(self.states.values()):
del s.items
del rv['rule2func']
del rv['nullable']
@@ -179,7 +181,7 @@ class GenericParser:
def addRule(self, doc, func, _preprocess=1):
fn = func
- rules = string.split(doc)
+ rules = doc.split()
index = []
for i in range(len(rules)):
@@ -195,7 +197,7 @@ class GenericParser:
if _preprocess:
rule, fn = self.preprocess(rule, func)
- if self.rules.has_key(lhs):
+ if lhs in self.rules:
self.rules[lhs].append(rule)
else:
self.rules[lhs] = [ rule ]
@@ -218,7 +220,7 @@ class GenericParser:
self.nullable = {}
tbd = []
- for rulelist in self.rules.values():
+ for rulelist in list(self.rules.values()):
lhs = rulelist[0][0]
self.nullable[lhs] = 0
for rule in rulelist:
@@ -233,7 +235,7 @@ class GenericParser:
# grammars.
#
for sym in rhs:
- if not self.rules.has_key(sym):
+ if sym not in self.rules:
break
else:
tbd.append(rule)
@@ -267,7 +269,7 @@ class GenericParser:
def makeNewRules(self):
worklist = []
- for rulelist in self.rules.values():
+ for rulelist in list(self.rules.values()):
for rule in rulelist:
worklist.append((rule, 0, 1, rule))
@@ -276,7 +278,7 @@ class GenericParser:
n = len(rhs)
while i < n:
sym = rhs[i]
- if not self.rules.has_key(sym) or \
+ if sym not in self.rules or \
not self.nullable[sym]:
candidate = 0
i = i + 1
@@ -293,7 +295,7 @@ class GenericParser:
if candidate:
lhs = self._NULLABLE+lhs
rule = (lhs, rhs)
- if self.newrules.has_key(lhs):
+ if lhs in self.newrules:
self.newrules[lhs].append(rule)
else:
self.newrules[lhs] = [ rule ]
@@ -320,7 +322,7 @@ class GenericParser:
self.states = { 0: self.makeState0() }
self.makeState(0, self._BOF)
- for i in xrange(len(tokens)):
+ for i in range(len(tokens)):
sets.append([])
if sets[i] == []:
@@ -349,8 +351,8 @@ class GenericParser:
#
return self._NULLABLE == sym[0:len(self._NULLABLE)]
- def skip(self, lhs_rhs, pos=0):
- lhs, rhs = lhs_rhs
+ def skip(self, xxx_todo_changeme, pos=0):
+ (lhs, rhs) = xxx_todo_changeme
n = len(rhs)
while pos < n:
if not self.isnullable(rhs[pos]):
@@ -373,7 +375,7 @@ class GenericParser:
core.sort()
tcore = tuple(core)
- if self.cores.has_key(tcore):
+ if tcore in self.cores:
return self.cores[tcore]
#
# Nope, doesn't exist. Compute it and the associated
@@ -397,13 +399,13 @@ class GenericParser:
nextSym = rhs[pos]
key = (X.stateno, nextSym)
- if not rules.has_key(nextSym):
- if not edges.has_key(key):
+ if nextSym not in rules:
+ if key not in edges:
edges[key] = None
X.T.append(nextSym)
else:
edges[key] = None
- if not predicted.has_key(nextSym):
+ if nextSym not in predicted:
predicted[nextSym] = 1
for prule in rules[nextSym]:
ppos = self.skip(prule)
@@ -427,10 +429,10 @@ class GenericParser:
# need to know the entire set of predicted nonterminals
# to do this without accidentally duplicating states.
#
- core = predicted.keys()
+ core = list(predicted.keys())
core.sort()
tcore = tuple(core)
- if self.cores.has_key(tcore):
+ if tcore in self.cores:
self.edges[(k, None)] = self.cores[tcore]
return k
@@ -441,7 +443,7 @@ class GenericParser:
def goto(self, state, sym):
key = (state, sym)
- if not self.edges.has_key(key):
+ if key not in self.edges:
#
# No transitions from state on sym.
#
@@ -613,7 +615,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)
@@ -632,14 +634,14 @@ class GenericParser:
rule = choices[0]
if len(choices) > 1:
rule = self.ambiguity(choices)
- #print(rule)
+ #print rule
rhs = rule[1]
attr = [None] * len(rhs)
for i in range(len(rhs)-1, -1, -1):
sym = rhs[i]
- if not self.newrules.has_key(sym):
+ if sym not in self.newrules:
if sym != self._BOF:
attr[i] = tokens[k-1]
key = (item, k)
@@ -669,7 +671,7 @@ class GenericParser:
sortlist.append((len(rhs), name))
name2index[name] = i
sortlist.sort()
- list = list(map(lambda a,b: b, sortlist))
+ list = [a_b[1] for a_b in sortlist]
return rules[name2index[self.resolve(list)]]
def resolve(self, list):
@@ -838,11 +840,11 @@ def _dump(tokens, sets, states):
for item in sets[i]:
print('\t', item)
for (lhs, rhs), pos in states[item[0]].items:
- print('\t\t', lhs, '::=',)
- print(string.join(rhs[:pos]),)
- print('.',)
+ print('\t\t', lhs, '::=', end=' ')
+ print(string.join(rhs[:pos]), end=' ')
+ print('.', end=' ')
print(string.join(rhs[pos:]))
if i < len(tokens):
- print
+ print()
print('token', str(tokens[i]))
- print
+ print()
diff --git a/tester/rt/test.py b/tester/rt/test.py
index fee39e3..3e1bb96 100644
--- a/tester/rt/test.py
+++ b/tester/rt/test.py
@@ -28,8 +28,11 @@
# POSSIBILITY OF SUCH DAMAGE.
#
+from __future__ import print_function
+
import copy
import datetime
+import fnmatch
import os
import sys
import threading
@@ -41,12 +44,11 @@ from rtemstoolkit import path
from rtemstoolkit import stacktraces
from rtemstoolkit import version
-import bsps
-import config
-import console
-import options
-import report
-import fnmatch
+from . import bsps
+from . import config
+from . import console
+from . import options
+from . import report
class test(object):
def __init__(self, index, total, report, executable, rtems_tools, bsp, bsp_config, opts):
diff --git a/tester/rt/version.py b/tester/rt/version.py
deleted file mode 100644
index 743d38a..0000000
--- a/tester/rt/version.py
+++ /dev/null
@@ -1,48 +0,0 @@
-#
-# RTEMS Tools Project (http://www.rtems.org/)
-# Copyright 2013-2015 Chris Johns (chrisj@rtems.org)
-# All rights reserved.
-#
-# This file is part of the RTEMS Tools package in 'rtems-tools'.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions are met:
-#
-# 1. Redistributions of source code must retain the above copyright notice,
-# this list of conditions and the following disclaimer.
-#
-# 2. Redistributions in binary form must reproduce the above copyright notice,
-# this list of conditions and the following disclaimer in the documentation
-# and/or other materials provided with the distribution.
-#
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
-# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-# POSSIBILITY OF SUCH DAMAGE.
-#
-
-#
-# Manage paths locally. The internally the path is in Unix or shell format and
-# we convert to the native format when performing operations at the Python
-# level. This allows macro expansion to work.
-#
-
-major = 0
-minor = 3
-revision = 0
-
-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()))
diff --git a/tester/rtems-test b/tester/rtems-test
index 2a2be48..f573fea 100755
--- a/tester/rtems-test
+++ b/tester/rtems-test
@@ -35,9 +35,6 @@ parent = os.path.dirname(base)
rtems = os.path.join(parent, 'share', 'rtems')
sys.path = [parent, rtems, os.path.join(rtems, 'tester')] + sys.path
-import rt.test
-rt.test.run()
-
try:
import rt.test
rt.test.run()