diff options
author | Peter Kjellerstedt <peter.kjellerstedt@axis.com> | 2023-12-06 21:55:26 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2023-12-08 16:58:34 +0000 |
commit | 7481f8e9168e1d03baf48e323bd971841792ca70 (patch) | |
tree | 6245825d90d312f604c08210ff0e28a11722ac20 /meta | |
parent | 99bc21953a2359b0d097dff2841470a1e8585dca (diff) | |
download | poky-7481f8e9168e1d03baf48e323bd971841792ca70.tar.gz |
oeqa/selftest/recipetool: Make test_recipetool_load_plugin more resilient
* Avoid trying to write to read-only directories and file systems.
* Support symbolic links in BBPATH.
(From OE-Core rev: 9a8b621c4d26ff349de88658e6ea21aee6ba6767)
Signed-off-by: Peter Kjellerstedt <peter.kjellerstedt@axis.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta')
-rw-r--r-- | meta/lib/oeqa/selftest/cases/recipetool.py | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/meta/lib/oeqa/selftest/cases/recipetool.py b/meta/lib/oeqa/selftest/cases/recipetool.py index bfe06eb4a5..20dd41f492 100644 --- a/meta/lib/oeqa/selftest/cases/recipetool.py +++ b/meta/lib/oeqa/selftest/cases/recipetool.py | |||
@@ -4,6 +4,7 @@ | |||
4 | # SPDX-License-Identifier: MIT | 4 | # SPDX-License-Identifier: MIT |
5 | # | 5 | # |
6 | 6 | ||
7 | import errno | ||
7 | import os | 8 | import os |
8 | import shutil | 9 | import shutil |
9 | import tempfile | 10 | import tempfile |
@@ -914,7 +915,15 @@ class RecipetoolTests(RecipetoolBase): | |||
914 | for p in paths: | 915 | for p in paths: |
915 | dstdir = os.path.join(dstdir, p) | 916 | dstdir = os.path.join(dstdir, p) |
916 | if not os.path.exists(dstdir): | 917 | if not os.path.exists(dstdir): |
917 | os.makedirs(dstdir) | 918 | try: |
919 | os.makedirs(dstdir) | ||
920 | except PermissionError: | ||
921 | return False | ||
922 | except OSError as e: | ||
923 | if e.errno == errno.EROFS: | ||
924 | return False | ||
925 | else: | ||
926 | raise e | ||
918 | if p == "lib": | 927 | if p == "lib": |
919 | # Can race with other tests | 928 | # Can race with other tests |
920 | self.add_command_to_tearDown('rmdir --ignore-fail-on-non-empty %s' % dstdir) | 929 | self.add_command_to_tearDown('rmdir --ignore-fail-on-non-empty %s' % dstdir) |
@@ -922,8 +931,12 @@ class RecipetoolTests(RecipetoolBase): | |||
922 | self.track_for_cleanup(dstdir) | 931 | self.track_for_cleanup(dstdir) |
923 | dstfile = os.path.join(dstdir, os.path.basename(srcfile)) | 932 | dstfile = os.path.join(dstdir, os.path.basename(srcfile)) |
924 | if srcfile != dstfile: | 933 | if srcfile != dstfile: |
925 | shutil.copy(srcfile, dstfile) | 934 | try: |
935 | shutil.copy(srcfile, dstfile) | ||
936 | except PermissionError: | ||
937 | return False | ||
926 | self.track_for_cleanup(dstfile) | 938 | self.track_for_cleanup(dstfile) |
939 | return True | ||
927 | 940 | ||
928 | def test_recipetool_load_plugin(self): | 941 | def test_recipetool_load_plugin(self): |
929 | """Test that recipetool loads only the first found plugin in BBPATH.""" | 942 | """Test that recipetool loads only the first found plugin in BBPATH.""" |
@@ -937,15 +950,17 @@ class RecipetoolTests(RecipetoolBase): | |||
937 | plugincontent = fh.readlines() | 950 | plugincontent = fh.readlines() |
938 | try: | 951 | try: |
939 | self.assertIn('meta-selftest', srcfile, 'wrong bbpath plugin found') | 952 | self.assertIn('meta-selftest', srcfile, 'wrong bbpath plugin found') |
940 | for path in searchpath: | 953 | searchpath = [ |
941 | self._copy_file_with_cleanup(srcfile, path, 'lib', 'recipetool') | 954 | path for path in searchpath |
955 | if self._copy_file_with_cleanup(srcfile, path, 'lib', 'recipetool') | ||
956 | ] | ||
942 | result = runCmd("recipetool --quiet count") | 957 | result = runCmd("recipetool --quiet count") |
943 | self.assertEqual(result.output, '1') | 958 | self.assertEqual(result.output, '1') |
944 | result = runCmd("recipetool --quiet multiloaded") | 959 | result = runCmd("recipetool --quiet multiloaded") |
945 | self.assertEqual(result.output, "no") | 960 | self.assertEqual(result.output, "no") |
946 | for path in searchpath: | 961 | for path in searchpath: |
947 | result = runCmd("recipetool --quiet bbdir") | 962 | result = runCmd("recipetool --quiet bbdir") |
948 | self.assertEqual(result.output, path) | 963 | self.assertEqual(os.path.realpath(result.output), os.path.realpath(path)) |
949 | os.unlink(os.path.join(result.output, 'lib', 'recipetool', 'bbpath.py')) | 964 | os.unlink(os.path.join(result.output, 'lib', 'recipetool', 'bbpath.py')) |
950 | finally: | 965 | finally: |
951 | with open(srcfile, 'w') as fh: | 966 | with open(srcfile, 'w') as fh: |