Skip to contentSkip to conversation

ltp: make copyFrom scp command non-fatal

PATCH Superseded Matthew 3 participants 6 messages Aug 5, 2020

v3 of 5 Superseded Latest is v5 →

lore
Share & tools
lore

Matthew

author
#0 lore raw

PATCH v3 1/1 ltp: make copyFrom scp command non-fatal

[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.

---
 meta/lib/oeqa/core/target/ssh.py   | 7 +++++--
 meta/lib/oeqa/runtime/cases/ltp.py | 2 +-
 2 files changed, 6 insertions(+), 3 deletions(-)
meta/lib/oeqa/core/target/ssh.py +5 -2
index 090b40a814..aefb576805 100644
@@ -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 status:
+            self.logger.warning("Copy returned non-zero exit status %d:\n%s" % (status, output))
+        return (status, output)
 
     def copyDirTo(self, localSrc, remoteDst):
         """
meta/lib/oeqa/runtime/cases/ltp.py +1 -1
index 6dc5ef22ad..da529ce482 100644
@@ -78,7 +78,7 @@ class LtpTest(LtpTestBase):
             # copy nice log from DUT
             dst = os.path.join(self.ltptest_log_dir, "%s" %  ltp_group )
             remote_src = "/opt/ltp/results/%s" % ltp_group
-            (status, output) = self.target.copyFrom(remote_src, dst)
+            (status, output) = self.target.copyFrom(remote_src, dst, True)
             msg = 'File could not be copied. Output: %s' % output
             self.assertEqual(status, 0, msg=msg)
 

--
2.27.0

#1 lore raw
Quoted 39 lines · Matthew

[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.

---
 meta/lib/oeqa/core/target/ssh.py   | 7 +++++--
 meta/lib/oeqa/runtime/cases/ltp.py | 2 +-
 2 files changed, 6 insertions(+), 3 deletions(-)
meta/lib/oeqa/core/target/ssh.py +5 -2
index 090b40a814..aefb576805 100644
@@ -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 status:
+            self.logger.warning("Copy returned non-zero exit status %d:\n%s" % (status, output))
+        return (status, output)
 
     def copyDirTo(self, localSrc, remoteDst):
         """
meta/lib/oeqa/runtime/cases/ltp.py +0 -0
index 6dc5ef22ad..da529ce482 100644

meta/lib/oeqa/runtime/cases/ltp.py class LtpTest(LtpTestBase): · line 83

Quoted 7 lines
meta/lib/oeqa/runtime/cases/ltp.py +1 -1
@@ -78,7 +78,7 @@ class LtpTest(LtpTestBase):
             # copy nice log from DUT
             dst = os.path.join(self.ltptest_log_dir, "%s" %  ltp_group )
             remote_src = "/opt/ltp/results/%s" % ltp_group
-            (status, output) = self.target.copyFrom(remote_src, dst)
+            (status, output) = self.target.copyFrom(remote_src, dst, True)
             msg = 'File could not be copied. Output: %s' % output
             self.assertEqual(status, 0, msg=msg)

The idea of this change is so "the ltp tests continue to run" yet if I understand that code, a copy failure will throw the assertEqual and hence stop the test so we don't get all the other logging information?

Cheers,

Richard

author
#2 lore raw
Quoted 43 lines · Richard Purdie
Quoted 42 lines · Matthew

[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.

---
 meta/lib/oeqa/core/target/ssh.py   | 7 +++++--
 meta/lib/oeqa/runtime/cases/ltp.py | 2 +-
 2 files changed, 6 insertions(+), 3 deletions(-)
meta/lib/oeqa/core/target/ssh.py +5 -2
index 090b40a814..aefb576805 100644
@@ -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 status:
+            self.logger.warning("Copy returned non-zero exit status %d:\n%s" % (status, output))
+        return (status, output)
 
     def copyDirTo(self, localSrc, remoteDst):
         """
meta/lib/oeqa/runtime/cases/ltp.py +0 -0
index 6dc5ef22ad..da529ce482 100644
@@ -78,7 +78,7 @@ class LtpTest(LtpTestBase):
             # copy nice log from DUT
             dst = os.path.join(self.ltptest_log_dir, "%s" %  ltp_group )
             remote_src = "/opt/ltp/results/%s" % ltp_group
Quoted 8 lines

meta/lib/oeqa/runtime/cases/ltp.py class LtpTest(LtpTestBase): · line 83

Quoted 4 lines
meta/lib/oeqa/runtime/cases/ltp.py +1 -1
-            (status, output) = self.target.copyFrom(remote_src, dst)
+            (status, output) = self.target.copyFrom(remote_src, dst, True)
             msg = 'File could not be copied. Output: %s' % output
             self.assertEqual(status, 0, msg=msg)

The idea of this change is so "the ltp tests continue to run" yet if I understand that code, a copy failure will throw the assertEqual and hence stop the test so we don't get all the other logging information?

When warn_on_failure=True, so is ignore_status. Then 'status and not ignore_status' evaluates to false, and 'raise AssertionError("Command '%s' returned non-zero exit ...)' will not run.

Quoted 6 lines

Cheers,

Richard

--
Mingde (Matthew) Zeng

#3 lore raw
Quoted 54 lines · Mingde (Matthew) Zeng
Quoted 43 lines · Richard Purdie
Quoted 42 lines · Matthew

[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.

---
 meta/lib/oeqa/core/target/ssh.py   | 7 +++++--
 meta/lib/oeqa/runtime/cases/ltp.py | 2 +-
 2 files changed, 6 insertions(+), 3 deletions(-)
meta/lib/oeqa/core/target/ssh.py +5 -2
index 090b40a814..aefb576805 100644
@@ -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 status:
+            self.logger.warning("Copy returned non-zero exit status %d:\n%s" % (status, output))
+        return (status, output)
 
     def copyDirTo(self, localSrc, remoteDst):
         """
meta/lib/oeqa/runtime/cases/ltp.py +0 -0
index 6dc5ef22ad..da529ce482 100644
@@ -78,7 +78,7 @@ class LtpTest(LtpTestBase):
             # copy nice log from DUT
             dst = os.path.join(self.ltptest_log_dir, "%s" %  ltp_group )
             remote_src = "/opt/ltp/results/%s" % ltp_group
Quoted 8 lines

meta/lib/oeqa/runtime/cases/ltp.py class LtpTest(LtpTestBase): · line 83

Quoted 4 lines
meta/lib/oeqa/runtime/cases/ltp.py +1 -1
-            (status, output) = self.target.copyFrom(remote_src, dst)
+            (status, output) = self.target.copyFrom(remote_src, dst, True)
             msg = 'File could not be copied. Output: %s' % output
             self.assertEqual(status, 0, msg=msg)

The idea of this change is so "the ltp tests continue to run" yet if I understand that code, a copy failure will throw the assertEqual and hence stop the test so we don't get all the other logging information?

Quoted 3 lines

When warn_on_failure=True, so is ignore_status. Then 'status and not ignore_status' evaluates to false, and 'raise AssertionError("Command '%s' returned non-zero exit ...)' will not run.

Sure, but status will be non-zero and the code says:

(status, output) = self.target.copyFrom(remote_src, dst, True) msg = 'File could not be copied. Output: %s' % output self.assertEqual(status, 0, msg=msg)

so

self.assertEqual(status, 0, msg=msg)

will fail if copyFrom() fails?

Cheers,

Richard

author
#4 lore raw
Quoted 65 lines · Richard Purdie
Quoted 54 lines · Mingde (Matthew) Zeng
Quoted 43 lines · Richard Purdie
Quoted 42 lines · Matthew

[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.

---
 meta/lib/oeqa/core/target/ssh.py   | 7 +++++--
 meta/lib/oeqa/runtime/cases/ltp.py | 2 +-
 2 files changed, 6 insertions(+), 3 deletions(-)
meta/lib/oeqa/core/target/ssh.py +5 -2
index 090b40a814..aefb576805 100644
@@ -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 status:
+            self.logger.warning("Copy returned non-zero exit status %d:\n%s" % (status, output))
+        return (status, output)
 
     def copyDirTo(self, localSrc, remoteDst):
         """
meta/lib/oeqa/runtime/cases/ltp.py +0 -0
index 6dc5ef22ad..da529ce482 100644
@@ -78,7 +78,7 @@ class LtpTest(LtpTestBase):
             # copy nice log from DUT
             dst = os.path.join(self.ltptest_log_dir, "%s" %  ltp_group )
             remote_src = "/opt/ltp/results/%s" % ltp_group
Quoted 8 lines

meta/lib/oeqa/runtime/cases/ltp.py class LtpTest(LtpTestBase): · line 83

Quoted 4 lines
meta/lib/oeqa/runtime/cases/ltp.py +1 -1
-            (status, output) = self.target.copyFrom(remote_src, dst)
+            (status, output) = self.target.copyFrom(remote_src, dst, True)
             msg = 'File could not be copied. Output: %s' % output
             self.assertEqual(status, 0, msg=msg)

The idea of this change is so "the ltp tests continue to run" yet if I understand that code, a copy failure will throw the assertEqual and hence stop the test so we don't get all the other logging information?

Quoted 3 lines

When warn_on_failure=True, so is ignore_status. Then 'status and not ignore_status' evaluates to false, and 'raise AssertionError("Command '%s' returned non-zero exit ...)' will not run.

Sure, but status will be non-zero and the code says:

(status, output) = self.target.copyFrom(remote_src, dst, True) msg = 'File could not be copied. Output: %s' % output self.assertEqual(status, 0, msg=msg)

Quoted 5 lines

so

self.assertEqual(status, 0, msg=msg)

will fail if copyFrom() fails?

Right, I'll comment that line out as well.

Also, I received the Patchwork email complaining a conflict, however I successfully applied my patch after git pulling a couple times, do you know what's wrong?

Quoted 4 lines

Cheers,

Richard

--
Mingde (Matthew) Zeng

#5 lore raw

✗ patchtest: failure for ltp: make copyFrom scp command non-fatal (rev3)

In reply to Matthew

== Series Details ==

Series: ltp: make copyFrom scp command non-fatal (rev3)
Revision: 3
URL : https://patchwork.openembedded.org/series/25475/
State : failure

== Summary ==

Thank you for submitting this patch series to OpenEmbedded Core. This is an automated response. Several tests have been executed on the proposed series by patchtest resulting in the following failures:

* Issue Series does not apply on top of target branch [test_series_merge_on_head]
Suggested fix Rebase your series on top of targeted branch
Targeted branch master (currently at 10221e578f)

If you believe any of these test results are incorrect, please reply to the mailing list ([email protected]) raising your concerns. Otherwise we would appreciate you correcting the issues and submitting a new version of the patchset if applicable. Please ensure you add/increment the version number when sending the new version (i.e. [PATCH] -> [PATCH v2] -> [PATCH v3] -> ...).

---

Guidelines:     https://www.openembedded.org/wiki/Commit_Patch_Message_Guidelines
Test framework: http://git.yoctoproject.org/cgit/cgit.cgi/patchtest
Test suite:     http://git.yoctoproject.org/cgit/cgit.cgi/patchtest-oe