From patchwork Mon Nov 30 15:28:43 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Purdie X-Patchwork-Id: 106526 Received: from mail-wm1-f42.google.com (mail-wm1-f42.google.com [209.85.128.42]) by mx.groups.io with SMTP id smtpd.msgproc02-g2.34872.1796052548583008814 for ; Mon, 30 Nov 2026 07:29:08 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@linuxfoundation.org header.s=google header.b=YgFy3rWo; spf=pass (domain: linuxfoundation.org, ip: 209.85.128.42, mailfrom: richard.purdie@linuxfoundation.org) Received: by mail-wm1-f42.google.com with SMTP id 5b1f17b1804b1-4bb55cda775so64760005e9.0 for ; Mon, 30 Nov 2026 07:29:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=google; t=1796052547; x=1796657347; darn=lists.openembedded.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to:content-type; bh=OKB44HUUWSIYrv/VTENKZnANkpfoERV10l48/Z9cJ9E=; b=YgFy3rWoDQqqI25O8n1gpVTEtOVLlHOW2IrylXNWkpMAzZnlRhds8jUIkfuKLL0wKN /uPLB+iNwuiWfVTrkw4ygoxg7fgHzp3bYppZEtJAjH5ORY51zS9HhdThZFddmYigd5yI hqWsHZ5kNLe4wkFCljf24Itc9gQgH4KtT1mLw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796052547; x=1796657347; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to:content-type; bh=OKB44HUUWSIYrv/VTENKZnANkpfoERV10l48/Z9cJ9E=; b=eh9lZgtlTwePdRSWCscZtvtyUXrwZ4ERQB5JkGvRyvZa3ecfa4LaAk5//RBDcOEoaX aD5+xZkVaLn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EezfdDnVUfhj/6+jk4weTKvmMlTbeY0A9TO iu3I= X-Received: by 2002:a05:600c:c086:b0:4bb:ab2c:67f7 with SMTP id 5b1f17b1804b1-4bbab2c6d69mr226040915e9.8.1796052546679; Mon, 30 Nov 2026 07:29:06 -0800 (PST) Return-Path: Received: from max.int.rpsys.net ([2001:8b0:aba:5f3c:2444:81bb:2aff:8d84]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4ab6baa397asm66033172f8f.48.2026.11.30.07.29.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Nov 2026 07:29:05 -0800 (PST) From: Richard Purdie To: bitbake-devel@lists.openembedded.org Subject: [PATCH 13/17] tests/runqueue: Add a test for RecipeCheckEvent/BB_CACHE_EXTRAVARS Date: Mon, 30 Nov 2026 15:28:43 +0000 Message-ID: <20261130152847.3472849-13-richard.purdie@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20261130152847.3472849-1-richard.purdie@linuxfoundation.org> References: <20261130152847.3472849-1-richard.purdie@linuxfoundation.org> MIME-Version: 1.0 List-Id: X-Webhook-Received: from 45-33-107-173.ip.linodeusercontent.com [45.33.107.173] by lin-tor-korg-lkml-alma10-1 with HTTPS for ; Mon, 30 Nov 2026 15:29:12 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/bitbake-devel/message/20502 Add a test for the new BB_CACHE_EXTRAVARS code and the associated event. Check the event is triggered and data is passed through to the event as expected. Initial code was from Claude, heavily editted. AI-Generated: Uses Claude (Opus 5.5) Signed-off-by: Richard Purdie --- .../classes/recipecheckevent.bbclass | 16 +++++ lib/bb/tests/runqueue.py | 63 +++++++++++++++++-- 2 files changed, 74 insertions(+), 5 deletions(-) create mode 100644 lib/bb/tests/runqueue-tests/classes/recipecheckevent.bbclass diff --git a/lib/bb/tests/runqueue-tests/classes/recipecheckevent.bbclass b/lib/bb/tests/runqueue-tests/classes/recipecheckevent.bbclass new file mode 100644 index 00000000000..ec12724e712 --- /dev/null +++ b/lib/bb/tests/runqueue-tests/classes/recipecheckevent.bbclass @@ -0,0 +1,16 @@ +# +# Test helper for BB_CACHE_EXTRAVARS: records the per-recipe values passed to +# event handlers through bb.runqueue.RecipeCheckEvent as JSON in +# ${TOPDIR}/extravars.json, keyed by recipe file basename. +# + +addhandler extravars_test_handler +extravars_test_handler[eventmask] = "bb.runqueue.RecipeCheckEvent" +python extravars_test_handler() { + import json + result = {} + for fn, values in e.recipedata.items(): + result[os.path.basename(fn)] = values + with open(e.data.expand("${TOPDIR}/extravars.json"), "w") as f: + json.dump(result, f, sort_keys=True) +} diff --git a/lib/bb/tests/runqueue.py b/lib/bb/tests/runqueue.py index d8c49f8c0c0..9b4287aaf96 100644 --- a/lib/bb/tests/runqueue.py +++ b/lib/bb/tests/runqueue.py @@ -12,13 +12,14 @@ import tempfile import subprocess import sys import time +import json # # TODO: # Add tests on task ordering (X happens before Y after Z) # -class RunQueueTests(unittest.TestCase): +class RunQueueBase(unittest.TestCase): alltasks = ['package', 'fetch', 'unpack', 'patch', 'prepare_recipe_sysroot', 'configure', 'compile', 'install', 'packagedata', 'package_qa', 'package_write_rpm', 'package_write_ipk', @@ -53,6 +54,13 @@ class RunQueueTests(unittest.TestCase): os.remove(tasklog) return tasks + def shutdown(self, tempdir): + # Wait for the hashserve socket to disappear else we'll see races with the tempdir cleanup + while (os.path.exists(tempdir + "/hashserve.sock") or os.path.exists(tempdir + "cache/hashserv.db-wal") or os.path.exists(tempdir + "/bitbake.lock")): + time.sleep(0.5) + +class RunQueueTests(RunQueueBase): + def test_no_setscenevalid(self): with tempfile.TemporaryDirectory(prefix="runqueuetest") as tempdir: cmd = ["bitbake", "a1"] @@ -427,8 +435,53 @@ class RunQueueTests(unittest.TestCase): self.shutdown(tempdir) - def shutdown(self, tempdir): - # Wait for the hashserve socket to disappear else we'll see races with the tempdir cleanup - while (os.path.exists(tempdir + "/hashserve.sock") or os.path.exists(tempdir + "cache/hashserv.db-wal") or os.path.exists(tempdir + "/bitbake.lock")): - time.sleep(0.5) +# Test BB_CACHE_EXTRAVARS and RecipeCheckEvent +class cacheExtraVarsTests(RunQueueBase): + + def trigger_recipecheckevent(self, tempdir, conf, targets): + # Helper to write the config, run bitbake and trigger RecipeCheckEvent + # returning json data of the event + postconf = os.path.join(tempdir, "extravars.conf") + with open(postconf, "w") as f: + f.write('INHERIT += "recipecheckevent"\n' + conf) + result = os.path.join(tempdir, "extravars.json") + if os.path.exists(result): + os.remove(result) + try: + output = self.run_bitbakecmd(["bitbake", "-R", postconf] + targets, tempdir, cleanup=True) + self.assertTrue(os.path.exists(result), "RecipeCheckEvent handler did not run") + with open(result) as f: + return json.load(f) + finally: + if os.path.exists(result): + os.remove(result) + + def test_cache_extravars(self): + # Check variables listed in BB_CACHE_EXTRAVARS are stored in the recipe + # cache and passed to RecipeCheckEvent. + + conf = 'OVERRIDES = "pn-${PN}"\n' \ + 'BB_CACHE_EXTRAVARS = "EXTRAVAR_A EXTRAVAR_B EXTRAVAR_UNSET"\n' \ + 'EXTRAVAR_A = "default"\n' \ + 'EXTRAVAR_A:pn-a1 = "a1-value"\n' \ + 'EXTRAVAR_B = "${PN}-b"\n' \ + 'EXTRAVAR_UNLISTED = "should-not-appear"\n' + expected = { + "a1.bb": {"EXTRAVAR_A": "a1-value", "EXTRAVAR_B": "a1-b", "EXTRAVAR_UNSET": ""}, + "b1.bb": {"EXTRAVAR_A": "default", "EXTRAVAR_B": "b1-b", "EXTRAVAR_UNSET": ""}, + } + with tempfile.TemporaryDirectory(prefix="runqueuetest") as tempdir: + # b1 depends on a1, so both expected + data = self.trigger_recipecheckevent(tempdir, conf, ["b1"]) + self.assertEqual(data, expected) + + self.shutdown(tempdir) + + def test_cache_extravars_unset(self): + # Without BB_CACHE_EXTRAVARS the event still fires, with no values + with tempfile.TemporaryDirectory(prefix="runqueuetest") as tempdir: + data = self.trigger_recipecheckevent(tempdir, "", ["a1"]) + self.assertEqual(data, {"a1.bb": {}}) + + self.shutdown(tempdir)