2018-05-12 04:58:27 +02:00
|
|
|
import os
|
2018-05-12 04:58:29 +02:00
|
|
|
import shutil
|
2018-05-12 04:58:27 +02:00
|
|
|
|
|
|
|
from gitremote import GitRemote
|
|
|
|
|
|
|
|
import infra
|
|
|
|
|
|
|
|
|
2019-02-06 04:25:30 +01:00
|
|
|
class GitTestBase(infra.basetest.BRConfigTest):
|
2018-05-12 04:58:27 +02:00
|
|
|
config = \
|
|
|
|
"""
|
|
|
|
BR2_BACKUP_SITE=""
|
|
|
|
"""
|
|
|
|
gitremotedir = infra.filepath("tests/download/git-remote")
|
|
|
|
gitremote = None
|
|
|
|
|
|
|
|
def setUp(self):
|
|
|
|
super(GitTestBase, self).setUp()
|
|
|
|
self.gitremote = GitRemote(self.builddir, self.gitremotedir, self.logtofile)
|
|
|
|
|
|
|
|
def tearDown(self):
|
|
|
|
self.show_msg("Cleaning up")
|
|
|
|
if self.gitremote:
|
|
|
|
self.gitremote.stop()
|
|
|
|
if self.b and not self.keepbuilds:
|
|
|
|
self.b.delete()
|
|
|
|
|
|
|
|
def check_hash(self, package):
|
|
|
|
# store downloaded tarball inside the output dir so the test infra
|
|
|
|
# cleans it up at the end
|
|
|
|
env = {"BR2_DL_DIR": os.path.join(self.builddir, "dl"),
|
|
|
|
"GITREMOTE_PORT_NUMBER": str(self.gitremote.port)}
|
|
|
|
self.b.build(["{}-dirclean".format(package),
|
|
|
|
"{}-source".format(package)],
|
|
|
|
env)
|
|
|
|
|
2018-05-12 04:58:28 +02:00
|
|
|
def check_download(self, package):
|
|
|
|
# store downloaded tarball inside the output dir so the test infra
|
|
|
|
# cleans it up at the end
|
2018-05-12 04:58:29 +02:00
|
|
|
dl_dir = os.path.join(self.builddir, "dl")
|
|
|
|
# enforce we test the download
|
|
|
|
if os.path.exists(dl_dir):
|
|
|
|
shutil.rmtree(dl_dir)
|
|
|
|
env = {"BR2_DL_DIR": dl_dir,
|
2018-05-12 04:58:28 +02:00
|
|
|
"GITREMOTE_PORT_NUMBER": str(self.gitremote.port)}
|
|
|
|
self.b.build(["{}-dirclean".format(package),
|
|
|
|
"{}-legal-info".format(package)],
|
|
|
|
env)
|
|
|
|
|
2018-05-12 04:58:27 +02:00
|
|
|
|
|
|
|
class TestGitHash(GitTestBase):
|
|
|
|
br2_external = [infra.filepath("tests/download/br2-external/git-hash")]
|
|
|
|
|
|
|
|
def test_run(self):
|
|
|
|
with self.assertRaises(SystemError):
|
|
|
|
self.check_hash("bad")
|
|
|
|
self.check_hash("good")
|
|
|
|
self.check_hash("nohash")
|
2018-05-12 04:58:28 +02:00
|
|
|
|
|
|
|
|
|
|
|
class TestGitRefs(GitTestBase):
|
|
|
|
br2_external = [infra.filepath("tests/download/br2-external/git-refs")]
|
|
|
|
|
|
|
|
def test_run(self):
|
|
|
|
with self.assertRaises(SystemError):
|
|
|
|
self.check_download("git-wrong-content")
|
|
|
|
with self.assertRaises(SystemError):
|
|
|
|
self.check_download("git-wrong-sha1")
|
2018-05-12 04:58:29 +02:00
|
|
|
self.check_download("git-partial-sha1-branch-head")
|
|
|
|
self.check_download("git-partial-sha1-reachable-by-branch")
|
2018-05-12 04:58:31 +02:00
|
|
|
self.check_download("git-partial-sha1-reachable-by-tag")
|
|
|
|
self.check_download("git-partial-sha1-tag-itself")
|
|
|
|
self.check_download("git-partial-sha1-tag-points-to")
|
2018-05-12 04:58:29 +02:00
|
|
|
self.check_download("git-sha1-branch-head")
|
|
|
|
self.check_download("git-sha1-reachable-by-branch")
|
2018-05-12 04:58:31 +02:00
|
|
|
self.check_download("git-sha1-reachable-by-tag")
|
|
|
|
self.check_download("git-sha1-tag-itself")
|
|
|
|
self.check_download("git-sha1-tag-points-to")
|
2018-05-12 04:58:30 +02:00
|
|
|
self.check_download("git-submodule-disabled")
|
|
|
|
self.check_download("git-submodule-enabled")
|
2018-05-12 04:58:31 +02:00
|
|
|
self.check_download("git-tag")
|