summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb
diff options
context:
space:
mode:
authorPaulo Neves <paulo@myneves.com>2024-02-27 07:18:07 +0100
committerSteve Sakoman <steve@sakoman.com>2024-03-01 08:00:58 -1000
commitec62e15f12f3c69d1e9b484cb2cbb8f84fdf73d8 (patch)
tree9d9783741f07491dd17b60e142397385e1f7fedf /bitbake/lib/bb
parentb67823515e8258bf28f2b2618e17ac9b8b0ea7be (diff)
downloadpoky-ec62e15f12f3c69d1e9b484cb2cbb8f84fdf73d8.tar.gz
bitbake: tests/fetch: Add real git lfs tests and decorator
Added tests that verify that git-lfs works with an actual real git-lfs server. This was not previously the case because the repo in the test was a simulation of git-lfs but not a real git lfs repo. The 2 added tests are almost the same but test that the git lfs file checkout is successfult with or without the lfs=1 flag. The lfs=1 URI parameter is a quirk that triggers 2 different code paths for git lfs. lfs=1, when used on git lfs repositories triggers the git lfs downloading at the fetch bare stage. lfs query parameter unset triggers the git lfs downloading only on checkout as an implicit behavior of git. This leads to possible network access on the unpack stage and outside the DL_DIR. lfs=0 actually disables git-lfs functionality even if supported. (cherry picked from commit d2be7f7f652360f13cd66d0850f3e19ffe2afb0a) (Bitbake rev: 2a6fd774405a58f3ef2953a0dc3eca063e0cf890) Signed-off-by: Paulo Neves <paulo@myneves.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org> Signed-off-by: Philip Lorenz <philip.lorenz@bmw.de> Signed-off-by: Steve Sakoman <steve@sakoman.com>
Diffstat (limited to 'bitbake/lib/bb')
-rw-r--r--bitbake/lib/bb/tests/fetch.py44
1 files changed, 44 insertions, 0 deletions
diff --git a/bitbake/lib/bb/tests/fetch.py b/bitbake/lib/bb/tests/fetch.py
index 743d3e3ff5..847a35602d 100644
--- a/bitbake/lib/bb/tests/fetch.py
+++ b/bitbake/lib/bb/tests/fetch.py
@@ -2159,6 +2159,12 @@ class GitShallowTest(FetcherTest):
2159 self.assertIn("fstests.doap", dir) 2159 self.assertIn("fstests.doap", dir)
2160 2160
2161class GitLfsTest(FetcherTest): 2161class GitLfsTest(FetcherTest):
2162 def skipIfNoGitLFS():
2163 import shutil
2164 if not shutil.which('git-lfs'):
2165 return unittest.skip('git-lfs not installed')
2166 return lambda f: f
2167
2162 def setUp(self): 2168 def setUp(self):
2163 FetcherTest.setUp(self) 2169 FetcherTest.setUp(self)
2164 2170
@@ -2192,6 +2198,44 @@ class GitLfsTest(FetcherTest):
2192 ud = fetcher.ud[uri] 2198 ud = fetcher.ud[uri]
2193 return fetcher, ud 2199 return fetcher, ud
2194 2200
2201 def get_real_git_lfs_file(self):
2202 self.d.setVar('PATH', os.environ.get('PATH'))
2203 fetcher, ud = self.fetch()
2204 fetcher.unpack(self.d.getVar('WORKDIR'))
2205 unpacked_lfs_file = os.path.join(self.d.getVar('WORKDIR'), 'git', "Cat_poster_1.jpg")
2206 return unpacked_lfs_file
2207
2208 @skipIfNoGitLFS()
2209 @skipIfNoNetwork()
2210 def test_real_git_lfs_repo_succeeds_without_lfs_param(self):
2211 self.d.setVar('SRC_URI', "git://gitlab.com/gitlab-examples/lfs.git;protocol=https;branch=master")
2212 f = self.get_real_git_lfs_file()
2213 self.assertTrue(os.path.exists(f))
2214 self.assertEqual("c0baab607a97839c9a328b4310713307", bb.utils.md5_file(f))
2215
2216 @skipIfNoGitLFS()
2217 @skipIfNoNetwork()
2218 def test_real_git_lfs_repo_succeeds(self):
2219 self.d.setVar('SRC_URI', "git://gitlab.com/gitlab-examples/lfs.git;protocol=https;branch=master;lfs=1")
2220 f = self.get_real_git_lfs_file()
2221 self.assertTrue(os.path.exists(f))
2222 self.assertEqual("c0baab607a97839c9a328b4310713307", bb.utils.md5_file(f))
2223
2224 @skipIfNoGitLFS()
2225 @skipIfNoNetwork()
2226 def test_real_git_lfs_repo_succeeds(self):
2227 self.d.setVar('SRC_URI', "git://gitlab.com/gitlab-examples/lfs.git;protocol=https;branch=master;lfs=0")
2228 f = self.get_real_git_lfs_file()
2229 # This is the actual non-smudged placeholder file on the repo if git-lfs does not run
2230 lfs_file = (
2231 'version https://git-lfs.github.com/spec/v1\n'
2232 'oid sha256:34be66b1a39a1955b46a12588df9d5f6fc1da790e05cf01f3c7422f4bbbdc26b\n'
2233 'size 11423554\n'
2234 )
2235
2236 with open(f) as fh:
2237 self.assertEqual(lfs_file, fh.read())
2238
2195 def test_lfs_enabled(self): 2239 def test_lfs_enabled(self):
2196 import shutil 2240 import shutil
2197 2241