All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] bitbake: runqueue: Verify mcdepends are valid
@ 2025-02-25 18:38 Mark Hatle
  2025-02-27 12:29 ` [bitbake-devel] " Richard Purdie
  0 siblings, 1 reply; 3+ messages in thread
From: Mark Hatle @ 2025-02-25 18:38 UTC (permalink / raw)
  To: bitbake-devel

From: Mark Hatle <mark.hatle@amd.com>

In order to avoid a potentially confusing backtrace, check that the mcdepend
is valid when we add it.

Add a test case to ensure invalid configurations are caught and trigger an
error.

Signed-off-by: Mark Hatle <mark.hatle@amd.com>
Signed-off-by: Mark Hatle <mark.hatle@kernel.crashing.org>
---
 lib/bb/runqueue.py                        |  2 ++
 lib/bb/tests/runqueue-tests/recipes/g1.bb |  2 ++
 lib/bb/tests/runqueue-tests/recipes/h1.bb |  0
 lib/bb/tests/runqueue.py                  | 18 ++++++++++++++++++
 4 files changed, 22 insertions(+)
 create mode 100644 lib/bb/tests/runqueue-tests/recipes/g1.bb
 create mode 100644 lib/bb/tests/runqueue-tests/recipes/h1.bb

diff --git a/lib/bb/runqueue.py b/lib/bb/runqueue.py
index ffb2d2849..539a6065f 100644
--- a/lib/bb/runqueue.py
+++ b/lib/bb/runqueue.py
@@ -730,6 +730,8 @@ class RunQueueData:
                 if mc == frommc:
                     fn = taskData[mcdep].build_targets[pn][0]
                     newdep = '%s:%s' % (fn,deptask)
+                    if newdep not in taskData[mcdep].taskentries:
+                        bb.fatal("Task mcdepends on non-existent task %s" % (newdep))
                     taskData[mc].taskentries[tid].tdepends.append(newdep)
 
         for mc in taskData:
diff --git a/lib/bb/tests/runqueue-tests/recipes/g1.bb b/lib/bb/tests/runqueue-tests/recipes/g1.bb
new file mode 100644
index 000000000..3c7dca025
--- /dev/null
+++ b/lib/bb/tests/runqueue-tests/recipes/g1.bb
@@ -0,0 +1,2 @@
+do_build[mcdepends] = "mc::mc-1:h1:do_invalid"
+
diff --git a/lib/bb/tests/runqueue-tests/recipes/h1.bb b/lib/bb/tests/runqueue-tests/recipes/h1.bb
new file mode 100644
index 000000000..e69de29bb
diff --git a/lib/bb/tests/runqueue.py b/lib/bb/tests/runqueue.py
index cc87e8d6a..e15fdc330 100644
--- a/lib/bb/tests/runqueue.py
+++ b/lib/bb/tests/runqueue.py
@@ -314,6 +314,24 @@ class RunQueueTests(unittest.TestCase):
                        ["mc_2:a1:%s" % t for t in rerun_tasks]
             self.assertEqual(set(tasks), set(expected))
 
+            # AssertionError is raised by self.run_bitbakecmd in the event of a failure
+            # in thise case a failure is required, but we need to do further processing
+            # to tell if it's the RIGHT kind of failure.
+            with self.assertRaises(AssertionError):
+                try:
+                    self.run_bitbakecmd(["bitbake", "g1"], tempdir, "", extraenv=extraenv, cleanup=True)
+                except AssertionError as e:
+                    # If the word 'Traceback' or 'KeyError' is in the exception text,
+                    # we've regressed.  So verify it's NOT present, and pass the
+                    # exception to indicate a 'pass'.
+                    if not ('Traceback' in str(e) or 'KeyError' in str(e)):
+                        # Raising 'AssertionError' is a test pass
+                        raise e
+                    else:
+                        # Dump the output for triage, but don't raise an
+                        # exception, this indicates a test failure.
+                        print("%s: %s" % (type(e), e))
+
             self.shutdown(tempdir)
 
     def test_hashserv_single(self):
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-02-27 17:04 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-25 18:38 [PATCH v2] bitbake: runqueue: Verify mcdepends are valid Mark Hatle
2025-02-27 12:29 ` [bitbake-devel] " Richard Purdie
2025-02-27 17:04   ` Mark Hatle

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.