From: Julien Stephan <jstephan@baylibre.com>
To: openembedded-core@lists.openembedded.org
Cc: Julien Stephan <jstephan@baylibre.com>
Subject: [PATCH v4 5/5] oeqa/selftest/bblock: add self test for bblock tool
Date: Wed, 2 Aug 2023 16:24:32 +0200 [thread overview]
Message-ID: <20230802142432.2296716-6-jstephan@baylibre.com> (raw)
In-Reply-To: <20230802142432.2296716-1-jstephan@baylibre.com>
it implements various combination of locking single/multiple recipe(s)/task(s)
it also tests that locked sig are architecture dependant
Signed-off-by: Julien Stephan <jstephan@baylibre.com>
---
meta/lib/oeqa/selftest/cases/bblock.py | 146 +++++++++++++++++++++++++
1 file changed, 146 insertions(+)
create mode 100644 meta/lib/oeqa/selftest/cases/bblock.py
diff --git a/meta/lib/oeqa/selftest/cases/bblock.py b/meta/lib/oeqa/selftest/cases/bblock.py
new file mode 100644
index 00000000000..803ea3d64c8
--- /dev/null
+++ b/meta/lib/oeqa/selftest/cases/bblock.py
@@ -0,0 +1,146 @@
+#
+# Copyright (c) 2023 BayLibre, SAS
+# Author: Julien Stepahn <jstephan@baylibre.com>
+#
+# SPDX-License-Identifier: GPL-2.0-only
+#
+
+import os
+import re
+
+import oeqa.utils.ftools as ftools
+from oeqa.utils.commands import runCmd, get_bb_var, get_bb_vars, bitbake
+
+from oeqa.selftest.case import OESelftestTestCase
+
+class BBLock(OESelftestTestCase):
+
+ @classmethod
+ def setUpClass(cls):
+ super(BBLock, cls).setUpClass()
+ cls.lockfile = cls.builddir+"/conf/bblock.conf"
+
+ def unlock_recipes(self, recipes=None, tasks=None):
+ cmd = 'bblock -r '
+ if recipes:
+ cmd += ' '.join(recipes)
+ if tasks:
+ cmd += ' -t ' + ','.join(tasks)
+ result = runCmd(cmd)
+
+ if recipes:
+ # ensure all signatures are removed from lockfile
+ contents = ftools.read_file(self.lockfile)
+ for recipe in recipes:
+ for task in tasks:
+ find_in_contents = re.search("SIGGEN_LOCKEDSIGS_.+\s\+=\s\"%s:%s:.*\"" % (recipe, task), contents)
+ self.assertFalse(find_in_contents, msg = "%s:%s should not be present into bblock.conf anymore" % (recipe, task))
+ self.assertExists(self.lockfile)
+ else:
+ self.assertNotExists(self.lockfile)
+
+ def lock_recipes(self, recipes, tasks=None, machine=None):
+ cmd = 'bblock ' + ' '.join(recipes)
+ if tasks:
+ cmd += ' -t ' + ','.join(tasks)
+
+ if machine:
+ cmd = "MACHINE=" + machine + " " + cmd
+ with open("/tmp/tmp.txt", "w") as file:
+ file.write(cmd)
+ result = runCmd(cmd)
+
+ self.assertExists(self.lockfile)
+
+ # ensure all signatures are added to lockfile
+ contents = ftools.read_file(self.lockfile)
+ for recipe in recipes:
+ for task in tasks:
+ find_in_contents = re.search("SIGGEN_LOCKEDSIGS_.+\s\+=\s\"%s:%s:.*\"" % (recipe, task), contents)
+ self.assertTrue(find_in_contents, msg = "%s:%s was not added into bblock.conf. bblock output: %s" % (recipe, task, result.output))
+
+ def modify_tasks(self, recipes, tasks):
+ task_append = ""
+ for recipe in recipes:
+ bb_vars = get_bb_vars(['PV'], recipe)
+ recipe_pv = bb_vars['PV']
+ recipe_append_file = recipe + '_' + recipe_pv + '.bbappend'
+
+ os.mkdir(os.path.join(self.testlayer_path, 'recipes-test', recipe))
+ recipe_append_path = os.path.join(self.testlayer_path, 'recipes-test', recipe, recipe_append_file)
+
+ for task in tasks:
+ task_append += "%s:append() {\necho \"modify task hash\"\n}\n" % task
+ ftools.write_file(recipe_append_path, task_append)
+ self.add_command_to_tearDown('rm -rf %s' % os.path.join(self.testlayer_path, 'recipes-test', recipe))
+
+ def test_lock_single_recipe_single_task(self):
+ recipes = ["quilt"]
+ tasks = ["do_compile"]
+ self._run_test(recipes, tasks)
+
+ def test_lock_single_recipe_multiple_tasks(self):
+ recipes = ["quilt"]
+ tasks = ["do_compile" ,"do_install"]
+ self._run_test(recipes, tasks)
+
+ def test_lock_architecture_specific(self):
+ recipes = ["quilt"]
+ tasks = ["do_compile"]
+
+ # lock quilt's do_compile task for qemuarm machine
+ self.lock_recipes(recipes, tasks, "qemuarm")
+
+ # modify quilt's do_compile task
+ self.modify_tasks(recipes, tasks)
+
+ # build quilt using by default qemux86-64.
+ # No Note/Warning should be emitted since sig is locked for qemuarm
+ # (quilt package is architecture dependant)
+ info_message = "NOTE: The following recipes have locked tasks: " + recipes[0]
+ warn_message = "The %s:%s sig is computed to be" % (recipes[0], tasks[0])
+ result = bitbake(recipes[0] + " -n")
+ self.assertNotIn(info_message, result.output)
+ self.assertNotIn(warn_message, result.output)
+
+ def test_lock_multiple_recipe_single_task(self):
+ recipes = ["quilt", "bc"]
+ tasks= ["do_compile"]
+ self._run_test(recipes, tasks)
+
+ def _run_test(self, recipes, tasks=None):
+ # unlock all recipes and ensure no bblock.conf file exist
+ self.unlock_recipes()
+
+ # lock tasks for recipes
+ result = self.lock_recipes(recipes, tasks)
+
+ # build recipes. At this stage we should have a Note about recipes
+ # having locked task's sig, but no warning since sig still match
+ info_message = "NOTE: The following recipes have locked tasks: " + " ".join(recipes)
+ for recipe in recipes:
+ result = bitbake(recipe + " -n")
+ self.assertIn(info_message, result.output)
+ for task in tasks:
+ warn_message = "The %s:%s sig is computed to be" % (recipe, task)
+ self.assertNotIn(warn_message, result.output)
+
+ ## modify all tasks that are locked to trigger a sig change then build the recipes
+ ## at this stage we should have a Note as before, but also a warning for all
+ ## locked stage indicating the sig mismatch
+ self.modify_tasks(recipes, tasks)
+ for recipe in recipes:
+ result = bitbake(recipe + " -n")
+ self.assertIn(info_message, result.output)
+ for task in tasks:
+ warn_message = "The %s:%s sig is computed to be" % (recipe, task)
+ self.assertIn(warn_message, result.output)
+
+ # unlock all tasks and rebuild, no more Note/Warning should remain
+ self.unlock_recipes(recipes, tasks)
+ for recipe in recipes:
+ result = bitbake(recipe + " -n")
+ self.assertNotIn(info_message, result.output)
+ for task in tasks:
+ warn_message = "The %s:%s sig is computed to be" % (recipe, task)
+ self.assertNotIn(warn_message, result.output)
--
2.41.0
next prev parent reply other threads:[~2023-08-02 14:24 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-02 14:24 [PATCH v4 0/5] Add bblock helper scripts Julien Stephan
2023-08-02 14:24 ` [PATCH v4 1/5] bitbake.conf: include bblock.conf Julien Stephan
2023-08-02 14:24 ` [PATCH v4 2/5] bitbake: cooker: add a new function to retrieve task signatures Julien Stephan
2023-08-02 14:44 ` Julien Stephan
2023-08-11 15:16 ` [OE-core] " Richard Purdie
2023-08-22 9:27 ` Julien Stephan
2023-09-14 13:26 ` Richard Purdie
2023-08-02 14:24 ` [PATCH v4 3/5] sstatesig: add a new info level for SIGGEN_LOCKEDSIGS_TASKSIG_CHECK Julien Stephan
2023-08-11 15:19 ` [OE-core] " Richard Purdie
2023-08-02 14:24 ` [PATCH v4 4/5] scripts/bblock: add a script to lock/unlock recipes Julien Stephan
2023-08-02 14:24 ` Julien Stephan [this message]
2023-08-03 2:57 ` [OE-core] [PATCH v4 0/5] Add bblock helper scripts Chen, Qi
2023-08-03 7:19 ` Julien Stephan
2023-08-10 13:21 ` Alexandre Belloni
2023-08-11 8:00 ` Alexandre Belloni
2023-08-11 8:45 ` Alexandre Belloni
2023-09-20 14:20 ` Julien Stephan
2023-09-21 13:11 ` Alexandre Belloni
2023-09-21 14:24 ` Julien Stephan
2023-09-21 21:58 ` Alexandre Belloni
2023-09-22 8:54 ` Julien Stephan
2023-09-22 9:50 ` Alexandre Belloni
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230802142432.2296716-6-jstephan@baylibre.com \
--to=jstephan@baylibre.com \
--cc=openembedded-core@lists.openembedded.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox