[rtems-tools commit] tester: Add a tester off to turn the target off when finished.

Chris Johns chrisj at rtems.org
Tue Oct 10 02:33:06 UTC 2017


Module:    rtems-tools
Branch:    master
Commit:    662e1f7d9adb8b0e98af20f5bd01f954efc4207b
Changeset: http://git.rtems.org/rtems-tools/commit/?id=662e1f7d9adb8b0e98af20f5bd01f954efc4207b

Author:    Chris Johns <chrisj at rtems.org>
Date:      Tue Oct 10 13:30:31 2017 +1100

tester: Add a tester off to turn the target off when finished.

Turning the target off stops it sitting asking for a download if you have
more than one target in a test set up. Any target can jump in and
nick the download.

---

 tester/rt/config.py | 30 ++++++++++++++++++++----------
 tester/rt/test.py   |  2 +-
 2 files changed, 21 insertions(+), 11 deletions(-)

diff --git a/tester/rt/config.py b/tester/rt/config.py
index 5aadc61..9bfb7ae 100644
--- a/tester/rt/config.py
+++ b/tester/rt/config.py
@@ -59,7 +59,7 @@ class file(config.file):
                    '%tftp',
                    '%console']
 
-    def __init__(self, index, report, name, opts, _directives = _directives):
+    def __init__(self, index, total, report, name, opts, _directives = _directives):
         super(file, self).__init__(name, opts, directives = _directives)
         self.lock = threading.Lock()
         self.realtime_trace = self.debug_trace('output')
@@ -67,6 +67,7 @@ class file(config.file):
         self.console = None
         self.output = None
         self.index = index
+        self.total = total
         self.report = report
         self.name = name
         self.timedout = False
@@ -114,13 +115,13 @@ class file(config.file):
                 raise error.general(msg)
         return regex
 
-    def _target_reset(self):
-        if self.defined('target_reset_command'):
-            reset_cmd = self.expand('%{target_reset_command}').strip()
-            if len(reset_cmd) > 0:
+    def _target_command(self, command):
+        if self.defined('target_%s_command' % (command)):
+            cmd = self.expand('%%{target_%s_command}' % (command)).strip()
+            if len(cmd) > 0:
                 rs_proc = execute.capture_execution()
-                ec, proc, output = rs_proc.open(reset_cmd, shell = True)
-                self._capture_console('target reset: %s: %s' % (reset_cmd, output))
+                ec, proc, output = rs_proc.open(cmd, shell = True)
+                self._capture_console('target %s: %s: %s' % (command, cmd, output))
 
     def _output_length(self):
         self._lock()
@@ -243,7 +244,7 @@ class file(config.file):
                     bsp = self.expand('%{bsp}')
                     self.report.start(index, total, exe, exe, bsp_arch, bsp)
                     if self.index == 1:
-                        self._target_reset()
+                        self._target_command('reset')
                 finally:
                     self._unlock()
                 if _directive == '%execute':
@@ -255,10 +256,16 @@ class file(config.file):
                 else:
                     raise error.general(self._name_line_msg('invalid directive'))
                 self._lock()
+                if self.index == self.total:
+                    self._target_command('off')
                 try:
                     status = self.report.end(exe, self.output)
+                    self._capture_console('test result: %s' % (status))
                     if status == 'timeout':
-                        self._target_reset()
+                        if self.index == self.total:
+                            self._target_command('off')
+                        else:
+                            self._target_command('reset')
                     self.process = None
                     self.output = None
                 finally:
@@ -309,7 +316,10 @@ class file(config.file):
             self._realtime_trace(text)
             self.output += text
         if reset_target:
-            self._target_reset()
+            if self.index == self.total:
+                self._target_command('off')
+            else:
+                self._target_command('reset')
         self._unlock()
         if ok_to_kill:
             self._ok_kill()
diff --git a/tester/rt/test.py b/tester/rt/test.py
index c3d8069..8a1eb9c 100644
--- a/tester/rt/test.py
+++ b/tester/rt/test.py
@@ -72,7 +72,7 @@ class test(object):
             if not path.isdir(rtems_tools_bin):
                 raise error.general('cannot find RTEMS tools path: %s' % (rtems_tools_bin))
             self.opts.defaults['rtems_tools'] = rtems_tools_bin
-        self.config = config.file(index, self.report, self.bsp_config, self.opts)
+        self.config = config.file(index, total, self.report, self.bsp_config, self.opts)
 
     def run(self):
         if self.config:



More information about the vc mailing list