diff mbox series

[v2,2/2] selftest/devtool: add devtool upgrade selftest for recipes with git submodules

Message ID 20250813092042.247966-3-pistora.tobias@gmail.com
State New
Headers show
Series devtool: fix upgrade for recipes with git submodules | expand

Commit Message

Tobias Pistora Aug. 13, 2025, 9:20 a.m. UTC
Tests [YOCTO #15943]

Move code from test_devtool_upgrade_git() into separate, local function.
Add a test_devtool_upgrade_gitsm() selftest for devtool.
Add recipes for testing gitsm components.

Signed-off-by: Tobias Pistora <pistora.tobias@gmail.com>
---
changes in v2:
- this patch was added in v2

 .../devtool/devtool-upgrade-test5_git.bb      | 32 +++++++++++++++++++
 .../devtool-upgrade-test5_git.bb.upgraded     | 31 ++++++++++++++++++
 meta/lib/oeqa/selftest/cases/devtool.py       | 10 ++++--
 3 files changed, 70 insertions(+), 3 deletions(-)
 create mode 100644 meta-selftest/recipes-test/devtool/devtool-upgrade-test5_git.bb
 create mode 100644 meta-selftest/recipes-test/devtool/devtool-upgrade-test5_git.bb.upgraded

Comments

Alexander Kanavin Aug. 13, 2025, 9:28 a.m. UTC | #1
Awesome, I like the reuse of existing code (there's a tendency in
selftests to copy-paste-tweak instead).

Alex

On Wed, 13 Aug 2025 at 11:21, Tobias Pistora via
lists.openembedded.org
<pistora.tobias=gmail.com@lists.openembedded.org> wrote:
>
> Tests [YOCTO #15943]
>
> Move code from test_devtool_upgrade_git() into separate, local function.
> Add a test_devtool_upgrade_gitsm() selftest for devtool.
> Add recipes for testing gitsm components.
>
> Signed-off-by: Tobias Pistora <pistora.tobias@gmail.com>
> ---
> changes in v2:
> - this patch was added in v2
>
>  .../devtool/devtool-upgrade-test5_git.bb      | 32 +++++++++++++++++++
>  .../devtool-upgrade-test5_git.bb.upgraded     | 31 ++++++++++++++++++
>  meta/lib/oeqa/selftest/cases/devtool.py       | 10 ++++--
>  3 files changed, 70 insertions(+), 3 deletions(-)
>  create mode 100644 meta-selftest/recipes-test/devtool/devtool-upgrade-test5_git.bb
>  create mode 100644 meta-selftest/recipes-test/devtool/devtool-upgrade-test5_git.bb.upgraded
>
> diff --git a/meta-selftest/recipes-test/devtool/devtool-upgrade-test5_git.bb b/meta-selftest/recipes-test/devtool/devtool-upgrade-test5_git.bb
> new file mode 100644
> index 0000000000..7e8b001a28
> --- /dev/null
> +++ b/meta-selftest/recipes-test/devtool/devtool-upgrade-test5_git.bb
> @@ -0,0 +1,32 @@
> +SUMMARY = "Test recipe for fetching git submodules"
> +HOMEPAGE = "http://git.yoctoproject.org/cgit/cgit.cgi/git-submodule-test/"
> +LICENSE = "MIT"
> +LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
> +
> +INHIBIT_DEFAULT_DEPS = "1"
> +
> +# Note: this is intentionally not the latest version in the original .bb
> +SRCREV = "132fea6e4dee56b61bcf5721c94e8b2445c6a017"
> +PV = "0.1+git"
> +PR = "r2"
> +
> +SRC_URI = "gitsm://git.yoctoproject.org/git-submodule-test;branch=master"
> +UPSTREAM_CHECK_COMMITS = "1"
> +RECIPE_NO_UPDATE_REASON = "This recipe is used to test devtool upgrade feature"
> +
> +EXCLUDE_FROM_WORLD = "1"
> +
> +do_test_git_as_user() {
> +    cd ${S}
> +    git status
> +    git submodule status
> +}
> +addtask test_git_as_user after do_unpack
> +
> +fakeroot do_test_git_as_root() {
> +    cd ${S}
> +    git status
> +    git submodule status
> +}
> +do_test_git_as_root[depends] += "virtual/fakeroot-native:do_populate_sysroot"
> +addtask test_git_as_root after do_unpack
> \ No newline at end of file
> diff --git a/meta-selftest/recipes-test/devtool/devtool-upgrade-test5_git.bb.upgraded b/meta-selftest/recipes-test/devtool/devtool-upgrade-test5_git.bb.upgraded
> new file mode 100644
> index 0000000000..938c46b016
> --- /dev/null
> +++ b/meta-selftest/recipes-test/devtool/devtool-upgrade-test5_git.bb.upgraded
> @@ -0,0 +1,31 @@
> +SUMMARY = "Test recipe for fetching git submodules"
> +HOMEPAGE = "http://git.yoctoproject.org/cgit/cgit.cgi/git-submodule-test/"
> +LICENSE = "MIT"
> +LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
> +
> +INHIBIT_DEFAULT_DEPS = "1"
> +
> +# Note: this is intentionally not the latest version in the original .bb
> +SRCREV = "a2885dd7d25380d23627e7544b7bbb55014b16ee"
> +PV = "0.1+git"
> +
> +SRC_URI = "gitsm://git.yoctoproject.org/git-submodule-test;branch=master"
> +UPSTREAM_CHECK_COMMITS = "1"
> +RECIPE_NO_UPDATE_REASON = "This recipe is used to test devtool upgrade feature"
> +
> +EXCLUDE_FROM_WORLD = "1"
> +
> +do_test_git_as_user() {
> +    cd ${S}
> +    git status
> +    git submodule status
> +}
> +addtask test_git_as_user after do_unpack
> +
> +fakeroot do_test_git_as_root() {
> +    cd ${S}
> +    git status
> +    git submodule status
> +}
> +do_test_git_as_root[depends] += "virtual/fakeroot-native:do_populate_sysroot"
> +addtask test_git_as_root after do_unpack
> \ No newline at end of file
> diff --git a/meta/lib/oeqa/selftest/cases/devtool.py b/meta/lib/oeqa/selftest/cases/devtool.py
> index 580c567be3..19a205912b 100644
> --- a/meta/lib/oeqa/selftest/cases/devtool.py
> +++ b/meta/lib/oeqa/selftest/cases/devtool.py
> @@ -1958,13 +1958,11 @@ class DevtoolUpgradeTests(DevtoolBase):
>          self.assertNotIn(recipe, result.output)
>          self.assertNotExists(os.path.join(self.workspacedir, 'recipes', recipe), 'Recipe directory should not exist after resetting')
>
> -    def test_devtool_upgrade_git(self):
> +    def _test_devtool_upgrade_git_by_recipe(self, recipe, commit):
>          # Check preconditions
>          self.assertTrue(not os.path.exists(self.workspacedir), 'This test cannot be run with a workspace directory under the build directory')
>          self.track_for_cleanup(self.workspacedir)
>          self.add_command_to_tearDown('bitbake-layers remove-layer */workspace')
> -        recipe = 'devtool-upgrade-test2'
> -        commit = '6cc6077a36fe2648a5f993fe7c16c9632f946517'
>          oldrecipefile = get_bb_var('FILE', recipe)
>          tempdir = tempfile.mkdtemp(prefix='devtoolqa')
>          self.track_for_cleanup(tempdir)
> @@ -1994,6 +1992,12 @@ class DevtoolUpgradeTests(DevtoolBase):
>          self.assertNotIn(recipe, result.output)
>          self.assertNotExists(os.path.join(self.workspacedir, 'recipes', recipe), 'Recipe directory should not exist after resetting')
>
> +    def test_devtool_upgrade_git(self):
> +        self._test_devtool_upgrade_git_by_recipe('devtool-upgrade-test2', '6cc6077a36fe2648a5f993fe7c16c9632f946517')
> +
> +    def test_devtool_upgrade_gitsm(self):
> +        self._test_devtool_upgrade_git_by_recipe('devtool-upgrade-test5', 'a2885dd7d25380d23627e7544b7bbb55014b16ee')
> +
>      def test_devtool_upgrade_drop_md5sum(self):
>          # Check preconditions
>          self.assertTrue(not os.path.exists(self.workspacedir), 'This test cannot be run with a workspace directory under the build directory')
> --
> 2.39.5
>
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#221797): https://lists.openembedded.org/g/openembedded-core/message/221797
> Mute This Topic: https://lists.openembedded.org/mt/114680479/1686489
> Group Owner: openembedded-core+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [alex.kanavin@gmail.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>
diff mbox series

Patch

diff --git a/meta-selftest/recipes-test/devtool/devtool-upgrade-test5_git.bb b/meta-selftest/recipes-test/devtool/devtool-upgrade-test5_git.bb
new file mode 100644
index 0000000000..7e8b001a28
--- /dev/null
+++ b/meta-selftest/recipes-test/devtool/devtool-upgrade-test5_git.bb
@@ -0,0 +1,32 @@ 
+SUMMARY = "Test recipe for fetching git submodules"
+HOMEPAGE = "http://git.yoctoproject.org/cgit/cgit.cgi/git-submodule-test/"
+LICENSE = "MIT"
+LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
+
+INHIBIT_DEFAULT_DEPS = "1"
+
+# Note: this is intentionally not the latest version in the original .bb
+SRCREV = "132fea6e4dee56b61bcf5721c94e8b2445c6a017"
+PV = "0.1+git"
+PR = "r2"
+
+SRC_URI = "gitsm://git.yoctoproject.org/git-submodule-test;branch=master"
+UPSTREAM_CHECK_COMMITS = "1"
+RECIPE_NO_UPDATE_REASON = "This recipe is used to test devtool upgrade feature"
+
+EXCLUDE_FROM_WORLD = "1"
+
+do_test_git_as_user() {
+    cd ${S}
+    git status
+    git submodule status
+}
+addtask test_git_as_user after do_unpack
+
+fakeroot do_test_git_as_root() {
+    cd ${S}
+    git status
+    git submodule status
+}
+do_test_git_as_root[depends] += "virtual/fakeroot-native:do_populate_sysroot"
+addtask test_git_as_root after do_unpack
\ No newline at end of file
diff --git a/meta-selftest/recipes-test/devtool/devtool-upgrade-test5_git.bb.upgraded b/meta-selftest/recipes-test/devtool/devtool-upgrade-test5_git.bb.upgraded
new file mode 100644
index 0000000000..938c46b016
--- /dev/null
+++ b/meta-selftest/recipes-test/devtool/devtool-upgrade-test5_git.bb.upgraded
@@ -0,0 +1,31 @@ 
+SUMMARY = "Test recipe for fetching git submodules"
+HOMEPAGE = "http://git.yoctoproject.org/cgit/cgit.cgi/git-submodule-test/"
+LICENSE = "MIT"
+LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
+
+INHIBIT_DEFAULT_DEPS = "1"
+
+# Note: this is intentionally not the latest version in the original .bb
+SRCREV = "a2885dd7d25380d23627e7544b7bbb55014b16ee"
+PV = "0.1+git"
+
+SRC_URI = "gitsm://git.yoctoproject.org/git-submodule-test;branch=master"
+UPSTREAM_CHECK_COMMITS = "1"
+RECIPE_NO_UPDATE_REASON = "This recipe is used to test devtool upgrade feature"
+
+EXCLUDE_FROM_WORLD = "1"
+
+do_test_git_as_user() {
+    cd ${S}
+    git status
+    git submodule status
+}
+addtask test_git_as_user after do_unpack
+
+fakeroot do_test_git_as_root() {
+    cd ${S}
+    git status
+    git submodule status
+}
+do_test_git_as_root[depends] += "virtual/fakeroot-native:do_populate_sysroot"
+addtask test_git_as_root after do_unpack
\ No newline at end of file
diff --git a/meta/lib/oeqa/selftest/cases/devtool.py b/meta/lib/oeqa/selftest/cases/devtool.py
index 580c567be3..19a205912b 100644
--- a/meta/lib/oeqa/selftest/cases/devtool.py
+++ b/meta/lib/oeqa/selftest/cases/devtool.py
@@ -1958,13 +1958,11 @@  class DevtoolUpgradeTests(DevtoolBase):
         self.assertNotIn(recipe, result.output)
         self.assertNotExists(os.path.join(self.workspacedir, 'recipes', recipe), 'Recipe directory should not exist after resetting')
 
-    def test_devtool_upgrade_git(self):
+    def _test_devtool_upgrade_git_by_recipe(self, recipe, commit):
         # Check preconditions
         self.assertTrue(not os.path.exists(self.workspacedir), 'This test cannot be run with a workspace directory under the build directory')
         self.track_for_cleanup(self.workspacedir)
         self.add_command_to_tearDown('bitbake-layers remove-layer */workspace')
-        recipe = 'devtool-upgrade-test2'
-        commit = '6cc6077a36fe2648a5f993fe7c16c9632f946517'
         oldrecipefile = get_bb_var('FILE', recipe)
         tempdir = tempfile.mkdtemp(prefix='devtoolqa')
         self.track_for_cleanup(tempdir)
@@ -1994,6 +1992,12 @@  class DevtoolUpgradeTests(DevtoolBase):
         self.assertNotIn(recipe, result.output)
         self.assertNotExists(os.path.join(self.workspacedir, 'recipes', recipe), 'Recipe directory should not exist after resetting')
 
+    def test_devtool_upgrade_git(self):
+        self._test_devtool_upgrade_git_by_recipe('devtool-upgrade-test2', '6cc6077a36fe2648a5f993fe7c16c9632f946517')
+
+    def test_devtool_upgrade_gitsm(self):
+        self._test_devtool_upgrade_git_by_recipe('devtool-upgrade-test5', 'a2885dd7d25380d23627e7544b7bbb55014b16ee')
+
     def test_devtool_upgrade_drop_md5sum(self):
         # Check preconditions
         self.assertTrue(not os.path.exists(self.workspacedir), 'This test cannot be run with a workspace directory under the build directory')