bitbake: 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]

(Bitbake rev: c9aaca3dd2dfdf4a291d6e1f6263037e0f54b4b6)

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>
This commit is contained in:
Pavel Zhukov
2022-06-16 18:15:22 +02:00
committed by Richard Purdie
parent 69ff043e62
commit 62af35ffb4

View File

@@ -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)