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.fs.test_ext.TestExt2: *runtime_test
tests.fs.test_ext.TestExt2r1: *runtime_test
tests.fs.test_ext.TestExt3: *runtime_test
--- /dev/null
+name: GIT_HASH
--- /dev/null
+include $(sort $(wildcard $(BR2_EXTERNAL_GIT_HASH_PATH)/package/*/*.mk))
+
+# Get the git server port number from the test infra
+GITREMOTE_PORT_NUMBER ?= 9418
--- /dev/null
+sha256 0000000000000000000000000000000000000000000000000000000000000000 bad-a238b1dfcd825d47d834af3c5223417c8411d90d.tar.gz
--- /dev/null
+################################################################################
+#
+# bad
+#
+################################################################################
+
+BAD_VERSION = a238b1dfcd825d47d834af3c5223417c8411d90d
+BAD_SITE = git://localhost:$(GITREMOTE_PORT_NUMBER)/repo.git
+
+$(eval $(generic-package))
--- /dev/null
+sha256 d00ae598e9e770d607621a86766030b42eaa58156cb8d482b043969da7963c23 good-a238b1dfcd825d47d834af3c5223417c8411d90d.tar.gz
--- /dev/null
+################################################################################
+#
+# good
+#
+################################################################################
+
+GOOD_VERSION = a238b1dfcd825d47d834af3c5223417c8411d90d
+GOOD_SITE = git://localhost:$(GITREMOTE_PORT_NUMBER)/repo.git
+
+$(eval $(generic-package))
--- /dev/null
+################################################################################
+#
+# nohash
+#
+################################################################################
+
+NOHASH_VERSION = a238b1dfcd825d47d834af3c5223417c8411d90d
+NOHASH_SITE = git://localhost:$(GITREMOTE_PORT_NUMBER)/repo.git
+
+$(eval $(generic-package))
--- /dev/null
+objects/*/* binary
--- /dev/null
+ref: refs/heads/master
--- /dev/null
+[core]
+ repositoryformatversion = 0
+ filemode = true
+ bare = true
--- /dev/null
+x\ 1ÎM\ e \10@a×\9cb.Ð\ 6¨\94b\8cñ\ 2nô\ 4Ã_\9d´@\82¸ðö6qáÞ¸ý\16/Ï\95\94¨\81ÔÓ®Õ\10À\98(Ã\10\84³BEc\95\8c(M\1cG?LÜ{ä£ðFh´\f\9fí^*\Éaõ\ 5.X\eeW\1e\vÁ±~°O_<Ï ií]I'\10\8ak£ô´×Ðñ\81s¶é6ÑÂ\9fr\8c25Â\95±\eÍ9ø®ÄØÙ×á\97Yö\ 6lÚ`C
\ No newline at end of file
--- /dev/null
+a238b1dfcd825d47d834af3c5223417c8411d90d
--- /dev/null
+# subprocess does not kill the child daemon when a test case fails by raising
+# an exception. So use pexpect instead.
+import infra
+
+import pexpect
+
+
+GIT_REMOTE_PORT_INITIAL = 9418
+GIT_REMOTE_PORT_LAST = GIT_REMOTE_PORT_INITIAL + 99
+
+
+class GitRemote(object):
+ def __init__(self, builddir, serveddir, logtofile):
+ """
+ Start a local git server.
+
+ In order to support test cases in parallel, select the port the
+ server will listen to in runtime. Since there is no reliable way
+ to allocate the port prior to starting the server (another
+ process in the host machine can use the port between it is
+ selected from a list and it is really allocated to the server)
+ try to start the server in a port and in the case it is already
+ in use, try the next one in the allowed range.
+ """
+ self.daemon = None
+ self.port = None
+ self.logfile = infra.open_log_file(builddir, "gitremote", logtofile)
+
+ daemon_cmd = ["git", "daemon", "--reuseaddr", "--verbose",
+ "--listen=localhost", "--export-all",
+ "--base-path={}".format(serveddir)]
+ for port in range(GIT_REMOTE_PORT_INITIAL, GIT_REMOTE_PORT_LAST + 1):
+ cmd = daemon_cmd + ["--port={port}".format(port=port)]
+ self.logfile.write("> starting git remote with '{}'\n".format(" ".join(cmd)))
+ self.daemon = pexpect.spawn(cmd[0], cmd[1:], logfile=self.logfile)
+ ret = self.daemon.expect(["Ready to rumble",
+ "Address already in use"])
+ if ret == 0:
+ self.port = port
+ return
+ raise SystemError("Could not find a free port to run git remote")
+
+ def stop(self):
+ if self.daemon is None:
+ return
+ self.daemon.terminate(force=True)
--- /dev/null
+import os
+
+from gitremote import GitRemote
+
+import infra
+
+
+class GitTestBase(infra.basetest.BRTest):
+ 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)
+
+
+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")