1import oe.path 2from oeqa.selftest.case import OESelftestTestCase 3from oeqa.utils.commands import bitbake 4from oeqa.core.decorator.oeid import OETestID 5 6class Fetch(OESelftestTestCase): 7 @OETestID(1058) 8 def test_git_mirrors(self): 9 """ 10 Verify that the git fetcher will fall back to the HTTP mirrors. The 11 recipe needs to be one that we have on the Yocto Project source mirror 12 and is hosted in git. 13 """ 14 15 # TODO: mktempd instead of hardcoding 16 dldir = os.path.join(self.builddir, "download-git-mirrors") 17 self.track_for_cleanup(dldir) 18 19 # No mirrors, should use git to fetch successfully 20 features = """ 21DL_DIR = "%s" 22MIRRORS_forcevariable = "" 23PREMIRRORS_forcevariable = "" 24""" % dldir 25 self.write_config(features) 26 oe.path.remove(dldir, recurse=True) 27 bitbake("dbus-wait -c fetch -f") 28 29 # No mirrors and broken git, should fail 30 features = """ 31DL_DIR = "%s" 32GIT_PROXY_COMMAND = "false" 33MIRRORS_forcevariable = "" 34PREMIRRORS_forcevariable = "" 35""" % dldir 36 self.write_config(features) 37 oe.path.remove(dldir, recurse=True) 38 with self.assertRaises(AssertionError): 39 bitbake("dbus-wait -c fetch -f") 40 41 # Broken git but a specific mirror 42 features = """ 43DL_DIR = "%s" 44GIT_PROXY_COMMAND = "false" 45MIRRORS_forcevariable = "git://.*/.* http://downloads.yoctoproject.org/mirror/sources/" 46""" % dldir 47 self.write_config(features) 48 oe.path.remove(dldir, recurse=True) 49 bitbake("dbus-wait -c fetch -f") 50