summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPavel Zhukov <pavel@zhukoff.net>2022-06-16 18:15:22 +0200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2022-06-21 20:49:49 +0100
commitc9aaca3dd2dfdf4a291d6e1f6263037e0f54b4b6 (patch)
tree9fe2c8524daa32d07b9abd7851f279d8d65b5385
parent35167536c163eb6b7653cbcaad9f65b834d3e2f8 (diff)
downloadbitbake-c9aaca3dd2dfdf4a291d6e1f6263037e0f54b4b6.tar.gz
tests/fetch: Add test for broken mirror tarball
With PREMIRRORS set and BB_NO_NETWORK = "1" bitbake should not try to fetch into non-initialized git directory if tarball is broken (or not in gzip format) [Yocto 14822] Signed-off-by: Pavel Zhukov <pavel.zhukov@huawei.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--lib/bb/tests/fetch.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/lib/bb/tests/fetch.py b/lib/bb/tests/fetch.py
index 622c46a05..ee41bff43 100644
--- a/lib/bb/tests/fetch.py
+++ b/lib/bb/tests/fetch.py
@@ -2895,3 +2895,28 @@ class FetchPremirroronlyNetworkTest(FetcherTest):
fetcher = bb.fetch.Fetch([self.recipe_url], self.d)
with self.assertRaises(bb.fetch2.NetworkAccess):
fetcher.download()
+
+class FetchPremirroronlyBrokenTarball(FetcherTest):
+
+ def setUp(self):
+ super(FetchPremirroronlyBrokenTarball, self).setUp()
+ self.mirrordir = os.path.join(self.tempdir, "mirrors")
+ os.mkdir(self.mirrordir)
+ self.reponame = "bitbake"
+ self.gitdir = os.path.join(self.tempdir, "git", self.reponame)
+ self.recipe_url = "git://git.fake.repo/bitbake"
+ self.d.setVar("BB_FETCH_PREMIRRORONLY", "1")
+ self.d.setVar("BB_NO_NETWORK", "1")
+ self.d.setVar("PREMIRRORS", self.recipe_url + " " + "file://{}".format(self.mirrordir) + " \n")
+ self.mirrorname = "git2_git.fake.repo.bitbake.tar.gz"
+ with open(os.path.join(self.mirrordir, self.mirrorname), 'w') as targz:
+ targz.write("This is not tar.gz file!")
+
+ def test_mirror_broken_download(self):
+ import sys
+ self.d.setVar("SRCREV", "0"*40)
+ fetcher = bb.fetch.Fetch([self.recipe_url], self.d)
+ with self.assertRaises(bb.fetch2.FetchError):
+ fetcher.download()
+ stdout = sys.stdout.getvalue()
+ self.assertFalse(" not a git repository (or any parent up to mount point /)" in stdout)