[v5,06/10] testing/tests/download: test git branch

Message ID 20180512025833.22998-7-ricardo.martincoski@gmail.com
State New
Headers show
Series
  • tests for git download infra v5
Related show

Commit Message

Ricardo Martincoski May 12, 2018, 2:58 a.m.
Add a branch to the static repo and check on the git refs test case the
download of a git package:
 - with a sha1 reachable by a branch name, but not pointed by it, as
   version. This is the most common use case for git refs in the tree;
 - with a partial sha1 of a commit reachable by a branch as version;
 - with a sha1 of the commit head of a branch as version;
 - with a partial sha1 of the commit head of a branch as version;

Enforce the download always occurs by removing the BR2_DL_DIR used for
the tarballs generated by the git download infra.

Signed-off-by: Ricardo Martincoski <ricardo.martincoski@datacom.ind.br>
Cc: Arnout Vandecappelle <arnout@mind.be>
---
Layout of static repo with the series applied until this patch:
 $ git -C support/testing/tests/download/git-remote/repo.git \
   log --all --decorate --graph --oneline --decorate
 * 68c197d (mybranch) branch2
 * 3174063 branch1
 * a238b1d (HEAD -> master) initial

Changes v4 -> v5:
  - do not test a named branch, Buildroot does not support it;

Changes v3 -> v4:
  - no functional changes;
  - fix old comment on the code;

Changes v2 -> v3:
  - complete rewrite using a static repo;
---
 .../git-partial-sha1-branch-head.hash             |   2 ++
 .../git-partial-sha1-branch-head.mk               |  11 +++++++++++
 .../git-partial-sha1-reachable-by-branch.hash     |   2 ++
 .../git-partial-sha1-reachable-by-branch.mk       |  11 +++++++++++
 .../git-sha1-branch-head.hash                     |   2 ++
 .../git-sha1-branch-head/git-sha1-branch-head.mk  |  11 +++++++++++
 .../git-sha1-reachable-by-branch.hash             |   2 ++
 .../git-sha1-reachable-by-branch.mk               |  11 +++++++++++
 .../11/93ff46343f4f6a0522e2b28b871e905178c1f0     | Bin 0 -> 23 bytes
 .../31/7406308d9259e2231bd0d6ddad3de3832bce08     | Bin 0 -> 182 bytes
 .../34/d1da713bf7de1c535e1d7d3ca985afd84bc7e5     | Bin 0 -> 23 bytes
 .../68/c197d0879d485f4f6cee85544722b79e68e59f     | Bin 0 -> 184 bytes
 .../b2/4b387624edc78d0292a127c43cad9ba97c6232     | Bin 0 -> 49 bytes
 .../e2/cfe068f7e5bf4de32ffe1241da53abce9fa89e     | Bin 0 -> 49 bytes
 .../git-remote/repo.git/refs/heads/mybranch       |   1 +
 support/testing/tests/download/test_git.py        |  11 ++++++++++-
 16 files changed, 63 insertions(+), 1 deletion(-)
 create mode 100644 support/testing/tests/download/br2-external/git-refs/package/git-partial-sha1-branch-head/git-partial-sha1-branch-head.hash
 create mode 100644 support/testing/tests/download/br2-external/git-refs/package/git-partial-sha1-branch-head/git-partial-sha1-branch-head.mk
 create mode 100644 support/testing/tests/download/br2-external/git-refs/package/git-partial-sha1-reachable-by-branch/git-partial-sha1-reachable-by-branch.hash
 create mode 100644 support/testing/tests/download/br2-external/git-refs/package/git-partial-sha1-reachable-by-branch/git-partial-sha1-reachable-by-branch.mk
 create mode 100644 support/testing/tests/download/br2-external/git-refs/package/git-sha1-branch-head/git-sha1-branch-head.hash
 create mode 100644 support/testing/tests/download/br2-external/git-refs/package/git-sha1-branch-head/git-sha1-branch-head.mk
 create mode 100644 support/testing/tests/download/br2-external/git-refs/package/git-sha1-reachable-by-branch/git-sha1-reachable-by-branch.hash
 create mode 100644 support/testing/tests/download/br2-external/git-refs/package/git-sha1-reachable-by-branch/git-sha1-reachable-by-branch.mk
 create mode 100644 support/testing/tests/download/git-remote/repo.git/objects/11/93ff46343f4f6a0522e2b28b871e905178c1f0
 create mode 100644 support/testing/tests/download/git-remote/repo.git/objects/31/7406308d9259e2231bd0d6ddad3de3832bce08
 create mode 100644 support/testing/tests/download/git-remote/repo.git/objects/34/d1da713bf7de1c535e1d7d3ca985afd84bc7e5
 create mode 100644 support/testing/tests/download/git-remote/repo.git/objects/68/c197d0879d485f4f6cee85544722b79e68e59f
 create mode 100644 support/testing/tests/download/git-remote/repo.git/objects/b2/4b387624edc78d0292a127c43cad9ba97c6232
 create mode 100644 support/testing/tests/download/git-remote/repo.git/objects/e2/cfe068f7e5bf4de32ffe1241da53abce9fa89e
 create mode 100644 support/testing/tests/download/git-remote/repo.git/refs/heads/mybranch

Patch

diff --git a/support/testing/tests/download/br2-external/git-refs/package/git-partial-sha1-branch-head/git-partial-sha1-branch-head.hash b/support/testing/tests/download/br2-external/git-refs/package/git-partial-sha1-branch-head/git-partial-sha1-branch-head.hash
new file mode 100644
index 0000000000..648bcceca0
--- /dev/null
+++ b/support/testing/tests/download/br2-external/git-refs/package/git-partial-sha1-branch-head/git-partial-sha1-branch-head.hash
@@ -0,0 +1,2 @@ 
+sha256  70b76187369e47db69dac02c5696e63b35199cd20490fa473d289dd377774613  git-partial-sha1-branch-head-68c197d0879d485f4f6c.tar.gz
+sha256  2c1126513651b0d346a4e6d1bb75ac1c9999217e18026302d27bea47b06c7fb2  file
diff --git a/support/testing/tests/download/br2-external/git-refs/package/git-partial-sha1-branch-head/git-partial-sha1-branch-head.mk b/support/testing/tests/download/br2-external/git-refs/package/git-partial-sha1-branch-head/git-partial-sha1-branch-head.mk
new file mode 100644
index 0000000000..6d4177c5bf
--- /dev/null
+++ b/support/testing/tests/download/br2-external/git-refs/package/git-partial-sha1-branch-head/git-partial-sha1-branch-head.mk
@@ -0,0 +1,11 @@ 
+################################################################################
+#
+# git-partial-sha1-branch-head
+#
+################################################################################
+
+GIT_PARTIAL_SHA1_BRANCH_HEAD_VERSION = 68c197d0879d485f4f6c
+GIT_PARTIAL_SHA1_BRANCH_HEAD_SITE = git://localhost:$(GITREMOTE_PORT_NUMBER)/repo.git
+GIT_PARTIAL_SHA1_BRANCH_HEAD_LICENSE_FILES = file
+
+$(eval $(generic-package))
diff --git a/support/testing/tests/download/br2-external/git-refs/package/git-partial-sha1-reachable-by-branch/git-partial-sha1-reachable-by-branch.hash b/support/testing/tests/download/br2-external/git-refs/package/git-partial-sha1-reachable-by-branch/git-partial-sha1-reachable-by-branch.hash
new file mode 100644
index 0000000000..d064362e2c
--- /dev/null
+++ b/support/testing/tests/download/br2-external/git-refs/package/git-partial-sha1-reachable-by-branch/git-partial-sha1-reachable-by-branch.hash
@@ -0,0 +1,2 @@ 
+sha256  9db079b9e215799d59975db7b2b26671eff1932ee6cf1075296f2ace3e2cb746  git-partial-sha1-reachable-by-branch-317406308d9259e2231b.tar.gz
+sha256  fabbc65c442bacb5e69b7adfea6d14fbbfc1327134322efd12771dc84387d507  file
diff --git a/support/testing/tests/download/br2-external/git-refs/package/git-partial-sha1-reachable-by-branch/git-partial-sha1-reachable-by-branch.mk b/support/testing/tests/download/br2-external/git-refs/package/git-partial-sha1-reachable-by-branch/git-partial-sha1-reachable-by-branch.mk
new file mode 100644
index 0000000000..2f65b5c9a9
--- /dev/null
+++ b/support/testing/tests/download/br2-external/git-refs/package/git-partial-sha1-reachable-by-branch/git-partial-sha1-reachable-by-branch.mk
@@ -0,0 +1,11 @@ 
+################################################################################
+#
+# git-partial-sha1-reachable-by-branch
+#
+################################################################################
+
+GIT_PARTIAL_SHA1_REACHABLE_BY_BRANCH_VERSION = 317406308d9259e2231b
+GIT_PARTIAL_SHA1_REACHABLE_BY_BRANCH_SITE = git://localhost:$(GITREMOTE_PORT_NUMBER)/repo.git
+GIT_PARTIAL_SHA1_REACHABLE_BY_BRANCH_LICENSE_FILES = file
+
+$(eval $(generic-package))
diff --git a/support/testing/tests/download/br2-external/git-refs/package/git-sha1-branch-head/git-sha1-branch-head.hash b/support/testing/tests/download/br2-external/git-refs/package/git-sha1-branch-head/git-sha1-branch-head.hash
new file mode 100644
index 0000000000..3e8f76d31a
--- /dev/null
+++ b/support/testing/tests/download/br2-external/git-refs/package/git-sha1-branch-head/git-sha1-branch-head.hash
@@ -0,0 +1,2 @@ 
+sha256  a21a2507b6d94ad484e49e3a9ae698f672a57469aab8e1779da77df7c9d4d337  git-sha1-branch-head-68c197d0879d485f4f6cee85544722b79e68e59f.tar.gz
+sha256  2c1126513651b0d346a4e6d1bb75ac1c9999217e18026302d27bea47b06c7fb2  file
diff --git a/support/testing/tests/download/br2-external/git-refs/package/git-sha1-branch-head/git-sha1-branch-head.mk b/support/testing/tests/download/br2-external/git-refs/package/git-sha1-branch-head/git-sha1-branch-head.mk
new file mode 100644
index 0000000000..d3ecaa8593
--- /dev/null
+++ b/support/testing/tests/download/br2-external/git-refs/package/git-sha1-branch-head/git-sha1-branch-head.mk
@@ -0,0 +1,11 @@ 
+################################################################################
+#
+# git-sha1-branch-head
+#
+################################################################################
+
+GIT_SHA1_BRANCH_HEAD_VERSION = 68c197d0879d485f4f6cee85544722b79e68e59f
+GIT_SHA1_BRANCH_HEAD_SITE = git://localhost:$(GITREMOTE_PORT_NUMBER)/repo.git
+GIT_SHA1_BRANCH_HEAD_LICENSE_FILES = file
+
+$(eval $(generic-package))
diff --git a/support/testing/tests/download/br2-external/git-refs/package/git-sha1-reachable-by-branch/git-sha1-reachable-by-branch.hash b/support/testing/tests/download/br2-external/git-refs/package/git-sha1-reachable-by-branch/git-sha1-reachable-by-branch.hash
new file mode 100644
index 0000000000..f8d7b5dc48
--- /dev/null
+++ b/support/testing/tests/download/br2-external/git-refs/package/git-sha1-reachable-by-branch/git-sha1-reachable-by-branch.hash
@@ -0,0 +1,2 @@ 
+sha256  8909e76d898e651af0bc23fae4103b87888bfe77448d71aaf1fbec3da97a3ce2  git-sha1-reachable-by-branch-317406308d9259e2231bd0d6ddad3de3832bce08.tar.gz
+sha256  fabbc65c442bacb5e69b7adfea6d14fbbfc1327134322efd12771dc84387d507  file
diff --git a/support/testing/tests/download/br2-external/git-refs/package/git-sha1-reachable-by-branch/git-sha1-reachable-by-branch.mk b/support/testing/tests/download/br2-external/git-refs/package/git-sha1-reachable-by-branch/git-sha1-reachable-by-branch.mk
new file mode 100644
index 0000000000..badf9e13ca
--- /dev/null
+++ b/support/testing/tests/download/br2-external/git-refs/package/git-sha1-reachable-by-branch/git-sha1-reachable-by-branch.mk
@@ -0,0 +1,11 @@ 
+################################################################################
+#
+# git-sha1-reachable-by-branch
+#
+################################################################################
+
+GIT_SHA1_REACHABLE_BY_BRANCH_VERSION = 317406308d9259e2231bd0d6ddad3de3832bce08
+GIT_SHA1_REACHABLE_BY_BRANCH_SITE = git://localhost:$(GITREMOTE_PORT_NUMBER)/repo.git
+GIT_SHA1_REACHABLE_BY_BRANCH_LICENSE_FILES = file
+
+$(eval $(generic-package))
diff --git a/support/testing/tests/download/git-remote/repo.git/objects/11/93ff46343f4f6a0522e2b28b871e905178c1f0 b/support/testing/tests/download/git-remote/repo.git/objects/11/93ff46343f4f6a0522e2b28b871e905178c1f0
new file mode 100644
index 0000000000000000000000000000000000000000..3541cd14f0bf5f3a172f868c7ec730dcc255ebd2
GIT binary patch
literal 23
fcmb<m^geacKWIaOhnCkF?{fxEm>AT(SQY{RanuOb

literal 0
HcmV?d00001

diff --git a/support/testing/tests/download/git-remote/repo.git/objects/31/7406308d9259e2231bd0d6ddad3de3832bce08 b/support/testing/tests/download/git-remote/repo.git/objects/31/7406308d9259e2231bd0d6ddad3de3832bce08
new file mode 100644
index 0000000000000000000000000000000000000000..c2c986572a7dec5f263e461155a09124d0f05844
GIT binary patch
literal 182
zcmV;n07?IN0j<tEP6II%Kv8P1!W)>#-;9k=lnv036+FLBVg-+p;}q<kNGa$M?J2G<
z_SWju-tAxJVAkwV*zA+69E${E??l+TU<sm!f}90XX7vSwx2eJTR4fTna*@JH$p;XR
z(K#RNiYZu2*^q+!y!4?zD#D<y-(k$UVZU9gej88RwO>4*8`RGo_IA)Vnl;DdW7doD
k#;AurrYHYXPL%;0UaV55dfu3pF0z#G*T2lF9~m)jQ^MU{p#T5?

literal 0
HcmV?d00001

diff --git a/support/testing/tests/download/git-remote/repo.git/objects/34/d1da713bf7de1c535e1d7d3ca985afd84bc7e5 b/support/testing/tests/download/git-remote/repo.git/objects/34/d1da713bf7de1c535e1d7d3ca985afd84bc7e5
new file mode 100644
index 0000000000000000000000000000000000000000..29f2d4fd004afa03b43e3148207e258e7aa9fc41
GIT binary patch
literal 23
fcmb<m^geacKWIaOhnCkF?{fx^m>AT3SQY^Qam@(V

literal 0
HcmV?d00001

diff --git a/support/testing/tests/download/git-remote/repo.git/objects/68/c197d0879d485f4f6cee85544722b79e68e59f b/support/testing/tests/download/git-remote/repo.git/objects/68/c197d0879d485f4f6cee85544722b79e68e59f
new file mode 100644
index 0000000000000000000000000000000000000000..3e421bb97a40ab93592d94107f3a1258a99b76fa
GIT binary patch
literal 184
zcmV;p07w6L0j<tGP6IIzhGA--!WY=cJG1K_gb){?AtxBmOcE=2jf^R{Ju9V1AJIP2
z_vz(UYZ(^7KaH+xGb|Zn@UW<Gh~gjt%@BA&CP|r6U=Il9i@I+6a1M*}=%OT8lLFwJ
z#fcXoK~andnbk!@KjYH6{U}Ubnti7}%Es;cTI@@|;i2B~?OdsR9=O$4JFhOJHKIp5
mIdsnKx<?QFr#q87ZF~V^j^(_mOzm`<^6&E_vE~mXVr;h@Dp>;n

literal 0
HcmV?d00001

diff --git a/support/testing/tests/download/git-remote/repo.git/objects/b2/4b387624edc78d0292a127c43cad9ba97c6232 b/support/testing/tests/download/git-remote/repo.git/objects/b2/4b387624edc78d0292a127c43cad9ba97c6232
new file mode 100644
index 0000000000000000000000000000000000000000..20491e3f176096db13c0b0c7857406e1c4119619
GIT binary patch
literal 49
zcmV-10M7q-0V^p=O;s>9VlXr?Ff%bxNXyJgWiYvTtI+!UJ(=J**;<>Gt?O@iAAbq}
H3k46<$LbTr

literal 0
HcmV?d00001

diff --git a/support/testing/tests/download/git-remote/repo.git/objects/e2/cfe068f7e5bf4de32ffe1241da53abce9fa89e b/support/testing/tests/download/git-remote/repo.git/objects/e2/cfe068f7e5bf4de32ffe1241da53abce9fa89e
new file mode 100644
index 0000000000000000000000000000000000000000..57be6485778c7f743a82f71ef718103cecfd4f35
GIT binary patch
literal 49
zcmb<m)YkO!4K*-JGB7bPFg6VIIDN)5RbbAa`)7~bv+oXld2!jhvYnibqU`nz3}1Tr
F^a08O6TJWc

literal 0
HcmV?d00001

diff --git a/support/testing/tests/download/git-remote/repo.git/refs/heads/mybranch b/support/testing/tests/download/git-remote/repo.git/refs/heads/mybranch
new file mode 100644
index 0000000000..45cec54673
--- /dev/null
+++ b/support/testing/tests/download/git-remote/repo.git/refs/heads/mybranch
@@ -0,0 +1 @@ 
+68c197d0879d485f4f6cee85544722b79e68e59f
diff --git a/support/testing/tests/download/test_git.py b/support/testing/tests/download/test_git.py
index fdfc858233..279d0ed8eb 100644
--- a/support/testing/tests/download/test_git.py
+++ b/support/testing/tests/download/test_git.py
@@ -1,4 +1,5 @@ 
 import os
+import shutil
 
 import infra
 from gitremote import GitRemote
@@ -35,7 +36,11 @@  class GitTestBase(infra.basetest.BRTest):
     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"),
+        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,
                "GITREMOTE_PORT_NUMBER": str(self.gitremote.port)}
         self.b.build(["{}-dirclean".format(package),
                       "{}-legal-info".format(package)],
@@ -60,3 +65,7 @@  class TestGitRefs(GitTestBase):
             self.check_download("git-wrong-content")
         with self.assertRaises(SystemError):
             self.check_download("git-wrong-sha1")
+        self.check_download("git-partial-sha1-branch-head")
+        self.check_download("git-partial-sha1-reachable-by-branch")
+        self.check_download("git-sha1-branch-head")
+        self.check_download("git-sha1-reachable-by-branch")