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