summaryrefslogtreecommitdiffstats
path: root/meta/lib/oeqa/selftest
diff options
context:
space:
mode:
authorPeter Kjellerstedt <peter.kjellerstedt@axis.com>2023-12-06 21:55:25 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2023-12-08 16:58:34 +0000
commit99bc21953a2359b0d097dff2841470a1e8585dca (patch)
tree64738c7f16c5cc4d031c655c8ea8b28c07a1f28d /meta/lib/oeqa/selftest
parent389ef0d9e4767d2b081af96f36957ea5e44a0226 (diff)
downloadpoky-99bc21953a2359b0d097dff2841470a1e8585dca.tar.gz
oeqa/selftest/devtool: Make test_devtool_load_plugin more resilient
* Avoid trying to write to read-only directories and file systems. * Support symbolic links in BBPATH. (From OE-Core rev: eba30ce546cda0ae4c3e433b6e79dbab0627157a) 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/lib/oeqa/selftest')
-rw-r--r--meta/lib/oeqa/selftest/cases/devtool.py25
1 files changed, 20 insertions, 5 deletions
diff --git a/meta/lib/oeqa/selftest/cases/devtool.py b/meta/lib/oeqa/selftest/cases/devtool.py
index e5daf949a6..fd9ac42168 100644
--- a/meta/lib/oeqa/selftest/cases/devtool.py
+++ b/meta/lib/oeqa/selftest/cases/devtool.py
@@ -4,6 +4,7 @@
4# SPDX-License-Identifier: MIT 4# SPDX-License-Identifier: MIT
5# 5#
6 6
7import errno
7import os 8import os
8import re 9import re
9import shutil 10import shutil
@@ -1900,7 +1901,15 @@ class DevtoolUpgradeTests(DevtoolBase):
1900 for p in paths: 1901 for p in paths:
1901 dstdir = os.path.join(dstdir, p) 1902 dstdir = os.path.join(dstdir, p)
1902 if not os.path.exists(dstdir): 1903 if not os.path.exists(dstdir):
1903 os.makedirs(dstdir) 1904 try:
1905 os.makedirs(dstdir)
1906 except PermissionError:
1907 return False
1908 except OSError as e:
1909 if e.errno == errno.EROFS:
1910 return False
1911 else:
1912 raise e
1904 if p == "lib": 1913 if p == "lib":
1905 # Can race with other tests 1914 # Can race with other tests
1906 self.add_command_to_tearDown('rmdir --ignore-fail-on-non-empty %s' % dstdir) 1915 self.add_command_to_tearDown('rmdir --ignore-fail-on-non-empty %s' % dstdir)
@@ -1908,8 +1917,12 @@ class DevtoolUpgradeTests(DevtoolBase):
1908 self.track_for_cleanup(dstdir) 1917 self.track_for_cleanup(dstdir)
1909 dstfile = os.path.join(dstdir, os.path.basename(srcfile)) 1918 dstfile = os.path.join(dstdir, os.path.basename(srcfile))
1910 if srcfile != dstfile: 1919 if srcfile != dstfile:
1911 shutil.copy(srcfile, dstfile) 1920 try:
1921 shutil.copy(srcfile, dstfile)
1922 except PermissionError:
1923 return False
1912 self.track_for_cleanup(dstfile) 1924 self.track_for_cleanup(dstfile)
1925 return True
1913 1926
1914 def test_devtool_load_plugin(self): 1927 def test_devtool_load_plugin(self):
1915 """Test that devtool loads only the first found plugin in BBPATH.""" 1928 """Test that devtool loads only the first found plugin in BBPATH."""
@@ -1927,15 +1940,17 @@ class DevtoolUpgradeTests(DevtoolBase):
1927 plugincontent = fh.readlines() 1940 plugincontent = fh.readlines()
1928 try: 1941 try:
1929 self.assertIn('meta-selftest', srcfile, 'wrong bbpath plugin found') 1942 self.assertIn('meta-selftest', srcfile, 'wrong bbpath plugin found')
1930 for path in searchpath: 1943 searchpath = [
1931 self._copy_file_with_cleanup(srcfile, path, 'lib', 'devtool') 1944 path for path in searchpath
1945 if self._copy_file_with_cleanup(srcfile, path, 'lib', 'devtool')
1946 ]
1932 result = runCmd("devtool --quiet count") 1947 result = runCmd("devtool --quiet count")
1933 self.assertEqual(result.output, '1') 1948 self.assertEqual(result.output, '1')
1934 result = runCmd("devtool --quiet multiloaded") 1949 result = runCmd("devtool --quiet multiloaded")
1935 self.assertEqual(result.output, "no") 1950 self.assertEqual(result.output, "no")
1936 for path in searchpath: 1951 for path in searchpath:
1937 result = runCmd("devtool --quiet bbdir") 1952 result = runCmd("devtool --quiet bbdir")
1938 self.assertEqual(result.output, path) 1953 self.assertEqual(os.path.realpath(result.output), os.path.realpath(path))
1939 os.unlink(os.path.join(result.output, 'lib', 'devtool', 'bbpath.py')) 1954 os.unlink(os.path.join(result.output, 'lib', 'devtool', 'bbpath.py'))
1940 finally: 1955 finally:
1941 with open(srcfile, 'w') as fh: 1956 with open(srcfile, 'w') as fh: