All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mariano Lopez <mariano.lopez@linux.intel.com>
To: benjamin.esquivel@linux.intel.com,
	 openembedded-core@lists.openembedded.org
Subject: Re: [PATCH 3/4 v2] dump: allow to have datastore vars on dump commands
Date: Tue, 25 Aug 2015 17:03:53 -0500	[thread overview]
Message-ID: <55DCE649.70603@linux.intel.com> (raw)
In-Reply-To: <1440531859.15187.42.camel@linux.intel.com>



On 08/25/2015 02:44 PM, Benjamin Esquivel wrote:
> Hi Mariano, please find my comments below.
>
> On Tue, 2015-08-25 at 10:55 -0500, mariano.lopez@linux.intel.com wrote:
>> From: Mariano Lopez <mariano.lopez@linux.intel.com>
>>
>> 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>
>> ---
>>   meta/classes/testimage.bbclass |  7 +++++--
>>   meta/lib/oeqa/utils/dump.py    | 42 ++++++++++++++++++++++++++------
>> ----------
>>   2 files changed, 31 insertions(+), 18 deletions(-)
>>
>> diff --git a/meta/classes/testimage.bbclass
>> b/meta/classes/testimage.bbclass
>> index 2131869..6a4b80a 100644
>> --- a/meta/classes/testimage.bbclass
>> +++ b/meta/classes/testimage.bbclass
>> @@ -63,11 +63,14 @@ testimage_dump_target () {
>>       ps
>>       free
>>       df
>> -    _ping
>> +    # The next command will export the default gateway IP
>> +    export DEFAULT_GATEWAY=$(ip route | awk '/default/ { print $3}')
>> +    ping -c3 $DEFAULT_GATEWAY
>>       dmesg
>>       netstat -an
>>       ip address
>> -    _logs
>> +    # Next command will dump logs from /var/log/
> suggestion to make this a function and call it from here.

It would be possible to add a bitbake var with the code.

>> +    find /var/log/ -type f 2>/dev/null -exec echo
>> "====================" \; -exec echo {} \; -exec echo
>> "====================" \; -exec cat {} \; -exec echo "" \;
>>   }
>>   
>>   testimage_dump_host () {
>> diff --git a/meta/lib/oeqa/utils/dump.py
>> b/meta/lib/oeqa/utils/dump.py
>> index a0fa699..a76aede 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
> *Replace
>> +            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):
>>   
> Wondering why there is not a base class Dumper that inherits to
> TargetDumper and HostDumper

It is there, it's called 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)
>> -- 
>> 1.9.1
>>

-- 
Mariano Lopez


  reply	other threads:[~2015-08-25 22:03 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-25 15:55 [PATCH 0/4 v2] Get dumps when qemu fails mariano.lopez
2015-08-25 15:55 ` [PATCH 1/4 v2] dump: Created new classes for dump host and target mariano.lopez
2015-08-25 15:55 ` [PATCH 2/4 v2] qemurunner: Added host dumps when there are errors mariano.lopez
2015-08-25 15:55 ` [PATCH 3/4 v2] dump: allow to have datastore vars on dump commands mariano.lopez
2015-08-25 19:44   ` Benjamin Esquivel
2015-08-25 22:03     ` Mariano Lopez [this message]
2015-08-25 15:55 ` [PATCH 4/4 v2] oetest: Fix regression when testing real hardware mariano.lopez
2015-08-25 19:24 ` [PATCH 0/4 v2] Get dumps when qemu fails Benjamin Esquivel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=55DCE649.70603@linux.intel.com \
    --to=mariano.lopez@linux.intel.com \
    --cc=benjamin.esquivel@linux.intel.com \
    --cc=openembedded-core@lists.openembedded.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.