diff options
Diffstat (limited to 'poky/bitbake')
-rw-r--r-- | poky/bitbake/lib/bb/fetch2/__init__.py | 7 | ||||
-rw-r--r-- | poky/bitbake/lib/bb/msg.py | 2 | ||||
-rw-r--r-- | poky/bitbake/lib/hashserv/client.py | 15 | ||||
-rw-r--r-- | poky/bitbake/lib/hashserv/tests.py | 29 |
4 files changed, 40 insertions, 13 deletions
diff --git a/poky/bitbake/lib/bb/fetch2/__init__.py b/poky/bitbake/lib/bb/fetch2/__init__.py index 290773072..07b7ae41b 100644 --- a/poky/bitbake/lib/bb/fetch2/__init__.py +++ b/poky/bitbake/lib/bb/fetch2/__init__.py @@ -1021,8 +1021,7 @@ def try_mirror_url(fetch, origud, ud, ld, check = False): origud.method.build_mirror_data(origud, ld) return origud.localpath # Otherwise the result is a local file:// and we symlink to it - ensure_symlink(ud.localpath, origud.localpath, relative=True) - + ensure_symlink(ud.localpath, origud.localpath) update_stamp(origud, ld) return ud.localpath @@ -1056,7 +1055,7 @@ def try_mirror_url(fetch, origud, ud, ld, check = False): bb.utils.unlockfile(lf) -def ensure_symlink(target, link_name, relative=False): +def ensure_symlink(target, link_name): if not os.path.exists(link_name): if os.path.islink(link_name): # Broken symbolic link @@ -1067,8 +1066,6 @@ def ensure_symlink(target, link_name, relative=False): # same time, in which case we do not want the second task to # fail when the link has already been created by the first task. try: - if relative is True: - target = os.path.relpath(target, os.path.dirname(link_name)) os.symlink(target, link_name) except FileExistsError: pass diff --git a/poky/bitbake/lib/bb/msg.py b/poky/bitbake/lib/bb/msg.py index 6f17b6acc..291b38ff7 100644 --- a/poky/bitbake/lib/bb/msg.py +++ b/poky/bitbake/lib/bb/msg.py @@ -278,7 +278,7 @@ def setLoggingConfig(defaultconfig, userconfigfile=None): with open(os.path.normpath(userconfigfile), 'r') as f: if userconfigfile.endswith('.yml') or userconfigfile.endswith('.yaml'): import yaml - userconfig = yaml.load(f) + userconfig = yaml.safe_load(f) elif userconfigfile.endswith('.json') or userconfigfile.endswith('.cfg'): import json userconfig = json.load(f) diff --git a/poky/bitbake/lib/hashserv/client.py b/poky/bitbake/lib/hashserv/client.py index ae5875d1b..0ffd0c2ae 100644 --- a/poky/bitbake/lib/hashserv/client.py +++ b/poky/bitbake/lib/hashserv/client.py @@ -40,7 +40,7 @@ class AsyncClient(object): self._connect_sock = connect_sock - async def _connect(self): + async def connect(self): if self.reader is None or self.writer is None: (self.reader, self.writer) = await self._connect_sock() @@ -62,7 +62,7 @@ class AsyncClient(object): count = 0 while True: try: - await self._connect() + await self.connect() return await proc() except ( OSError, @@ -190,7 +190,6 @@ class Client(object): for call in ( "connect_tcp", - "connect_unix", "close", "get_unihash", "report_unihash", @@ -209,6 +208,16 @@ class Client(object): return wrapper + def connect_unix(self, path): + # AF_UNIX has path length issues so chdir here to workaround + cwd = os.getcwd() + try: + os.chdir(os.path.dirname(path)) + self.loop.run_until_complete(self.client.connect_unix(os.path.basename(path))) + self.loop.run_until_complete(self.client.connect()) + finally: + os.chdir(cwd) + @property def max_chunk(self): return self.client.max_chunk diff --git a/poky/bitbake/lib/hashserv/tests.py b/poky/bitbake/lib/hashserv/tests.py index 3dd9a31be..77a19b807 100644 --- a/poky/bitbake/lib/hashserv/tests.py +++ b/poky/bitbake/lib/hashserv/tests.py @@ -23,7 +23,8 @@ def _run_server(server, idx): sys.stderr = sys.stdout server.serve_forever() -class TestHashEquivalenceServer(object): + +class HashEquivalenceTestSetup(object): METHOD = 'TestMethod' server_index = 0 @@ -65,6 +66,8 @@ class TestHashEquivalenceServer(object): result = client.get_unihash(self.METHOD, taskhash) self.assertEqual(result, unihash) + +class HashEquivalenceCommonTests(object): def test_create_hash(self): # Simple test that hashes can be created taskhash = '35788efcb8dfb0a02659d81cf2bfd695fb30faf9' @@ -240,15 +243,33 @@ class TestHashEquivalenceServer(object): self.assertClientGetHash(self.client, taskhash4, None) -class TestHashEquivalenceUnixServer(TestHashEquivalenceServer, unittest.TestCase): +class TestHashEquivalenceUnixServer(HashEquivalenceTestSetup, HashEquivalenceCommonTests, unittest.TestCase): def get_server_addr(self, server_idx): return "unix://" + os.path.join(self.temp_dir.name, 'sock%d' % server_idx) -class TestHashEquivalenceTCPServer(TestHashEquivalenceServer, unittest.TestCase): +class TestHashEquivalenceUnixServerLongPath(HashEquivalenceTestSetup, unittest.TestCase): + DEEP_DIRECTORY = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/ccccccccccccccccccccccccccccccccccccccccccc" + def get_server_addr(self, server_idx): + os.makedirs(os.path.join(self.temp_dir.name, self.DEEP_DIRECTORY), exist_ok=True) + return "unix://" + os.path.join(self.temp_dir.name, self.DEEP_DIRECTORY, 'sock%d' % server_idx) + + + def test_long_sock_path(self): + # Simple test that hashes can be created + taskhash = '35788efcb8dfb0a02659d81cf2bfd695fb30faf9' + outhash = '2765d4a5884be49b28601445c2760c5f21e7e5c0ee2b7e3fce98fd7e5970796f' + unihash = 'f46d3fbb439bd9b921095da657a4de906510d2cd' + + self.assertClientGetHash(self.client, taskhash, None) + + result = self.client.report_unihash(taskhash, self.METHOD, outhash, unihash) + self.assertEqual(result['unihash'], unihash, 'Server returned bad unihash') + + +class TestHashEquivalenceTCPServer(HashEquivalenceTestSetup, HashEquivalenceCommonTests, unittest.TestCase): def get_server_addr(self, server_idx): # Some hosts cause asyncio module to misbehave, when IPv6 is not enabled. # If IPv6 is enabled, it should be safe to use localhost directly, in general # case it is more reliable to resolve the IP address explicitly. return socket.gethostbyname("localhost") + ":0" - |