Message ID | 20180512025833.22998-6-ricardo.martincoski@gmail.com |
---|---|
State | Accepted |
Headers | show |
Series | tests for git download infra v5 | expand |
On 12/05/2018 04:58, Ricardo Martincoski wrote: [snip] > create mode 100644 support/testing/tests/download/br2-external/git-refs/Config.in > create mode 100644 support/testing/tests/download/br2-external/git-refs/external.desc > create mode 100644 support/testing/tests/download/br2-external/git-refs/external.mk I don't think it makes a whole lot of sense to make a separate external for this; it would seem easier to put everything in a single external (and move the br2_external setting to GitTestBase). But that can be fixed in a follow-up patch, so applied to master, thanks. [snip] > + def check_download(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), > + "{}-legal-info".format(package)], Here there's also a refactoring opportunity, since this function only differs with check_hash in this one line. Regards, Arnout > + env) > + > > class TestGitHash(GitTestBase): > br2_external = [infra.filepath("tests/download/br2-external/git-hash")] > @@ -41,3 +50,13 @@ class TestGitHash(GitTestBase): > self.check_hash("bad") > self.check_hash("good") > self.check_hash("nohash") > + > + > +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") >
Hello, On Mon, Feb 04, 2019 at 05:48 PM, Arnout Vandecappelle wrote: > On 12/05/2018 04:58, Ricardo Martincoski wrote: > [snip] >> create mode 100644 support/testing/tests/download/br2-external/git-refs/Config.in >> create mode 100644 support/testing/tests/download/br2-external/git-refs/external.desc >> create mode 100644 support/testing/tests/download/br2-external/git-refs/external.mk > > I don't think it makes a whole lot of sense to make a separate external for > this; it would seem easier to put everything in a single external (and move the > br2_external setting to GitTestBase). But that can be fixed in a follow-up > patch, so applied to master, thanks. I don't remember if there was any reason to keep them separate. Indeed it seems they can be merged. I will add to my todo list. > > [snip] >> + def check_download(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), >> + "{}-legal-info".format(package)], > > Here there's also a refactoring opportunity, since this function only differs > with check_hash in this one line. I will take a look. Regards, Ricardo
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 27b0255343..61ccfdfd2d 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -264,6 +264,7 @@ tests.core.test_timezone.TestGlibcAllTimezone: *runtime_test tests.core.test_timezone.TestGlibcNonDefaultLimitedTimezone: *runtime_test tests.core.test_timezone.TestNoTimezone: *runtime_test tests.download.test_git.TestGitHash: *runtime_test +tests.download.test_git.TestGitRefs: *runtime_test tests.fs.test_ext.TestExt2: *runtime_test tests.fs.test_ext.TestExt2r1: *runtime_test tests.fs.test_ext.TestExt3: *runtime_test diff --git a/support/testing/tests/download/br2-external/git-refs/Config.in b/support/testing/tests/download/br2-external/git-refs/Config.in new file mode 100644 index 0000000000..e69de29bb2 diff --git a/support/testing/tests/download/br2-external/git-refs/external.desc b/support/testing/tests/download/br2-external/git-refs/external.desc new file mode 100644 index 0000000000..69f40d46c6 --- /dev/null +++ b/support/testing/tests/download/br2-external/git-refs/external.desc @@ -0,0 +1 @@ +name: GIT_REFS diff --git a/support/testing/tests/download/br2-external/git-refs/external.mk b/support/testing/tests/download/br2-external/git-refs/external.mk new file mode 100644 index 0000000000..ab38c27eb7 --- /dev/null +++ b/support/testing/tests/download/br2-external/git-refs/external.mk @@ -0,0 +1,4 @@ +include $(sort $(wildcard $(BR2_EXTERNAL_GIT_REFS_PATH)/package/*/*.mk)) + +# Get the git server port number from the test infra +GITREMOTE_PORT_NUMBER ?= 9418 diff --git a/support/testing/tests/download/br2-external/git-refs/package/git-wrong-content/git-wrong-content.hash b/support/testing/tests/download/br2-external/git-refs/package/git-wrong-content/git-wrong-content.hash new file mode 100644 index 0000000000..47b2b8b7d7 --- /dev/null +++ b/support/testing/tests/download/br2-external/git-refs/package/git-wrong-content/git-wrong-content.hash @@ -0,0 +1,2 @@ + sha256 04715901977503d1df650e0959f4d31d8e7b105e2ac99a2182e0652b8f13baa1 git-wrong-content-a238b1dfcd825d47d834af3c5223417c8411d90d.tar.gz + sha256 0000000000000000000000000000000000000000000000000000000000000000 file diff --git a/support/testing/tests/download/br2-external/git-refs/package/git-wrong-content/git-wrong-content.mk b/support/testing/tests/download/br2-external/git-refs/package/git-wrong-content/git-wrong-content.mk new file mode 100644 index 0000000000..786224dad9 --- /dev/null +++ b/support/testing/tests/download/br2-external/git-refs/package/git-wrong-content/git-wrong-content.mk @@ -0,0 +1,11 @@ +################################################################################ +# +# git-wrong-content +# +################################################################################ + +GIT_WRONG_CONTENT_VERSION = a238b1dfcd825d47d834af3c5223417c8411d90d +GIT_WRONG_CONTENT_SITE = git://localhost:$(GITREMOTE_PORT_NUMBER)/repo.git +GIT_WRONG_CONTENT_LICENSE_FILES = file + +$(eval $(generic-package)) diff --git a/support/testing/tests/download/br2-external/git-refs/package/git-wrong-sha1/git-wrong-sha1.mk b/support/testing/tests/download/br2-external/git-refs/package/git-wrong-sha1/git-wrong-sha1.mk new file mode 100644 index 0000000000..f9d0d2226c --- /dev/null +++ b/support/testing/tests/download/br2-external/git-refs/package/git-wrong-sha1/git-wrong-sha1.mk @@ -0,0 +1,11 @@ +################################################################################ +# +# git-wrong-sha1 +# +################################################################################ + +GIT_WRONG_SHA1_VERSION = 0000000000000000000000000000000000000000 +GIT_WRONG_SHA1_SITE = git://localhost:$(GITREMOTE_PORT_NUMBER)/repo.git +GIT_WRONG_SHA1_LICENSE_FILES = file + +$(eval $(generic-package)) diff --git a/support/testing/tests/download/test_git.py b/support/testing/tests/download/test_git.py index 14fc8e4da3..fdfc858233 100644 --- a/support/testing/tests/download/test_git.py +++ b/support/testing/tests/download/test_git.py @@ -32,6 +32,15 @@ class GitTestBase(infra.basetest.BRTest): "{}-source".format(package)], env) + def check_download(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), + "{}-legal-info".format(package)], + env) + class TestGitHash(GitTestBase): br2_external = [infra.filepath("tests/download/br2-external/git-hash")] @@ -41,3 +50,13 @@ class TestGitHash(GitTestBase): self.check_hash("bad") self.check_hash("good") self.check_hash("nohash") + + +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")