Openembedded Core Discussions
 help / color / mirror / Atom feed
From: "Matthew" <matthew.zeng@windriver.com>
To: Richard Purdie <richard.purdie@linuxfoundation.org>
Cc: <openembedded-core@lists.openembedded.org>
Subject: Re: [PATCHv2] ltp: make copyFrom scp command non-fatal
Date: Wed, 5 Aug 2020 13:57:55 -0400	[thread overview]
Message-ID: <878setht5o.fsf@windriver.com> (raw)
In-Reply-To: <202cd662179307a24cd3c55bbaca2a4b91c48f26.camel@linuxfoundation.org>


Richard Purdie <richard.purdie@linuxfoundation.org> writes:

> On Wed, 2020-08-05 at 13:15 -0400, Mingde (Matthew) Zeng wrote:
>> [YOCTO #13802]
>>
>> Make the scp failure non-fatal so the ltp tests continue to run and
>> the rest of the logs will be available to see afterwards.
>>
>> Signed-off-by: Mingde (Matthew) Zeng <matthew.zeng@windriver.com>
>> ---
>>  meta/lib/oeqa/core/target/ssh.py | 11 +++++++----
>>  1 file changed, 7 insertions(+), 4 deletions(-)
>>
>> diff --git a/meta/lib/oeqa/core/target/ssh.py b/meta/lib/oeqa/core/target/ssh.py
>> index 090b40a814..e891a4bbfa 100644
>> --- a/meta/lib/oeqa/core/target/ssh.py
>> +++ b/meta/lib/oeqa/core/target/ssh.py
>> @@ -50,7 +50,7 @@ class OESSHTarget(OETarget):
>>      def stop(self, **kwargs):
>>          pass
>>
>> -    def _run(self, command, timeout=None, ignore_status=True):
>> +    def _run(self, command, timeout=None, ignore_status=True, ignore_error=False):
>>          """
>>              Runs command in target using SSHProcess.
>>          """
>> @@ -62,8 +62,11 @@ class OESSHTarget(OETarget):
>>                   "" % (status, time.time() - starttime))
>>
>>          if status and not ignore_status:
>> -            raise AssertionError("Command '%s' returned non-zero exit "
>> -                                 "status %d:\n%s" % (command, status, output))
>> +            if ignore_error:
>> +                self.logger.warning("Command '%s' returned non-zero exit status %d:\n%s" % (command, status, output))
>> +            else:
>> +                raise AssertionError("Command '%s' returned non-zero exit "
>> +                                     "status %d:\n%s" % (command, status, output))
>>
>>          return (status, output)
>>
>> @@ -113,7 +116,7 @@ class OESSHTarget(OETarget):
>>          """
>>          remotePath = '%s@%s:%s' % (self.user, self.ip, remoteSrc)
>>          scpCmd = self.scp + [remotePath, localDst]
>> -        return self._run(scpCmd, ignore_status=False)
>> +        return self._run(scpCmd, ignore_error=True)
>>
>>      def copyDirTo(self, localSrc, remoteDst):
>>          """
>
> That isn't what I meant, I mean something like:
>
> diff --git a/meta/lib/oeqa/core/target/ssh.py b/meta/lib/oeqa/core/target/ssh.py
> index 090b40a8143..cbc56f2e0ad 100644
> --- a/meta/lib/oeqa/core/target/ssh.py
> +++ b/meta/lib/oeqa/core/target/ssh.py
> @@ -107,13 +107,16 @@ class OESSHTarget(OETarget):
>              scpCmd = self.scp + [localSrc, remotePath]
>              return self._run(scpCmd, ignore_status=False)
>
> -    def copyFrom(self, remoteSrc, localDst):
> +    def copyFrom(self, remoteSrc, localDst, warn_on_failure=False):
>          """
>              Copy file from target.
>          """
>          remotePath = '%s@%s:%s' % (self.user, self.ip, remoteSrc)
>          scpCmd = self.scp + [remotePath, localDst]
> -        return self._run(scpCmd, ignore_status=False)
> +        (status, output) = self._run(scpCmd, ignore_status=warn_on_failure)
> +        if warn_on_failure and not status:
> +            self.logger.warning("Copy X returned non-zero exit status %d:\n%s" % (XXX, status, output))
> +        return (status, output)
>
>      def copyDirTo(self, localSrc, remoteDst):
>          """
>
> so that we enable this in the specific case og the copy we might accept failure for.

This works too, my implementation is not as specific as this but it still enables warning only when the optional parameter ignore_error=True, which is what I specified in the copyFrom function only.

I'll adjust my patch.

>
> Cheers,
>
> Richard


--
Mingde (Matthew) Zeng

  reply	other threads:[~2020-08-05 17:58 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-05 17:15 [PATCHv2] ltp: make copyFrom scp command non-fatal Matthew
2020-08-05 17:39 ` Richard Purdie
2020-08-05 17:57   ` Matthew [this message]
2020-08-05 17:58   ` Matthew

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=878setht5o.fsf@windriver.com \
    --to=matthew.zeng@windriver.com \
    --cc=openembedded-core@lists.openembedded.org \
    --cc=richard.purdie@linuxfoundation.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox