mirror of
https://git.yoctoproject.org/poky
synced 2026-05-31 00:39:46 +00:00
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>
This commit is contained in:
committed by
Richard Purdie
parent
389ef0d9e4
commit
99bc21953a
@@ -4,6 +4,7 @@
|
|||||||
# SPDX-License-Identifier: MIT
|
# SPDX-License-Identifier: MIT
|
||||||
#
|
#
|
||||||
|
|
||||||
|
import errno
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import shutil
|
import shutil
|
||||||
@@ -1900,7 +1901,15 @@ class DevtoolUpgradeTests(DevtoolBase):
|
|||||||
for p in paths:
|
for p in paths:
|
||||||
dstdir = os.path.join(dstdir, p)
|
dstdir = os.path.join(dstdir, p)
|
||||||
if not os.path.exists(dstdir):
|
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":
|
if p == "lib":
|
||||||
# Can race with other tests
|
# Can race with other tests
|
||||||
self.add_command_to_tearDown('rmdir --ignore-fail-on-non-empty %s' % dstdir)
|
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)
|
self.track_for_cleanup(dstdir)
|
||||||
dstfile = os.path.join(dstdir, os.path.basename(srcfile))
|
dstfile = os.path.join(dstdir, os.path.basename(srcfile))
|
||||||
if srcfile != dstfile:
|
if srcfile != dstfile:
|
||||||
shutil.copy(srcfile, dstfile)
|
try:
|
||||||
|
shutil.copy(srcfile, dstfile)
|
||||||
|
except PermissionError:
|
||||||
|
return False
|
||||||
self.track_for_cleanup(dstfile)
|
self.track_for_cleanup(dstfile)
|
||||||
|
return True
|
||||||
|
|
||||||
def test_devtool_load_plugin(self):
|
def test_devtool_load_plugin(self):
|
||||||
"""Test that devtool loads only the first found plugin in BBPATH."""
|
"""Test that devtool loads only the first found plugin in BBPATH."""
|
||||||
@@ -1927,15 +1940,17 @@ class DevtoolUpgradeTests(DevtoolBase):
|
|||||||
plugincontent = fh.readlines()
|
plugincontent = fh.readlines()
|
||||||
try:
|
try:
|
||||||
self.assertIn('meta-selftest', srcfile, 'wrong bbpath plugin found')
|
self.assertIn('meta-selftest', srcfile, 'wrong bbpath plugin found')
|
||||||
for path in searchpath:
|
searchpath = [
|
||||||
self._copy_file_with_cleanup(srcfile, path, 'lib', 'devtool')
|
path for path in searchpath
|
||||||
|
if self._copy_file_with_cleanup(srcfile, path, 'lib', 'devtool')
|
||||||
|
]
|
||||||
result = runCmd("devtool --quiet count")
|
result = runCmd("devtool --quiet count")
|
||||||
self.assertEqual(result.output, '1')
|
self.assertEqual(result.output, '1')
|
||||||
result = runCmd("devtool --quiet multiloaded")
|
result = runCmd("devtool --quiet multiloaded")
|
||||||
self.assertEqual(result.output, "no")
|
self.assertEqual(result.output, "no")
|
||||||
for path in searchpath:
|
for path in searchpath:
|
||||||
result = runCmd("devtool --quiet bbdir")
|
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'))
|
os.unlink(os.path.join(result.output, 'lib', 'devtool', 'bbpath.py'))
|
||||||
finally:
|
finally:
|
||||||
with open(srcfile, 'w') as fh:
|
with open(srcfile, 'w') as fh:
|
||||||
|
|||||||
Reference in New Issue
Block a user