[2/2] selftest/bbtests: Add tests for git floating tag resolution

Message ID 20220210175417.2695557-2-richard.purdie@linuxfoundation.org
State Accepted, archived
Commit 33554ba3c034fc31744b27392afe751d645d6c2e
Headers show
Series [1/2] buildtools: Allow testsdk to access the network | expand

Commit Message

Richard Purdie Feb. 10, 2022, 5:54 p.m. UTC
This test ensures that where a floating tag is used for a git url, there
aren't a number of different bugs such as inconsistent source revisions
for the tag within a given build and that the recipe is reparsed at each
run to ensure the tag is checked.

A test is also added to ensure that the build fails if SRCPV (get_srcrev())
isn't used yet there is a floating tag.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
---
 .../gitunpackoffline/gitunpackoffline-fail.bb         | 11 +++++++++++
 .../recipes-test/gitunpackoffline/gitunpackoffline.bb |  6 ++++++
 meta/lib/oeqa/selftest/cases/bbtests.py               |  8 ++++++++
 3 files changed, 25 insertions(+)
 create mode 100644 meta-selftest/recipes-test/gitunpackoffline/gitunpackoffline-fail.bb
 create mode 100644 meta-selftest/recipes-test/gitunpackoffline/gitunpackoffline.bb

Patch

diff --git a/meta-selftest/recipes-test/gitunpackoffline/gitunpackoffline-fail.bb b/meta-selftest/recipes-test/gitunpackoffline/gitunpackoffline-fail.bb
new file mode 100644
index 00000000000..dbf1ef35a57
--- /dev/null
+++ b/meta-selftest/recipes-test/gitunpackoffline/gitunpackoffline-fail.bb
@@ -0,0 +1,11 @@ 
+SUMMARY = "Test recipe for fetching git submodules"
+HOMEPAGE = "https://git.yoctoproject.org/git/matchbox-panel-2"
+LICENSE = "GPL-2.0-or-later"
+LIC_FILES_CHKSUM = "file://COPYING;md5=94d55d512a9ba36caa9b7df079bae19f"
+
+INHIBIT_DEFAULT_DEPS = "1"
+
+# Deliberately have a tag which has to be resolved but ensure do_unpack doesn't access the network again.
+SRC_URI = "git://git.yoctoproject.org/git/matchbox-panel-2;branch=master;protocol=https;tag=2.10"
+
+S = "${WORKDIR}/git"
\ No newline at end of file
diff --git a/meta-selftest/recipes-test/gitunpackoffline/gitunpackoffline.bb b/meta-selftest/recipes-test/gitunpackoffline/gitunpackoffline.bb
new file mode 100644
index 00000000000..73bc2181591
--- /dev/null
+++ b/meta-selftest/recipes-test/gitunpackoffline/gitunpackoffline.bb
@@ -0,0 +1,6 @@ 
+require gitunpackoffline-fail.bb
+
+# Deliberately have a tag which has to be resolved but ensure do_unpack doesn't access the network again.
+SRC_URI = "git://git.yoctoproject.org/git/matchbox-panel-2;branch=master;protocol=https;tag=2.11"
+
+PV = "0.0+git${SRCPV}"
diff --git a/meta/lib/oeqa/selftest/cases/bbtests.py b/meta/lib/oeqa/selftest/cases/bbtests.py
index 246cb032bfb..8dd069b2977 100644
--- a/meta/lib/oeqa/selftest/cases/bbtests.py
+++ b/meta/lib/oeqa/selftest/cases/bbtests.py
@@ -312,3 +312,11 @@  INHERIT:remove = \"report-error\"
         self.assertFalse(fatal, "Failed to patch using PATCHTOOL=\"git\"")
         self.delete_recipeinc(test_recipe)
         bitbake('-cclean man-db')
+
+    def test_git_unpack_nonetwork(self):
+        bitbake('gitunpackoffline -c fetch')
+        bitbake('gitunpackoffline -c patch')
+
+    def test_git_unpack_nonetwork_fail(self):
+        result = bitbake('gitunpackoffline-fail -c fetch', ignore_status=True)
+        self.assertTrue("Recipe uses a floating tag/branch without a fixed SRCREV" in result.output, msg = "Recipe without PV set to SRCPV should have failed: %s" % result.output)