All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Kjellerstedt <pkj@axis.com>
To: <openembedded-core@lists.openembedded.org>
Subject: [PATCHv2 3/9] oeqa/selftest/devtool: Make test_devtool_load_plugin more resilient
Date: Wed, 6 Dec 2023 21:55:25 +0100	[thread overview]
Message-ID: <20231206205531.4037549-4-pkj@axis.com> (raw)
In-Reply-To: <20231206205531.4037549-1-pkj@axis.com>

* Avoid trying to write to read-only directories and file systems.
* Support symbolic links in BBPATH.

Signed-off-by: Peter Kjellerstedt <peter.kjellerstedt@axis.com>
---
 meta/lib/oeqa/selftest/cases/devtool.py | 25 ++++++++++++++++++++-----
 1 file changed, 20 insertions(+), 5 deletions(-)

diff --git a/meta/lib/oeqa/selftest/cases/devtool.py b/meta/lib/oeqa/selftest/cases/devtool.py
index 03d57cc30a..e01ab01869 100644
--- a/meta/lib/oeqa/selftest/cases/devtool.py
+++ b/meta/lib/oeqa/selftest/cases/devtool.py
@@ -4,6 +4,7 @@
 # SPDX-License-Identifier: MIT
 #
 
+import errno
 import os
 import re
 import shutil
@@ -1900,7 +1901,15 @@ class DevtoolUpgradeTests(DevtoolBase):
         for p in paths:
             dstdir = os.path.join(dstdir, p)
             if not os.path.exists(dstdir):
-                os.makedirs(dstdir)
+                try:
+                    os.makedirs(dstdir)
+                except PermissionError:
+                    return False
+                except OSError as e:
+                    if e.errno == errno.EROFS:
+                        return False
+                    else:
+                        raise e
                 if p == "lib":
                     # Can race with other tests
                     self.add_command_to_tearDown('rmdir --ignore-fail-on-non-empty %s' % dstdir)
@@ -1908,8 +1917,12 @@ class DevtoolUpgradeTests(DevtoolBase):
                     self.track_for_cleanup(dstdir)
         dstfile = os.path.join(dstdir, os.path.basename(srcfile))
         if srcfile != dstfile:
-            shutil.copy(srcfile, dstfile)
+            try:
+                shutil.copy(srcfile, dstfile)
+            except PermissionError:
+                return False
             self.track_for_cleanup(dstfile)
+        return True
 
     def test_devtool_load_plugin(self):
         """Test that devtool loads only the first found plugin in BBPATH."""
@@ -1927,15 +1940,17 @@ class DevtoolUpgradeTests(DevtoolBase):
             plugincontent = fh.readlines()
         try:
             self.assertIn('meta-selftest', srcfile, 'wrong bbpath plugin found')
-            for path in searchpath:
-                self._copy_file_with_cleanup(srcfile, path, 'lib', 'devtool')
+            searchpath = [
+                path for path in searchpath
+                if self._copy_file_with_cleanup(srcfile, path, 'lib', 'devtool')
+            ]
             result = runCmd("devtool --quiet count")
             self.assertEqual(result.output, '1')
             result = runCmd("devtool --quiet multiloaded")
             self.assertEqual(result.output, "no")
             for path in searchpath:
                 result = runCmd("devtool --quiet bbdir")
-                self.assertEqual(result.output, path)
+                self.assertEqual(os.path.realpath(result.output), os.path.realpath(path))
                 os.unlink(os.path.join(result.output, 'lib', 'devtool', 'bbpath.py'))
         finally:
             with open(srcfile, 'w') as fh:


  parent reply	other threads:[~2023-12-06 20:55 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-06 20:55 [PATCHv2 0/9] Improvements for devtool/recipetool Peter Kjellerstedt
2023-12-06 20:55 ` [PATCHv2 1/9] oeqa/selftest/devtool: Correct git clone of local repository Peter Kjellerstedt
2023-12-06 20:55 ` [PATCHv2 2/9] oeqa/selftest/devtool: Avoid global Git hooks when amending a patch Peter Kjellerstedt
2023-12-06 20:55 ` Peter Kjellerstedt [this message]
2023-12-06 20:55 ` [PATCHv2 4/9] oeqa/selftest/recipetool: Make test_recipetool_load_plugin more resilient Peter Kjellerstedt
2023-12-06 20:55 ` [PATCHv2 5/9] lib/oe/recipeutils: Avoid wrapping any SRC_URI[sha*sum] variables Peter Kjellerstedt
2023-12-06 20:55 ` [PATCHv2 6/9] recipetool: create: Improve identification of licenses Peter Kjellerstedt
2023-12-06 20:55 ` [PATCHv2 7/9] recipetool: create: Only include the expected SRC_URI checksums Peter Kjellerstedt
2023-12-07 16:23   ` [OE-core] " Alexandre Belloni
2023-12-06 20:55 ` [PATCHv2 8/9] devtool: upgrade: Update all existing checksums for the SRC_URI Peter Kjellerstedt
2023-12-06 20:55 ` [PATCHv2 9/9] devtool: modify: Make --no-extract work again Peter Kjellerstedt

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=20231206205531.4037549-4-pkj@axis.com \
    --to=pkj@axis.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.