summaryrefslogtreecommitdiffstats
path: root/tester/rt
diff options
context:
space:
mode:
authorChris Johns <chrisj@rtems.org>2018-11-07 14:55:20 +1100
committerChris Johns <chrisj@rtems.org>2018-11-08 18:13:45 +1100
commite058db02816d7729e7cfa898522a6073f5d7e714 (patch)
treeaa70574c9b277224be596553881e75fc3924111c /tester/rt
parentrtemstoolkit: Fix the parsing of the revision string to a number. (diff)
downloadrtems-tools-e058db02816d7729e7cfa898522a6073f5d7e714.tar.bz2
python: Provide support to select a valid python version.
- Update imports after wrapping the code. - Fix python3 issues. - Fix config path issues for in repo and install runs. Closes #3537
Diffstat (limited to 'tester/rt')
-rwxr-xr-xtester/rt/check.py19
-rwxr-xr-xtester/rt/cmd-bsp-builder.py45
-rwxr-xr-xtester/rt/cmd-run.py44
-rwxr-xr-xtester/rt/cmd-test.py45
-rw-r--r--tester/rt/config.py6
-rw-r--r--tester/rt/console.py7
-rw-r--r--tester/rt/coverage.py2
-rw-r--r--tester/rt/gdb.py12
-rw-r--r--tester/rt/run.py19
-rw-r--r--tester/rt/stty.py2
-rw-r--r--tester/rt/test.py16
-rw-r--r--tester/rt/tftp.py9
12 files changed, 173 insertions, 53 deletions
diff --git a/tester/rt/check.py b/tester/rt/check.py
index f2addbd..f81ee70 100755
--- a/tester/rt/check.py
+++ b/tester/rt/check.py
@@ -971,7 +971,7 @@ class builder:
cmd = [path.join(self.rtems, 'configure')]
for c in cmds:
c = c.replace('@PREFIX@', self.prefix)
- c = c.replace('@RTEMS_VERSION@', self.rtems_version)
+ c = c.replace('@RTEMS_VERSION@', str(self.rtems_version))
c = c.replace('@ARCH@', build.arch)
c = c.replace('@BSP@', build.bsp)
cmd += [c]
@@ -1118,7 +1118,7 @@ class builder:
log.notice('Profile(s): %s' % (', '.join(profiles)))
self.run_jobs(self.profile_jobs(profiles))
-def run_args(args):
+def run(args):
b = None
ec = 0
try:
@@ -1129,9 +1129,15 @@ def run_args(args):
tools = prefix
build_dir = 'bsp-builds'
logf = 'bsp-build-%s.txt' % (_now().strftime('%Y%m%d-%H%M%S'))
- config_file = rtems.bsp_configuration_file()
+ config_file = rtems.bsp_configuration_file(prog = args[0])
- argsp = argparse.ArgumentParser()
+ description = 'RTEMS BSP Builder is a BSP build tester. It builds BSPs '
+ description += 'in various ways to test build regressions in the kernel. You '
+ description += 'can build based on tier, architecture, or BSP. You can control '
+ description += 'the profile of build with various build configuration settings.'
+
+ argsp = argparse.ArgumentParser(prog = 'rtems-bsp-builder',
+ description = description)
argsp.add_argument('--prefix', help = 'Prefix to build the BSP.',
type = str)
argsp.add_argument('--rtems-tools', help = 'The RTEMS tools directory.',
@@ -1297,8 +1303,5 @@ def run_args(args):
b.results.report()
sys.exit(ec)
-def run():
- run_args(sys.argv)
-
if __name__ == "__main__":
- run()
+ run(sys.argv)
diff --git a/tester/rt/cmd-bsp-builder.py b/tester/rt/cmd-bsp-builder.py
new file mode 100755
index 0000000..c94aeaf
--- /dev/null
+++ b/tester/rt/cmd-bsp-builder.py
@@ -0,0 +1,45 @@
+#! /usr/bin/env python
+#
+# RTEMS Tools Project (http://www.rtems.org/)
+# Copyright 2016 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.
+#
+
+from __future__ import print_function
+
+import sys, os
+
+base = os.path.dirname(os.path.dirname(os.path.abspath(sys.argv[0])))
+rtems = os.path.dirname(base)
+sys.path = [rtems] + sys.path
+
+try:
+ import check
+ check.run(sys.argv[1:])
+except ImportError:
+ print("Incorrect RTEMS Tools installation", file = sys.stderr)
+ sys.exit(1)
diff --git a/tester/rt/cmd-run.py b/tester/rt/cmd-run.py
new file mode 100755
index 0000000..221c3f8
--- /dev/null
+++ b/tester/rt/cmd-run.py
@@ -0,0 +1,44 @@
+#
+# RTEMS Tools Project (http://www.rtems.org/)
+# Copyright 2017 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.
+#
+
+from __future__ import print_function
+
+import sys, os
+
+base = os.path.dirname(os.path.dirname(os.path.abspath(sys.argv[0])))
+rtems = os.path.dirname(base)
+sys.path = [rtems] + sys.path
+
+try:
+ import run
+ run.run(sys.argv[1:], command_path = base)
+except ImportError:
+ print("Incorrect RTEMS Tools installation", file = sys.stderr)
+ sys.exit(1)
diff --git a/tester/rt/cmd-test.py b/tester/rt/cmd-test.py
new file mode 100755
index 0000000..93e480f
--- /dev/null
+++ b/tester/rt/cmd-test.py
@@ -0,0 +1,45 @@
+#! /usr/bin/env python
+#
+# 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.
+#
+
+from __future__ import print_function
+
+import sys, os
+
+base = os.path.dirname(os.path.dirname(os.path.abspath(sys.argv[0])))
+rtems = os.path.dirname(base)
+sys.path = [rtems] + sys.path
+
+try:
+ import test
+ test.run(sys.argv[1:], command_path = base)
+except ImportError:
+ print("Incorrect RTEMS Tools installation", file = sys.stderr)
+ sys.exit(1)
diff --git a/tester/rt/config.py b/tester/rt/config.py
index 1c2670a..448581f 100644
--- a/tester/rt/config.py
+++ b/tester/rt/config.py
@@ -46,9 +46,9 @@ from rtemstoolkit import execute
from rtemstoolkit import log
from rtemstoolkit import path
-from . import console
-from . import gdb
-from . import tftp
+import console
+import gdb
+import tftp
timeout = 15
diff --git a/tester/rt/console.py b/tester/rt/console.py
index 0545ace..ef35a0e 100644
--- a/tester/rt/console.py
+++ b/tester/rt/console.py
@@ -41,13 +41,13 @@ import time
from rtemstoolkit import path
-from . import telnet
+import telnet
#
# Not available on Windows. Not sure what this means.
#
if os.name != 'nt':
- from . import stty
+ import stty
else:
stty = None
@@ -107,6 +107,9 @@ class tty(console):
time.sleep(0.05)
try:
data = me.tty.read()
+ if isinstance(data, bytes):
+ data = data.decode('utf-8', 'ignore')
+ data = [c for c in data if ord(c) < 128]
except IOError as ioe:
if ioe.errno == errno.EAGAIN:
continue
diff --git a/tester/rt/coverage.py b/tester/rt/coverage.py
index 978a8c4..cd5c501 100644
--- a/tester/rt/coverage.py
+++ b/tester/rt/coverage.py
@@ -47,7 +47,7 @@ from rtemstoolkit import execute
from rtemstoolkit import macros
-from . import options
+import options
class summary:
def __init__(self, p_summary_dir):
diff --git a/tester/rt/gdb.py b/tester/rt/gdb.py
index 1669693..2416a50 100644
--- a/tester/rt/gdb.py
+++ b/tester/rt/gdb.py
@@ -48,16 +48,8 @@ from rtemstoolkit import execute
from rtemstoolkit import options
from rtemstoolkit 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 console
- from . import pygdb
-except (ValueError, SystemError):
- import console
- import pygdb
+import console
+import pygdb
#
# The MI parser needs a global lock. It has global objects.
diff --git a/tester/rt/run.py b/tester/rt/run.py
index 1f4fa3a..ff95091 100644
--- a/tester/rt/run.py
+++ b/tester/rt/run.py
@@ -32,12 +32,8 @@ from __future__ import print_function
import copy
import datetime
-import fnmatch
-import os
-import re
import sys
import threading
-import time
from rtemstoolkit import error
from rtemstoolkit import host
@@ -46,11 +42,11 @@ from rtemstoolkit import path
from rtemstoolkit import stacktraces
from rtemstoolkit import version
-from . import bsps
-from . import config
-from . import console
-from . import options
-from . import report
+import bsps
+import config
+import console
+import options
+import report
class test(object):
def __init__(self, index, total, report, executable, rtems_tools, bsp, bsp_config, opts):
@@ -98,8 +94,7 @@ def list_bsps(opts):
log.notice(' %s' % (path.basename(bsp[:-3])))
raise error.exit()
-def run(command_path = None):
- import sys
+def run(args, command_path = None):
tests = []
stdtty = console.save()
opts = None
@@ -111,7 +106,7 @@ def run(command_path = None):
'--list-bsps': 'List the supported BSPs',
'--debug-trace': 'Debug trace based on specific flags',
'--stacktrace': 'Dump a stack trace on a user termination (^C)' }
- opts = options.load(sys.argv,
+ opts = options.load(args,
optargs = optargs,
command_path = command_path)
log.notice('RTEMS Testing - Run, %s' % (version.string()))
diff --git a/tester/rt/stty.py b/tester/rt/stty.py
index b393dbf..130318d 100644
--- a/tester/rt/stty.py
+++ b/tester/rt/stty.py
@@ -58,7 +58,7 @@ def restore(attributes):
termios.tcsetattr(sys.stdout, termios.TCSANOW, attributes[1])
termios.tcsetattr(sys.stderr, termios.TCSANOW, attributes[2])
-class tty:
+class tty(object):
raw = 'B115200,~BRKINT,IGNBRK,IGNCR,~ICANON,~ISIG,~IEXTEN,~ECHO,CLOCAL,~CRTSCTS'
diff --git a/tester/rt/test.py b/tester/rt/test.py
index c5d61d8..13c1e6e 100644
--- a/tester/rt/test.py
+++ b/tester/rt/test.py
@@ -50,12 +50,12 @@ from rtemstoolkit import stacktraces
from rtemstoolkit import version
from rtemstoolkit import check
-from . import bsps
-from . import config
-from . import console
-from . import options
-from . import report
-from . import coverage
+import bsps
+import config
+import console
+import options
+import report
+import coverage
class log_capture(object):
def __init__(self):
@@ -216,7 +216,7 @@ def killall(tests):
for test in tests:
test.kill()
-def run(command_path = None):
+def run(args, command_path = None):
import sys
tests = []
stdtty = console.save()
@@ -234,7 +234,7 @@ def run(command_path = None):
'--stacktrace': 'Dump a stack trace on a user termination (^C)',
'--coverage': 'Perform coverage analysis of test executables.'}
mailer.append_options(optargs)
- opts = options.load(sys.argv,
+ opts = options.load(args,
optargs = optargs,
command_path = command_path)
mail = None
diff --git a/tester/rt/tftp.py b/tester/rt/tftp.py
index 243f9b3..52deabc 100644
--- a/tester/rt/tftp.py
+++ b/tester/rt/tftp.py
@@ -43,14 +43,7 @@ import sys
from rtemstoolkit import error
from rtemstoolkit import reraise
-#
-# 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 tftpy
-except (ValueError, SystemError):
- import tftpy
+import tftpy
class tftp(object):
'''RTEMS Testing TFTP base.'''