diff options
author | Chris Johns <chrisj@rtems.org> | 2017-10-23 15:22:34 +1100 |
---|---|---|
committer | Chris Johns <chrisj@rtems.org> | 2017-10-23 15:22:34 +1100 |
commit | 52513610668b02c2c3991c75946aa3ed2995e206 (patch) | |
tree | 2a580dd01199db4a56f84da1813c663e2c897751 | |
parent | 7051ba5b1958b3926cb69b98d0d9f1db384f754f (diff) |
tester: Add an executable file name filter.
The exe filter lets a BSP change the executable file to something
that can be downloaded to the target. For example U-Boot requires the image
format. The tester can now be configured to on-demand generate a specific
image for the target as the tester runs.
-rw-r--r-- | tester/rt/config.py | 68 | ||||
-rw-r--r-- | tester/rt/report.py | 2 | ||||
-rw-r--r-- | tester/rtems/testing/bsps/xilinx_zynq_zedboard.mc | 2 |
3 files changed, 58 insertions, 14 deletions
diff --git a/tester/rt/config.py b/tester/rt/config.py index ea214c3..80defdd 100644 --- a/tester/rt/config.py +++ b/tester/rt/config.py @@ -115,7 +115,7 @@ class file(config.file): raise error.general(msg) return regex - def _target_command(self, command, bsp_arch = None, bsp = None, exe = None): + def _target_command(self, command, bsp_arch = None, bsp = None, exe = None, fexe = None): if self.defined('target_%s_command' % (command)): cmd = self.expand('%%{target_%s_command}' % (command)).strip() if bsp_arch is not None and '@ARCH@' in cmd: @@ -124,10 +124,51 @@ class file(config.file): cmd = cmd.replace('@BSP@', bsp) if exe is not None and '@EXE@' in cmd: cmd = cmd.replace('@EXE@', exe) + if fexe is not None and '@FEXE@' in cmd: + cmd = cmd.replace('@FEXE@', exe) if len(cmd) > 0: rs_proc = execute.capture_execution() ec, proc, output = rs_proc.open(cmd, shell = True) - self._capture_console('target %s: %s: %s' % (command, cmd, output)) + self._capture_console('target %s: %s' % (command, cmd)) + if len(output) > 0: + output = os.linesep.join([' ' + l for l in output.splitlines()]) + self._capture_console(output) + + def _target_exe_filter(self, exe): + if self.defined('target_exe_filter_command'): + f = self.expand('%{target_exe_filter_command}').strip() + # Be like sed and use the first character as the delmiter. + if len(f) > 0: + delimiter = f[0] + pat = '' + repl = '' + repl_not_pat = False + esc = False + for c in f[1:]: + add = True + if not esc and c == '\\': + esc = True + add = False + elif esc: + if c == delimiter: + c = delimiter + else: + c = '\\' + c + esc = False + elif c == delimiter: + if repl_not_pat: + exe = re.sub(r'%s' % (pat), repl, exe) + self._capture_console('target exe filter: find:%s subst:%s -> %s' % \ + (pat, repl, exe)) + return exe + repl_not_pat = True + add = False + if add: + if repl_not_pat: + repl += c + else: + pat += c + raise error.general('invalid exe filter: %s' % (f)) def _output_length(self): self._lock() @@ -217,7 +258,7 @@ class file(config.file): if not self.in_error: if self.console: self.console.open() - self.process.open(executable = data[0], + self.process.open(executable = exe, port = port, output_length = self._output_length, console = self.capture_console, @@ -248,32 +289,33 @@ class file(config.file): exe = self.expand('%{test_executable}') bsp_arch = self.expand('%{bsp_arch}') bsp = self.expand('%{bsp}') - self.report.start(index, total, exe, exe, bsp_arch, bsp) + fexe = self._target_exe_filter(exe) + self.report.start(index, total, exe, fexe, bsp_arch, bsp) if self.index == 1: - self._target_command('on', bsp_arch, bsp, exe) - self._target_command('pretest', bsp_arch, bsp, exe) + self._target_command('on', bsp_arch, bsp, exe, fexe) + self._target_command('pretest', bsp_arch, bsp, exe, fexe) finally: self._unlock() if _directive == '%execute': - self._dir_execute(ds, total, index, exe, bsp_arch, bsp) + self._dir_execute(ds, total, index, fexe, bsp_arch, bsp) elif _directive == '%gdb': - self._dir_gdb(ds, total, index, exe, bsp_arch, bsp) + self._dir_gdb(ds, total, index, fexe, bsp_arch, bsp) elif _directive == '%tftp': - self._dir_tftp(ds, total, index, exe, bsp_arch, bsp) + self._dir_tftp(ds, total, index, fexe, bsp_arch, bsp) else: raise error.general(self._name_line_msg('invalid directive')) self._lock() if self.index == self.total: - self._target_command('off', bsp_arch, bsp, exe) - self._target_command('posttest', bsp_arch, bsp, exe) + self._target_command('off', bsp_arch, bsp, exe, fexe) + self._target_command('posttest', bsp_arch, bsp, exe, fexe) try: status = self.report.end(exe, self.output) self._capture_console('test result: %s' % (status)) if status == 'timeout': if self.index == self.total: - self._target_command('off', bsp_arch, bsp, exe) + self._target_command('off', bsp_arch, bsp, exe, fexe) else: - self._target_command('reset', bsp_arch, bsp, exe) + self._target_command('reset', bsp_arch, bsp, exe, fexe) self.process = None self.output = None finally: diff --git a/tester/rt/report.py b/tester/rt/report.py index b4a124e..03a2a47 100644 --- a/tester/rt/report.py +++ b/tester/rt/report.py @@ -90,7 +90,7 @@ class report(object): len(str(total)), self.invalids, bsp_arch, bsp, - path.basename(executable)) + path.basename(name)) self.lock.acquire() if name in self.results: self.lock.release() diff --git a/tester/rtems/testing/bsps/xilinx_zynq_zedboard.mc b/tester/rtems/testing/bsps/xilinx_zynq_zedboard.mc index cf5830c..af10810 100644 --- a/tester/rtems/testing/bsps/xilinx_zynq_zedboard.mc +++ b/tester/rtems/testing/bsps/xilinx_zynq_zedboard.mc @@ -53,6 +53,8 @@ jobs: none, none, '1' xilinx_zynq_zedboard: none, none, '%{_rtscripts}/tftp.cfg' xilinx_zynq_zedboard_arch: none, none, 'arm' test_restarts: none, none, '3' +target_pretest_command: none, none, 'rtems-zynq-mkimg @EXE@' +target_exe_filter_command: none, none, '/\.exe/.exe.img/' target_on_command: none, none, 'wemo-reset CSEng1 0 && sleep 4 && wemo-reset CSEng1 -1' target_off_command: none, none, 'wemo-reset CSEng1 0' target_reset_command: none, none, 'wemo-reset CSEng1 3' |