diff options
author | Mariano Lopez <mariano.lopez@linux.intel.com> | 2015-08-24 20:25:46 -0500 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2015-08-30 12:34:40 +0100 |
commit | 384927eb8d52bc5f14c63c8421aa62ee859587f0 (patch) | |
tree | 01ef92ce5698d2a6337f2f2082436a144be564b0 /meta/lib | |
parent | ad10af6be343b5425fde43055263b0744c161cb3 (diff) | |
download | openembedded-core-384927eb8d52bc5f14c63c8421aa62ee859587f0.tar.gz openembedded-core-384927eb8d52bc5f14c63c8421aa62ee859587f0.tar.bz2 openembedded-core-384927eb8d52bc5f14c63c8421aa62ee859587f0.zip |
dump: allow to have datastore vars on dump commands
This allows to have datastore variables in the dump
commands and will get the data when a new instance
it's created.
Also this remove special cases from the commands.
[YOCTO #8118]
Signed-off-by: Mariano Lopez <mariano.lopez@linux.intel.com>
Diffstat (limited to 'meta/lib')
-rw-r--r-- | meta/lib/oeqa/utils/dump.py | 42 |
1 files changed, 26 insertions, 16 deletions
diff --git a/meta/lib/oeqa/utils/dump.py b/meta/lib/oeqa/utils/dump.py index a0fa699a27..a76aede8c3 100644 --- a/meta/lib/oeqa/utils/dump.py +++ b/meta/lib/oeqa/utils/dump.py @@ -11,8 +11,24 @@ def get_host_dumper(d): class BaseDumper(object): - def __init__(self, d): + def __init__(self, d, cmds): + self.cmds = [] self.parent_dir = d.getVar("TESTIMAGE_DUMP_DIR", True) + for cmd in cmds.split('\n'): + cmd = cmd.lstrip() + if not cmd or cmd[0] == '#': + continue + # Replae variables from the datastore + while True: + index_start = cmd.find("${") + if index_start == -1: + break + index_start += 2 + index_end = cmd.find("}", index_start) + var = cmd[index_start:index_end] + value = d.getVar(var, True) + cmd = cmd.replace("${%s}" % var, value) + self.cmds.append(cmd) def create_dir(self, dir_suffix): dump_subdir = ("%s_%s" % ( @@ -26,7 +42,7 @@ class BaseDumper(object): raise err self.dump_dir = dump_dir - def write_dump(self, command, output): + def _write_dump(self, command, output): if isinstance(self, HostDumper): prefix = "host" elif isinstance(self, TargetDumper): @@ -45,33 +61,27 @@ class BaseDumper(object): class HostDumper(BaseDumper): def __init__(self, d): - super(HostDumper, self).__init__(d) - self.host_cmds = d.getVar("testimage_dump_host", True) + host_cmds = d.getVar("testimage_dump_host", True) + super(HostDumper, self).__init__(d, host_cmds) def dump_host(self, dump_dir=""): if dump_dir: self.dump_dir = dump_dir - for cmd in self.host_cmds.split('\n'): - cmd = cmd.lstrip() - if not cmd or cmd[0] == '#': - continue + for cmd in self.cmds: result = runCmd(cmd, ignore_status=True) - self.write_dump(cmd.split()[0], result.output) + self._write_dump(cmd.split()[0], result.output) class TargetDumper(BaseDumper): def __init__(self, d, qemurunner): - super(TargetDumper, self).__init__(d) - self.target_cmds = d.getVar("testimage_dump_target", True) + target_cmds = d.getVar("testimage_dump_target", True) + super(TargetDumper, self).__init__(d, target_cmds) self.runner = qemurunner def dump_target(self, dump_dir=""): if dump_dir: self.dump_dir = dump_dir - for cmd in self.target_cmds.split('\n'): - cmd = cmd.lstrip() - if not cmd or cmd[0] == '#': - continue + for cmd in self.cmds: (status, output) = self.runner.run_serial(cmd) - self.write_dump(cmd.split()[0], output) + self._write_dump(cmd.split()[0], output) |