[8/9] testsuite: add perform_signature_lint method

Message ID 20240402172813.418770-9-chris.larson@siemens.com
State Superseded, archived
Headers show
Series Add more signature cachability tests to the testsuite | expand

Commit Message

kergoth@gmail.com April 2, 2024, 5:28 p.m. UTC
From: Christopher Larson <chris.larson@seimens.com>

This method is provided to generate signature data for specified target
or targets and check for cachability issues without having to complete a
build.

Signed-off-by: Christopher Larson <chris.larson@siemens.com>
---
 testsuite/cibase.py | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

Patch

diff --git a/testsuite/cibase.py b/testsuite/cibase.py
index 90591f32..349a79f0 100755
--- a/testsuite/cibase.py
+++ b/testsuite/cibase.py
@@ -125,6 +125,25 @@  def perform_sstate_populate(self, image_target, **kwargs):
         # Remove isar configuration so the the following test creates a new one
         self.delete_from_build_dir('conf')
 
+    def perform_signature_lint(self, targets, verbose=False, sources_dir=isar_root,
+                               excluded_tasks=None, **kwargs):
+        """Generate signature data for target(s) and check for cachability issues."""
+        self.configure(**kwargs)
+        self.move_in_build_dir("tmp", "tmp_before_sstate")
+        self.bitbake(targets, sig_handler="none")
+
+        verbose_arg = "--verbose" if verbose else ""
+        excluded_arg = f"--excluded-tasks {','.join(excluded_tasks)}" if excluded_tasks else ""
+        cmd = f"{isar_root}/scripts/isar-sstate lint --lint-stamps {self.build_dir}/tmp/stamps " \
+              f"--build-dir {self.build_dir} --sources-dir {sources_dir} {verbose_arg} {excluded_arg}"
+        self.log.info(f"Running: {cmd}")
+        exit_status, output = process.getstatusoutput(cmd, ignore_status=True)
+        if exit_status > 0:
+            ansi_escape = re.compile(r'\x1B(?:[@-Z\\-_]|\[[0-?]*[ -/]*[@-~])')
+            for line in output.splitlines():
+                self.log.error(ansi_escape.sub('', line))
+            self.fail("Detected cachability issues")
+
     def perform_sstate_test(self, image_target, package_target, **kwargs):
         def check_executed_tasks(target, expected):
             taskorder_file = glob.glob(f'{self.build_dir}/tmp/work/*/{target}/*/temp/log.task_order')