diff options
author | Pavel Zhukov <pavel@zhukoff.net> | 2022-06-09 18:57:04 +0200 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2022-06-11 10:30:56 +0100 |
commit | 6c5944c114b9bb33673138e9e84959415abfc8a1 (patch) | |
tree | ba4e0776670366ac415bd511fb1a1632e1fc036d /bitbake | |
parent | 84087dfade414fa4c8d6a37fea6533abfcdd9c51 (diff) | |
download | poky-6c5944c114b9bb33673138e9e84959415abfc8a1.tar.gz |
bitbake: tests/fetch: Add tests for premirror using real project
Existing test uses fake local repo for better performance. Adding
test which uses real (but still small) project hosted on
yoctoproject.org.
(Bitbake rev: 247f3536a691cdaa3f96768d1b42653b1da9ae84)
Signed-off-by: Pavel Zhukov <pavel.zhukov@huawei.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake')
-rw-r--r-- | bitbake/lib/bb/tests/fetch.py | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/bitbake/lib/bb/tests/fetch.py b/bitbake/lib/bb/tests/fetch.py index 18e585721c..622c46a05d 100644 --- a/bitbake/lib/bb/tests/fetch.py +++ b/bitbake/lib/bb/tests/fetch.py | |||
@@ -2856,3 +2856,42 @@ class FetchPremirroronlyLocalTest(FetcherTest): | |||
2856 | fetcher = bb.fetch.Fetch([self.recipe_url], self.d) | 2856 | fetcher = bb.fetch.Fetch([self.recipe_url], self.d) |
2857 | with self.assertRaises(bb.fetch2.NetworkAccess): | 2857 | with self.assertRaises(bb.fetch2.NetworkAccess): |
2858 | fetcher.download() | 2858 | fetcher.download() |
2859 | |||
2860 | class FetchPremirroronlyNetworkTest(FetcherTest): | ||
2861 | |||
2862 | def setUp(self): | ||
2863 | super(FetchPremirroronlyNetworkTest, self).setUp() | ||
2864 | self.mirrordir = os.path.join(self.tempdir, "mirrors") | ||
2865 | os.mkdir(self.mirrordir) | ||
2866 | self.reponame = "fstests" | ||
2867 | self.clonedir = os.path.join(self.tempdir, "git") | ||
2868 | self.gitdir = os.path.join(self.tempdir, "git", "{}.git".format(self.reponame)) | ||
2869 | self.recipe_url = "git://git.yoctoproject.org/fstests" | ||
2870 | self.d.setVar("BB_FETCH_PREMIRRORONLY", "1") | ||
2871 | self.d.setVar("BB_NO_NETWORK", "0") | ||
2872 | self.d.setVar("PREMIRRORS", self.recipe_url + " " + "file://{}".format(self.mirrordir) + " \n") | ||
2873 | |||
2874 | def make_git_repo(self): | ||
2875 | import shutil | ||
2876 | self.mirrorname = "git2_git.yoctoproject.org.fstests.tar.gz" | ||
2877 | os.makedirs(self.clonedir) | ||
2878 | self.git("clone --bare --shallow-since=\"01.01.2013\" {}".format(self.recipe_url), self.clonedir) | ||
2879 | bb.process.run('tar -czvf {} .'.format(os.path.join(self.mirrordir, self.mirrorname)), cwd = self.gitdir) | ||
2880 | shutil.rmtree(self.clonedir) | ||
2881 | |||
2882 | @skipIfNoNetwork() | ||
2883 | def test_mirror_tarball_updated(self): | ||
2884 | self.make_git_repo() | ||
2885 | ## Upstream commit is in the mirror | ||
2886 | self.d.setVar("SRCREV", "49d65d53c2bf558ae6e9185af0f3af7b79d255ec") | ||
2887 | fetcher = bb.fetch.Fetch([self.recipe_url], self.d) | ||
2888 | fetcher.download() | ||
2889 | |||
2890 | @skipIfNoNetwork() | ||
2891 | def test_mirror_tarball_outdated(self): | ||
2892 | self.make_git_repo() | ||
2893 | ## Upstream commit not in the mirror | ||
2894 | self.d.setVar("SRCREV", "15413486df1f5a5b5af699b6f3ba5f0984e52a9f") | ||
2895 | fetcher = bb.fetch.Fetch([self.recipe_url], self.d) | ||
2896 | with self.assertRaises(bb.fetch2.NetworkAccess): | ||
2897 | fetcher.download() | ||