summaryrefslogtreecommitdiffstats
path: root/meta/lib
diff options
context:
space:
mode:
authorMariano Lopez <mariano.lopez@linux.intel.com>2015-08-24 20:25:46 -0500
committerRichard Purdie <richard.purdie@linuxfoundation.org>2015-08-30 12:36:13 +0100
commitc78ba0d4f072e1606e9934823138d9302cc49ab8 (patch)
tree50a55070c1f5c691bc3f5648bc559d183d841cd4 /meta/lib
parent85fd1a7a121daffc3c5c530930f832ecc61ef83d (diff)
downloadpoky-c78ba0d4f072e1606e9934823138d9302cc49ab8.tar.gz
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] (From OE-Core rev: 384927eb8d52bc5f14c63c8421aa62ee859587f0) Signed-off-by: Mariano Lopez <mariano.lopez@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib')
-rw-r--r--meta/lib/oeqa/utils/dump.py42
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):
11 11
12class BaseDumper(object): 12class BaseDumper(object):
13 13
14 def __init__(self, d): 14 def __init__(self, d, cmds):
15 self.cmds = []
15 self.parent_dir = d.getVar("TESTIMAGE_DUMP_DIR", True) 16 self.parent_dir = d.getVar("TESTIMAGE_DUMP_DIR", True)
17 for cmd in cmds.split('\n'):
18 cmd = cmd.lstrip()
19 if not cmd or cmd[0] == '#':
20 continue
21 # Replae variables from the datastore
22 while True:
23 index_start = cmd.find("${")
24 if index_start == -1:
25 break
26 index_start += 2
27 index_end = cmd.find("}", index_start)
28 var = cmd[index_start:index_end]
29 value = d.getVar(var, True)
30 cmd = cmd.replace("${%s}" % var, value)
31 self.cmds.append(cmd)
16 32
17 def create_dir(self, dir_suffix): 33 def create_dir(self, dir_suffix):
18 dump_subdir = ("%s_%s" % ( 34 dump_subdir = ("%s_%s" % (
@@ -26,7 +42,7 @@ class BaseDumper(object):
26 raise err 42 raise err
27 self.dump_dir = dump_dir 43 self.dump_dir = dump_dir
28 44
29 def write_dump(self, command, output): 45 def _write_dump(self, command, output):
30 if isinstance(self, HostDumper): 46 if isinstance(self, HostDumper):
31 prefix = "host" 47 prefix = "host"
32 elif isinstance(self, TargetDumper): 48 elif isinstance(self, TargetDumper):
@@ -45,33 +61,27 @@ class BaseDumper(object):
45class HostDumper(BaseDumper): 61class HostDumper(BaseDumper):
46 62
47 def __init__(self, d): 63 def __init__(self, d):
48 super(HostDumper, self).__init__(d) 64 host_cmds = d.getVar("testimage_dump_host", True)
49 self.host_cmds = d.getVar("testimage_dump_host", True) 65 super(HostDumper, self).__init__(d, host_cmds)
50 66
51 def dump_host(self, dump_dir=""): 67 def dump_host(self, dump_dir=""):
52 if dump_dir: 68 if dump_dir:
53 self.dump_dir = dump_dir 69 self.dump_dir = dump_dir
54 for cmd in self.host_cmds.split('\n'): 70 for cmd in self.cmds:
55 cmd = cmd.lstrip()
56 if not cmd or cmd[0] == '#':
57 continue
58 result = runCmd(cmd, ignore_status=True) 71 result = runCmd(cmd, ignore_status=True)
59 self.write_dump(cmd.split()[0], result.output) 72 self._write_dump(cmd.split()[0], result.output)
60 73
61 74
62class TargetDumper(BaseDumper): 75class TargetDumper(BaseDumper):
63 76
64 def __init__(self, d, qemurunner): 77 def __init__(self, d, qemurunner):
65 super(TargetDumper, self).__init__(d) 78 target_cmds = d.getVar("testimage_dump_target", True)
66 self.target_cmds = d.getVar("testimage_dump_target", True) 79 super(TargetDumper, self).__init__(d, target_cmds)
67 self.runner = qemurunner 80 self.runner = qemurunner
68 81
69 def dump_target(self, dump_dir=""): 82 def dump_target(self, dump_dir=""):
70 if dump_dir: 83 if dump_dir:
71 self.dump_dir = dump_dir 84 self.dump_dir = dump_dir
72 for cmd in self.target_cmds.split('\n'): 85 for cmd in self.cmds:
73 cmd = cmd.lstrip()
74 if not cmd or cmd[0] == '#':
75 continue
76 (status, output) = self.runner.run_serial(cmd) 86 (status, output) = self.runner.run_serial(cmd)
77 self.write_dump(cmd.split()[0], output) 87 self._write_dump(cmd.split()[0], output)