From patchwork Thu Dec 11 15:06:41 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: naftaly.ralamboarivony@smile.fr X-Patchwork-Id: 76293 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7FCE1D41D53 for ; Thu, 11 Dec 2025 15:06:53 +0000 (UTC) Received: from mail-wm1-f52.google.com (mail-wm1-f52.google.com [209.85.128.52]) by mx.groups.io with SMTP id smtpd.msgproc02-g2.11348.1765465612118881827 for ; Thu, 11 Dec 2025 07:06:52 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@smile.fr header.s=google header.b=0dvG0w6h; spf=pass (domain: smile.fr, ip: 209.85.128.52, mailfrom: naftaly.ralamboarivony@smile.fr) Received: by mail-wm1-f52.google.com with SMTP id 5b1f17b1804b1-4775ae77516so2390505e9.1 for ; Thu, 11 Dec 2025 07:06:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=smile.fr; s=google; t=1765465610; x=1766070410; darn=lists.openembedded.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=Rj9TkxFdu5isGQ9OXGna9LM1/ciFtjAxo3pry0VaGdo=; b=0dvG0w6hmZ2Q3SaKJ/AsIvLrV4GgAuaRyUeN4S9Th+skQG2TzZ6s0me+clm9Enfw48 O3t2wO5sDWPDsx0bVKJlx+1u5PK8ja0mIl2g+8RqxG3ICI4GCIwFUkvBN0ox+rpiowq7 SHPgKUGAxwPb8SoH3za7IvPWju0F46mAS8b70= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765465610; x=1766070410; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=Rj9TkxFdu5isGQ9OXGna9LM1/ciFtjAxo3pry0VaGdo=; b=i1Hcpv2SZEzYC+MIYTFzWBStg7efSUl5FEBOdGD9Fb7ZVvkgeTYLSF9J0CBc3zMPvO ZKnc638bhSF5a5lXxXFSikrz6ssofkJuTpgNIR4R8W0jZxK0IoU0uujpFcUamBrRhg3o We/MbExs+ppJ7R7DFoJ67Tssl14uyavbGnecOXIf4ISKAAtpBwOpSAz9dZhocd+VO86X gwnJ4D6rOi5W6bPEgS8VYVKFChmn+LzR5sSDmNs8tQzkBua2oPxxgOLCUnSD+dl6BwOC 0Sc3JlH9bl1bwD4mQSt6LnNorZp/Ai3pt4avMWEWuvV1fa4O46uOW8Gm0Q/jSsj5ZDPl e8XQ== X-Gm-Message-State: AOJu0Yz2aeuY9F9HMM+HpEt6gFCpg/sqL6Rpeqeqh4Y+qZFJFVz4lbFY ChOwf8WU1VHFOXpNU+XTEGiNhNkmF++DT/nSzrfiiBZLF5E+tbat2cLHBAKL79d0pIfy8xQmpnw pZCMA X-Gm-Gg: AY/fxX5e6QIGBP6p6mIx+aeiugqAnUCoEkICDYMRCOBpJkyVkLX5KdVNrSbmMt/mK42 e8Q7YgWbR59foGwatpbaevpPG0pye4UjW1bcMcOgfIyZNoSl4KAChHSWRRR6Ilf5uMgDuT1UPW2 PkZ2qB4MrxLhj5czNRI/yyjxy9TH3js9J7EzDhCub8SZGgKKMkjwUWu27F0R3Gh60NxMIE2z9Eg 7XTVPLM6p7fbEY6NuSgoXLhAwlTr4zKClPbwSxYiVvkWn3lyavWWTubrTzsQOox7xkpRX7qCPDQ tzHn4pD80RAR8Sg2+CsiKvwJsBbS655Xrk/T9RY7G7Hk7GaI0JjHjEB2Ak7pfMnR2hFgph50ACT 8I2tcDuDn5ny2ZhQ6fuhOFO9K3FR6ExEf2r9QJwDUokWS0loJGyQVjgbzVHQypuBmyEm+mDshG5 zczmLz/nBh6Q5Um0PltUbajHLZ39/7q/ekcRO+qO7pt9YA+vB1KK/QFu+zVAI1RNfGx67DiEgOX rZZowVbVfGXrdCCUFnejw== X-Google-Smtp-Source: AGHT+IEkmurhvbjfQuGAc99+gzpDYbzG3ghnEWgpjIkSixFJdKLgw56Qj0zAcvWxQCrFi/6dNZK8CA== X-Received: by 2002:a05:6000:2409:b0:42b:3090:2680 with SMTP id ffacd0b85a97d-42fa39ced51mr7459334f8f.10.1765465610139; Thu, 11 Dec 2025 07:06:50 -0800 (PST) Received: from P-ASN-DERVAUX.. (2a02-8434-8fe1-4f01-5250-bba4-03e6-c67a.rev.sfr.net. [2a02:8434:8fe1:4f01:5250:bba4:3e6:c67a]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-42fa8a70379sm6504043f8f.11.2025.12.11.07.06.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Dec 2025 07:06:49 -0800 (PST) From: naftaly.ralamboarivony@smile.fr To: openembedded-core@lists.openembedded.org Cc: Naftaly RALAMBOARIVONY Subject: [OE-core][PATCH v4 1/6] patchtest: fix failure when oe-core repo is in detached HEAD Date: Thu, 11 Dec 2025 16:06:41 +0100 Message-Id: <20251211150646.2647853-1-naftaly.ralamboarivony@smile.fr> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 List-Id: X-Webhook-Received: from 45-33-107-173.ip.linodeusercontent.com [45.33.107.173] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Thu, 11 Dec 2025 15:06:53 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/227539 From: Naftaly RALAMBOARIVONY Patchtest fails when oe-core git repo is in a "detached HEAD" state: Error log: > File "/usr/lib/python3/dist-packages/git/repo/base.py", line 881, in active_branch return self.head.reference ^^^^^^^^^^^^^^^^^^^ > File "/usr/lib/python3/dist-packages/git/refs/symbolic.py", line 311, in _get_reference raise TypeError("%s is a detached symbolic reference as it points to %r" % (self, sha)) TypeError: HEAD is a detached symbolic reference as it points to '3dd31d3b29730fa1130645d76bb71914ac036335' None In this case, no current branch is available for the clean operation. To fix this, updates the checkout logic: - if a current branch is available, use it, - otherwise, fall back to the commit pointed to by HEAD. This ensures that the script works correctly even when HEAD is detached. Signed-off-by: Naftaly RALAMBOARIVONY --- meta/lib/patchtest/repo.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/meta/lib/patchtest/repo.py b/meta/lib/patchtest/repo.py index 2cdd6736e4..6a7d7d2d3b 100644 --- a/meta/lib/patchtest/repo.py +++ b/meta/lib/patchtest/repo.py @@ -21,7 +21,12 @@ class PatchTestRepo(object): self.repodir = repodir self.repo = git.Repo.init(repodir) self.patch = mbox.PatchSeries(patch) - self.current_branch = self.repo.active_branch.name + + if self.repo.head.is_detached: + self.current_commit = self.repo.head.commit.hexsha + self.current_branch = None + else: + self.current_branch = self.repo.active_branch.name # targeted branch defined on the patch may be invalid, so make sure there # is a corresponding remote branch @@ -80,6 +85,6 @@ class PatchTestRepo(object): self._patchmerged = True def clean(self): - self.repo.git.execute(['git', 'checkout', self.current_branch]) + self.repo.git.execute(['git', 'checkout', self.current_branch if self.current_branch else self.current_commit]) self.repo.git.execute(['git', 'branch', '-D', self._workingbranch]) self._patchmerged = False From patchwork Thu Dec 11 15:06:42 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: naftaly.ralamboarivony@smile.fr X-Patchwork-Id: 76294 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8129BD41D54 for ; Thu, 11 Dec 2025 15:06:53 +0000 (UTC) Received: from mail-wm1-f47.google.com (mail-wm1-f47.google.com [209.85.128.47]) by mx.groups.io with SMTP id smtpd.msgproc01-g2.11400.1765465612505832462 for ; Thu, 11 Dec 2025 07:06:52 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@smile.fr header.s=google header.b=NBoew8LX; spf=pass (domain: smile.fr, ip: 209.85.128.47, mailfrom: naftaly.ralamboarivony@smile.fr) Received: by mail-wm1-f47.google.com with SMTP id 5b1f17b1804b1-4779cb0a33fso2877525e9.0 for ; Thu, 11 Dec 2025 07:06:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=smile.fr; s=google; t=1765465611; x=1766070411; darn=lists.openembedded.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=qKnez7GlkVraC4ABlrfa6SvP4abbv+FEIadWzy/e1Fs=; b=NBoew8LXg0AN9CsLlTPn1WJQvdFoWafnNnl71V70DBI9LunEwsKxU07vnehJ+33NCE eOf9aItm/2PP14HeaY2VFZVL/jht4r+GHZPjfmNaRVNsFQSlhqMECH4emI0RMn8dxfHh Jqqwn2R5Y7cUNSbe0Q+/rFZfeZbsmrQqFpPDY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765465611; x=1766070411; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=qKnez7GlkVraC4ABlrfa6SvP4abbv+FEIadWzy/e1Fs=; b=MNaYd6UZbQGU1PivRCcbYoe1WQrG3iJb/0kVSjyftqihvLNlOtNOCl9aHHpKJjYCIy /E2zpEzWDp75WhotvJPYqz4+56lFAp1mdB8h6ildTmuLTeUxIOooM8mML2YKqsOmiREW szfsZMZyIkN3OYM2DPoEwle2p7Pbu7XYpZ3i766lTGK1P2SjSUYieZNlMNIZRpQSfhUP tjuaTRkmmpZ1vKRX07qQl1xZcIco23h40VrDjr3wZ5tnCrTpF75nIOOCXo+lOH38SudY pOeKfbxWA+5TDZyCFjt8DkgncmNl2OqwltyJepSeur1vbKdWXFBIoODytk4/DbZgoypw qOIQ== X-Gm-Message-State: AOJu0YzNYY17DC2XxoLhx6nr/ljygNZL75pxgVo1MIbDfMFsE1bjKn50 HtgKiLnMRsenX6UNDTvXoi8HhPea+lyHGhMze5t0wFyOczUuRqIz0qHfEC+6GWVjHMc8CdlUe6K PhJvn X-Gm-Gg: AY/fxX7PplaAzjLRAXiiyEH15gSijtp0CIYUNmjq20Govt5sRcmkba4Zfjnt/n9MQnY iexWNTheYvPLFpjfA8v7D/40VcLSW0DpBVnQsFuDV8lCIm6yMc18NG/aZaRJ6+BNUt6BBocyK2f E56RDvu7oqWUqST6hekq2bq3WuJs56I1wacklCtafQhFYpZoxoLzjFmREBMhBVAk7K26csK+Mbw CzaUs5wjQDgxzqdVZjxgJRiHKXdRa2BB/4LwAiJU2MUWEdnmV6Hs+boqfGEHaiL4xKp0pmRjY96 HGmgy7BXepvY/3WV64aUgNVaJb8y+9jsM2RPDSAW1SKzXx/i/3F3+NX7sUH3RthzdyxaE+7Hb8A NW/1zmfi47P2byhqL1Tsh2jFiPx41DycrUZFUL4NrgA7vH7t5xgyUTjgg0asnnzAcA/NmdOhhx6 vKf2ZdjFr3avauwor/2tE+e6YRaDsaEFP4b9eB9DwAUaZAV+Zj6N4s4geRyYVf+vQCqva58fzMd TEuLewScSafGRt+D1rpAQ== X-Google-Smtp-Source: AGHT+IGHrtJxzvsOzyDgsJuFP5+51mZg8UoWd3jhT9HEV1lb5FbBa2HdrOqHE59WO+2jS/HElahrsg== X-Received: by 2002:a05:6000:2f84:b0:42b:3366:6330 with SMTP id ffacd0b85a97d-42fa3b0cecfmr7231708f8f.57.1765465610540; Thu, 11 Dec 2025 07:06:50 -0800 (PST) Received: from P-ASN-DERVAUX.. (2a02-8434-8fe1-4f01-5250-bba4-03e6-c67a.rev.sfr.net. [2a02:8434:8fe1:4f01:5250:bba4:3e6:c67a]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-42fa8a70379sm6504043f8f.11.2025.12.11.07.06.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Dec 2025 07:06:50 -0800 (PST) From: naftaly.ralamboarivony@smile.fr To: openembedded-core@lists.openembedded.org Cc: Naftaly RALAMBOARIVONY Subject: [OE-core][PATCH v4 2/6] patchtest/selftest: convert separate count variables into a results dictionary Date: Thu, 11 Dec 2025 16:06:42 +0100 Message-Id: <20251211150646.2647853-2-naftaly.ralamboarivony@smile.fr> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20251211150646.2647853-1-naftaly.ralamboarivony@smile.fr> References: <20251211150646.2647853-1-naftaly.ralamboarivony@smile.fr> MIME-Version: 1.0 List-Id: X-Webhook-Received: from 45-33-107-173.ip.linodeusercontent.com [45.33.107.173] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Thu, 11 Dec 2025 15:06:53 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/227540 From: Naftaly RALAMBOARIVONY Change the variables used to count test results: - passcount - failcount - skipcount - xpasscount - xfailcount - xskipcount - errorcount into a single dictionary named counts, in order to make it easier to pass these values to a result analysis and display function (print_results). Signed-off-by: Naftaly RALAMBOARIVONY --- meta/lib/patchtest/selftest/selftest | 52 +++++++++++++++------------- 1 file changed, 27 insertions(+), 25 deletions(-) diff --git a/meta/lib/patchtest/selftest/selftest b/meta/lib/patchtest/selftest/selftest index 3cf1c361f7..c2f274b15b 100755 --- a/meta/lib/patchtest/selftest/selftest +++ b/meta/lib/patchtest/selftest/selftest @@ -18,19 +18,19 @@ parentdir = os.path.dirname(topdir) # path to the repo root repodir = os.path.dirname(os.path.dirname(parentdir)) -def print_results(passcount, failcount, skipcount, xpasscount, xfailcount, xskipcount, errorcount): - total = passcount + skipcount + failcount + xpasscount + xfailcount + xskipcount + errorcount +def print_results(counts): + total = sum(counts.values()) print("============================================================================") print("Testsuite summary for %s" % os.path.basename(topdir)) print("============================================================================") - print("# TOTAL: %s" % str(total)) - print("# XPASS: %s" % str(xpasscount)) - print("# XFAIL: %s" % str(xfailcount)) - print("# XSKIP: %s" % str(xskipcount)) - print("# PASS: %s" % str(passcount)) - print("# FAIL: %s" % str(failcount)) - print("# SKIP: %s" % str(skipcount)) - print("# ERROR: %s" % str(errorcount)) + print("# TOTAL: " + str(total)) + print("# XPASS: " + str(counts["xpass"])) + print("# XFAIL: " + str(counts["xfail"])) + print("# XSKIP: " + str(counts["xskip"])) + print("# PASS: " + str(counts["pass"])) + print("# FAIL: " + str(counts["fail"])) + print("# SKIP: " + str(counts["skip"])) + print("# ERROR: " + str(counts["error"])) print("============================================================================") # Once the tests are in oe-core, we can remove the testdir param and use os.path.dirname to get relative paths @@ -44,13 +44,15 @@ def test(root, patch): return results if __name__ == '__main__': - passcount = 0 - failcount = 0 - skipcount = 0 - xpasscount = 0 - xfailcount = 0 - xskipcount = 0 - errorcount = 0 + counts = { + "pass": 0, + "fail": 0, + "skip": 0, + "xpass": 0, + "xfail": 0, + "xskip": 0, + "error": 0, + } results = None @@ -68,27 +70,27 @@ if __name__ == '__main__': result, _ = resultline.split(':', 1) if expected_result.upper() == "FAIL" and result.upper() == "FAIL": - xfailcount = xfailcount + 1 + counts["xfail"] = counts["xfail"] + 1 print("XFAIL: %s (file: %s)" % (testid.strip("."), os.path.basename(patch))) elif expected_result.upper() == "PASS" and result.upper() == "PASS": - xpasscount = xpasscount + 1 + counts["xpass"] = counts["xpass"] + 1 print("XPASS: %s (file: %s)" % (testid.strip("."), os.path.basename(patch))) elif expected_result.upper() == "SKIP" and result.upper() == "SKIP": - xskipcount = xskipcount + 1 + counts["xskip"] = counts["xskip"] + 1 print("XSKIP: %s (file: %s)" % (testid.strip("."), os.path.basename(patch))) else: print("%s: %s (%s)" % (result.upper(), testid.strip("."), os.path.basename(patch))) if result.upper() == "PASS": - passcount = passcount + 1 + counts["pass"] = counts["pass"] + 1 elif result.upper() == "FAIL": - failcount = failcount + 1 + counts["fail"] = counts["fail"] + 1 elif result.upper() == "SKIP": - skipcount = skipcount + 1 + counts["skip"] = counts["skip"] + 1 else: print("Bad result on test %s against %s" % (testid.strip("."), os.path.basename(patch))) - errorcount = errorcount + 1 + counts["error"] = counts["error"] + 1 break else: print ("No test for=%s" % patch) - print_results(passcount, failcount, skipcount, xpasscount, xfailcount, xskipcount, errorcount) + print_results(counts) From patchwork Thu Dec 11 15:06:43 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: naftaly.ralamboarivony@smile.fr X-Patchwork-Id: 76295 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 88844D41D4C for ; Thu, 11 Dec 2025 15:06:53 +0000 (UTC) Received: from mail-wr1-f48.google.com (mail-wr1-f48.google.com [209.85.221.48]) by mx.groups.io with SMTP id smtpd.msgproc01-g2.11401.1765465612897899458 for ; Thu, 11 Dec 2025 07:06:53 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@smile.fr header.s=google header.b=lslvLYWi; spf=pass (domain: smile.fr, ip: 209.85.221.48, mailfrom: naftaly.ralamboarivony@smile.fr) Received: by mail-wr1-f48.google.com with SMTP id ffacd0b85a97d-429ce7e79f8so157019f8f.0 for ; Thu, 11 Dec 2025 07:06:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=smile.fr; s=google; t=1765465611; x=1766070411; darn=lists.openembedded.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=twKBVRHbffrPEQrPPJr1jRsb7pPLZYA9hoYZqN9VNvg=; b=lslvLYWiaN1x+knf1u6Ebt4JMFTfn1twb/zU1/srf5AKThg0LBNFfDCVVfSzCHSNhe aU3rMVQPYDUFbPjX18mfJBjSCxJlk7+qHNfrPatxIJxzkUvW2n5QzJSvB4ayoIph755R lFjeNEGr5YRbIPn9G6iofSNG3LoCqOP+pL3K8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765465611; x=1766070411; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=twKBVRHbffrPEQrPPJr1jRsb7pPLZYA9hoYZqN9VNvg=; b=etyXA9nKCWF5kNHqFHzKA9okFDW3MRuwKgfLgBHKxMWvu/ftKLXDAbJVrA1SYVHbZg yPbu3inSVkXWlQsnSX0qerCv9yBv7/uU/nVhqZB7y9i/QWaCtiZkwDEVHBF41JLx2eMg 2gsNGTS1rZ2z8+yVIbBet5YEYRYujO2g+cWHCXI9/WUq1fNOIDsvCYsdoz+EgkFI1Kc6 ZWQPp0UEZSdomZMsOLJIfQR7cfFOg8lcEVN9kwLyvvfK3slZQcYHf1MV6upvnEZ4c8iR fPN/Ld8i45e3a7Ak/pPIr5J+aoJ5XjLBYbCeLENULo3uJYLZePUerKd94iR0aLgD5Ypu cyIg== X-Gm-Message-State: AOJu0Yz9SYACWerWx6rp7ytQOC2oF1l22XS3gUiY2pV0Zk2vpcP2ih4A oKiZr3mhlwEr+K7KW6zdx+iY6tCFVexx7SJbKAzYANy/UYD63u/0a3FjNFRr378zey/UuHzwCue MqBtb X-Gm-Gg: AY/fxX45+Yi4wwncHzaEAB7YcNtMMbjI2bQlJRPxYonSlgHIjvpFCv2tunLHXTbe+s7 3y5j+LcwL/mXVl0/42hdGQIcrUbsK+xZARDTnV/TMBqbjvntJe8uH23b1PxVwfKg5PfYixroBum F1tg45aJ2qSdNTrmnkl/QdKL6tDOjKkA1QfKOEaPIuBvsrN1wR52P9EPntNy06gvdTI0LAzomMp RuyX9kpTxLnbb7Ujp0H9I0UmS75rWyBSIwVp0XpYaFyXIxrV56GgJX/igJPpxUOFfhzvKh0I31D OHBY7ItyhsqFudplTODRpMxBWt9tAyWgKGxlMc/4nB/ZiFKp2ISoRan9ITWMoMUR0IWywvOUsNt qp6WRbvm/tOpDPjl2Zg9NrMA+Cgv9FlGXtLvzgTVoFBIguXnfweh580hw9cFlfNcGf/I/OaB7CC 13SNiS8FrPfPUa0xE/CblcHoZ3JD+3nN4wM3S5Dgs+Jf3Um4H90O6UHTMACzBxoXge4w8bNadcQ J14wConfBsqEW9KeK//GA== X-Google-Smtp-Source: AGHT+IG2n63FxNi5p/6EgGtMW2Njl9fmLMQPGWm+XRPkTaZ6aXT4I6zs+9TjCzHgGTnyH1WwJ7lTPQ== X-Received: by 2002:a05:6000:612:b0:425:73c9:7159 with SMTP id ffacd0b85a97d-42fa3afe908mr6858989f8f.33.1765465611003; Thu, 11 Dec 2025 07:06:51 -0800 (PST) Received: from P-ASN-DERVAUX.. (2a02-8434-8fe1-4f01-5250-bba4-03e6-c67a.rev.sfr.net. [2a02:8434:8fe1:4f01:5250:bba4:3e6:c67a]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-42fa8a70379sm6504043f8f.11.2025.12.11.07.06.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Dec 2025 07:06:50 -0800 (PST) From: naftaly.ralamboarivony@smile.fr To: openembedded-core@lists.openembedded.org Cc: Naftaly RALAMBOARIVONY Subject: [OE-core][PATCH v4 3/6] patchtest/selftest: refactor patch retrieval and result analysis Date: Thu, 11 Dec 2025 16:06:43 +0100 Message-Id: <20251211150646.2647853-3-naftaly.ralamboarivony@smile.fr> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20251211150646.2647853-1-naftaly.ralamboarivony@smile.fr> References: <20251211150646.2647853-1-naftaly.ralamboarivony@smile.fr> MIME-Version: 1.0 List-Id: X-Webhook-Received: from 45-33-107-173.ip.linodeusercontent.com [45.33.107.173] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Thu, 11 Dec 2025 15:06:53 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/227541 From: Naftaly RALAMBOARIVONY Move the code responsible for collecting patches into a new get_patches() function. It returns a list of dictionaries containing: - test ID - patch name - expected result - root path Refactor result analysis code into an analyze_result() function that updates the counts dictionary. These two refactorings will make it easier to add a new test in detached HEAD mode. Signed-off-by: Naftaly RALAMBOARIVONY --- meta/lib/patchtest/selftest/selftest | 94 +++++++++++++++++----------- 1 file changed, 56 insertions(+), 38 deletions(-) diff --git a/meta/lib/patchtest/selftest/selftest b/meta/lib/patchtest/selftest/selftest index c2f274b15b..a1be478e1a 100755 --- a/meta/lib/patchtest/selftest/selftest +++ b/meta/lib/patchtest/selftest/selftest @@ -33,6 +33,58 @@ def print_results(counts): print("# ERROR: " + str(counts["error"])) print("============================================================================") +def get_patches(patchesdir): + """ + Return a list of dict mapping test IDs to patch filenames and expected results. + """ + patch_list = [] + for root, dirs, patches in os.walk(patchesdir): + for patch in patches: + part = patch.split('.') + klass, testname, expected_result = part[0], part[1], part[-1] + testid = f".{klass}.{testname}" + patch_list.append({ + "testid": testid, + "patch": patch, + "expected": expected_result, + "root" : root, + }) + return patch_list + +def analyze_result(results, patch, counts): + testid = patch["testid"] + expected_result = str(patch["expected"]) + for resultline in results.splitlines(): + if testid in resultline: + result, _ = resultline.split(':', 1) + + if expected_result.upper() == "FAIL" and result.upper() == "FAIL": + counts["xfail"] = counts["xfail"] + 1 + print("XFAIL: %s (file: %s)" % (testid.strip("."), os.path.basename(patch["patch"]))) + elif expected_result.upper() == "PASS" and result.upper() == "PASS": + counts["xpass"] = counts["xpass"] + 1 + print("XPASS: %s (file: %s)" % (testid.strip("."), os.path.basename(patch["patch"]))) + elif expected_result.upper() == "SKIP" and result.upper() == "SKIP": + counts["xskip"] = counts["xskip"] + 1 + print("XSKIP: %s (file: %s)" % (testid.strip("."), os.path.basename(patch["patch"]))) + else: + print("%s: %s (%s)" % (result.upper(), testid.strip("."),os.path.basename(patch["patch"]))) + if result.upper() == "PASS": + counts["pass"] = counts["pass"] + 1 + elif result.upper() == "FAIL": + counts["fail"] = counts["fail"] + 1 + elif result.upper() == "SKIP": + counts["skip"] = counts["skip"] + 1 + else: + print("Bad result on test %s against %s" % (testid.strip("."),os.path.basename(patch["patch"]))) + counts["error"] = counts["error"] + 1 + break + else: + print ("No test for=%s" % patch["patch"]) + + return counts + + # Once the tests are in oe-core, we can remove the testdir param and use os.path.dirname to get relative paths def test(root, patch): res = True @@ -55,42 +107,8 @@ if __name__ == '__main__': } results = None - - for root, dirs, patches in os.walk(patchesdir): - for patch in patches: - results = test(root, patch) - - a = patch.split('.') - klass, testname = a[0], a[1] - expected_result = a[-1] - testid = ".%s.%s" % (klass,testname) - - for resultline in results.splitlines(): - if testid in resultline: - result, _ = resultline.split(':', 1) - - if expected_result.upper() == "FAIL" and result.upper() == "FAIL": - counts["xfail"] = counts["xfail"] + 1 - print("XFAIL: %s (file: %s)" % (testid.strip("."), os.path.basename(patch))) - elif expected_result.upper() == "PASS" and result.upper() == "PASS": - counts["xpass"] = counts["xpass"] + 1 - print("XPASS: %s (file: %s)" % (testid.strip("."), os.path.basename(patch))) - elif expected_result.upper() == "SKIP" and result.upper() == "SKIP": - counts["xskip"] = counts["xskip"] + 1 - print("XSKIP: %s (file: %s)" % (testid.strip("."), os.path.basename(patch))) - else: - print("%s: %s (%s)" % (result.upper(), testid.strip("."), os.path.basename(patch))) - if result.upper() == "PASS": - counts["pass"] = counts["pass"] + 1 - elif result.upper() == "FAIL": - counts["fail"] = counts["fail"] + 1 - elif result.upper() == "SKIP": - counts["skip"] = counts["skip"] + 1 - else: - print("Bad result on test %s against %s" % (testid.strip("."), os.path.basename(patch))) - counts["error"] = counts["error"] + 1 - break - else: - print ("No test for=%s" % patch) - + patches = get_patches(patchesdir) + for patch_info in patches: + results = test(patch_info["root"], patch_info["patch"]) + counts = analyze_result(results, patch_info, counts) print_results(counts) From patchwork Thu Dec 11 15:06:44 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: naftaly.ralamboarivony@smile.fr X-Patchwork-Id: 76296 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 55600D41D55 for ; Thu, 11 Dec 2025 15:07:03 +0000 (UTC) Received: from mail-wm1-f48.google.com (mail-wm1-f48.google.com [209.85.128.48]) by mx.groups.io with SMTP id smtpd.msgproc02-g2.11350.1765465613458589818 for ; Thu, 11 Dec 2025 07:06:53 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@smile.fr header.s=google header.b=dlRz87Lq; spf=pass (domain: smile.fr, ip: 209.85.128.48, mailfrom: naftaly.ralamboarivony@smile.fr) Received: by mail-wm1-f48.google.com with SMTP id 5b1f17b1804b1-4779aa4f928so2778495e9.1 for ; Thu, 11 Dec 2025 07:06:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=smile.fr; s=google; t=1765465611; x=1766070411; darn=lists.openembedded.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=fey6/MMZYY5H26igQ2VPhHYh3Z8zP28DH95PmOpkcug=; b=dlRz87Lq6QYnWEwOg8ksPva+BmXXQ9b836cY7v3Atk4FKxYvHLqwXTaztTIcLy48rR MVFw0BqDDuutceCBnbF1wCAlz1zS9KLT4VU+O6swtiW4aJgLXY9VS/jfczBsinKUq6q+ qBRscHJ+P2D8rn9gdV9AGRrpafgZnJfXdDUnI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765465611; x=1766070411; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=fey6/MMZYY5H26igQ2VPhHYh3Z8zP28DH95PmOpkcug=; b=L0AJckdcPzFrxjNWRvLCyLLu2tN2zMRjlZwpGnhoW1txM00iYiY4u/6adQEakd07nP FCx1VR+6jBErH7r865d7qsAlTvZhCWaDLrZvrgQnQD7xJMr64czt/knT5oTE5iR9xRB3 3DmCD6bSZi0gGpBy4gkxg8qPOU6aeGlgrnKD5oZnULyI4bjrmVlLAXK8d4MkpKJGlXhz 9A1ri7uizPkV3R917yiiWgArk7ikQ3z9h+BzjtsXTp5qozSbMDax770PPDPioPo1y7T5 FRxsQHwMpYFTWDEX+htrQV12GnID/qbAAnEuS2B+Nd3WDh2Yz5SLMtMutH80qRTUjY9P cQQg== X-Gm-Message-State: AOJu0YwZ8duRBLrCBfFgBfilmzKzqGqCECYhZzNEbiE9/7M2RT1zSqWp RrWqlXF6Dm2rHPgpyU/ZV8oLR7HAP48p32ky3dRNVQ/9sZ1Y82dxRUEHqYOVjwvxKqewkxpUKxA +arCT X-Gm-Gg: AY/fxX4ZZ2kTrywEpoBPe+3KWuShp1avwAQuO/rygtgqXMogil0zmihxRdAd2fiLCYe EtfZ8st1Hzw9RX0vvTnZztcVDJ66JHW/HOklKGF+Z9DiqGz6yFc7wBDGPfzT7vG6a8YQ1yVA35Z doVpWVT9xv4fldUxio+jSbqBaRljhJ8eW3tpDY67YMLk2BEsZpVOU0GRfrPuHdUCI80Mi9jgvnL zMJ9HRziWdfxeoZ07YWG9Ns2zAchkfaOERjALAensmgtIkevwKphem9PGUksdPtWaOrUGPyrmYM Kpo+xEBbwpBN7PukmOXkcEwEQsN/uXovUyPpclQU/9zTlED9Mad91+FFCa+JZ9bGyASrtdiDGyH e8LVGybtIZ9gSWxDJgXiypu9RBPsihBDSQpZerRBnCYIZWswGRa7VIP80y21KnTCfAu+F7B2YcY b8qQgykQuLNkUN4UBIUJJHxiaMo6g7IFaK1XB1hsen+Q8hYKRioMU5GmUuKR6HvdX6Gid0t2DJF WXkIROTJRrlbMfWXMNf4A== X-Google-Smtp-Source: AGHT+IHqR9HIN7SpQYIV3nCnnVoUNgVRJ/w+UZAlMq/SGjezAQ6uJONYlt/NCs+SF/RT3wJTmpw4TQ== X-Received: by 2002:a5d:5f52:0:b0:429:8a71:d57 with SMTP id ffacd0b85a97d-42fa39db05dmr7436854f8f.27.1765465611526; Thu, 11 Dec 2025 07:06:51 -0800 (PST) Received: from P-ASN-DERVAUX.. (2a02-8434-8fe1-4f01-5250-bba4-03e6-c67a.rev.sfr.net. [2a02:8434:8fe1:4f01:5250:bba4:3e6:c67a]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-42fa8a70379sm6504043f8f.11.2025.12.11.07.06.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Dec 2025 07:06:51 -0800 (PST) From: naftaly.ralamboarivony@smile.fr To: openembedded-core@lists.openembedded.org Cc: Naftaly RALAMBOARIVONY Subject: [OE-core][PATCH v4 4/6] patchtest/selftest: Extract head-attached test loop into function Date: Thu, 11 Dec 2025 16:06:44 +0100 Message-Id: <20251211150646.2647853-4-naftaly.ralamboarivony@smile.fr> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20251211150646.2647853-1-naftaly.ralamboarivony@smile.fr> References: <20251211150646.2647853-1-naftaly.ralamboarivony@smile.fr> MIME-Version: 1.0 List-Id: X-Webhook-Received: from 45-33-107-173.ip.linodeusercontent.com [45.33.107.173] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Thu, 11 Dec 2025 15:07:03 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/227542 From: Naftaly RALAMBOARIVONY Move the loop that run the tests in head attached tests into a function 'test_head_attached'. Also add an explicit check for the case where no patches are found and exit with an error. Signed-off-by: Naftaly RALAMBOARIVONY --- meta/lib/patchtest/selftest/selftest | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/meta/lib/patchtest/selftest/selftest b/meta/lib/patchtest/selftest/selftest index a1be478e1a..92acc4d556 100755 --- a/meta/lib/patchtest/selftest/selftest +++ b/meta/lib/patchtest/selftest/selftest @@ -95,6 +95,12 @@ def test(root, patch): return results +def test_head_attached(patches, counts): + for patch_info in patches: + results = test(patch_info["root"], patch_info["patch"]) + counts = analyze_result(results, patch_info, counts) + return counts + if __name__ == '__main__': counts = { "pass": 0, @@ -107,8 +113,10 @@ if __name__ == '__main__': } results = None + patches = get_patches(patchesdir) - for patch_info in patches: - results = test(patch_info["root"], patch_info["patch"]) - counts = analyze_result(results, patch_info, counts) + if not patches: + print(f"Error: Unable to find patch(es) in {patchesdir}") + sys.exit(1) + counts = test_head_attached(patches, counts) print_results(counts) From patchwork Thu Dec 11 15:06:45 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: naftaly.ralamboarivony@smile.fr X-Patchwork-Id: 76297 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 55663D41D56 for ; Thu, 11 Dec 2025 15:07:03 +0000 (UTC) Received: from mail-wr1-f47.google.com (mail-wr1-f47.google.com [209.85.221.47]) by mx.groups.io with SMTP id smtpd.msgproc02-g2.11351.1765465614179373457 for ; Thu, 11 Dec 2025 07:06:54 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@smile.fr header.s=google header.b=GVpr83ya; spf=pass (domain: smile.fr, ip: 209.85.221.47, mailfrom: naftaly.ralamboarivony@smile.fr) Received: by mail-wr1-f47.google.com with SMTP id ffacd0b85a97d-42e2b80ab25so118468f8f.1 for ; Thu, 11 Dec 2025 07:06:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=smile.fr; s=google; t=1765465612; x=1766070412; darn=lists.openembedded.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=SBC3bxyU5gwgVpqlPVndjRqp8xzQAr3Pf0Twv6+gHZM=; b=GVpr83yaX0lciTzU+6ALZtkxpE6L630SOml80pIqu4xWoKoDv0XUyErL/P8d9Iwm07 JudmTLx+agzJuTfh4RZYv9VEOPnu2aC0unAVu/TyiJUMcwFLiW4K+HVgaSO/f+fxwgYo joZbaSOUKXM3ULkOWbUANA1ILC67juufVCDQI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765465612; x=1766070412; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=SBC3bxyU5gwgVpqlPVndjRqp8xzQAr3Pf0Twv6+gHZM=; b=pTt6pg4j43e8+GvC3AFXZxomnkTyir3yN0lVvLcc5rYe1k9zmTTPCE6fUJMLbwnMwe z1/SsBYdmWh8xumlxPj0xp0zZSbgO3MBA7LCy2AbkYencfTOa2OQBd38oF8nCASUvf0Y r1DeMkn9sWa8toOoyxeaHnUk5OJiBohjqWvFv2k9rO3KrE8A6OudOpVqx3X2P9PcpqO9 A4ewZIPyn3oXCpa4+MfziAnUMkDMFNmoBfk8PwGYD6KdsMQ3JE2dwAaD1lZ+ZkSUUS6I PjXCGEjkkYRgrOsGflT/pRp7P6CVJh7p3cRfUuKFRZTb7SVBtOi5zF3WutLx41Ee8t1C ggzw== X-Gm-Message-State: AOJu0YyOtsSGP10RoW2RZySR7RJShj6zv0TOSn9+7Gis0hdx4iWRVGjQ g6iA5mqiYxtNU2C2y8kCXeeRt1Xhosj4XRuBxAsLSlsizfbTbpeeOV+sun7FX5B1tUDyunoNO08 /px9i X-Gm-Gg: AY/fxX5VbWOCsThmZ7hvC9gzW+eDmaTQr7i8N7kqczNywlC+81CB+o2yDTfiBPSwJGy 2m+MeQDozba3ThX01zEOqiiIJ9Sm9C+/Gu8kFdizRPAlwpNFyZgxaivaqRWEHYZNODejJJFyhrE MGjRT8tfwhlSW0dcmcul86hnwhZuQA9W1KGa3iIIqoz9nAkzWnzjA/u638X/KAdiB6+yGPaliOS 6FofFIwbEn+FeU5Jlku8oLe3EyGhgKIsCOtOBy7bvrkovki+npK/nRKYNT9dOaxD8BNbDh+YojS KA6BQAOMNg/oLuzmm6rnR5BDo2OOGtW18/LoAEQ5zk9KeFkjmZiFbGTTCat2Vqd8fO/7GcBp310 SORqFYUh6TeqRN2yMWU4h/cueqpC6HaiBPfOwQmvlgkXHW1ttiernOUOBFSVT3QtRqFHm9W8o3+ ON6R+KHcI9kj02pBzRisj8co0JYAFpbVEsfENBcyUQ6em6DaVUwV6phWRAKxUMTRBoxKqrgdBqp 6hX+jNqZWsvTw//46ptNQ== X-Google-Smtp-Source: AGHT+IEl2LnMxN1s6ysRN6t0PNhegok1GN+a9O2lHHxFTK/Z6Sdjw7jRuGMJmtBk2RPChkuQ2YEzhg== X-Received: by 2002:a5d:5f55:0:b0:42b:36f4:cd20 with SMTP id ffacd0b85a97d-42fa39d8199mr6999724f8f.27.1765465612056; Thu, 11 Dec 2025 07:06:52 -0800 (PST) Received: from P-ASN-DERVAUX.. (2a02-8434-8fe1-4f01-5250-bba4-03e6-c67a.rev.sfr.net. [2a02:8434:8fe1:4f01:5250:bba4:3e6:c67a]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-42fa8a70379sm6504043f8f.11.2025.12.11.07.06.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Dec 2025 07:06:51 -0800 (PST) From: naftaly.ralamboarivony@smile.fr To: openembedded-core@lists.openembedded.org Cc: Naftaly RALAMBOARIVONY Subject: [OE-core][PATCH v4 5/6] patchtest/selftest: Add coverage for detached and attached HEAD cases Date: Thu, 11 Dec 2025 16:06:45 +0100 Message-Id: <20251211150646.2647853-5-naftaly.ralamboarivony@smile.fr> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20251211150646.2647853-1-naftaly.ralamboarivony@smile.fr> References: <20251211150646.2647853-1-naftaly.ralamboarivony@smile.fr> MIME-Version: 1.0 List-Id: X-Webhook-Received: from 45-33-107-173.ip.linodeusercontent.com [45.33.107.173] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Thu, 11 Dec 2025 15:07:03 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/227543 From: Naftaly RALAMBOARIVONY Extend the selftest to run against both modes to ensure correct behavior and prevent regressions when operating in a detached HEAD environment. Two test modes are run: Git attached and detached, via the 'run_tests()' function. Signed-off-by: Naftaly RALAMBOARIVONY --- changes in v4: - Fix incorrect working directory when running Git commands on the autobuilder : https://lists.openembedded.org/g/openembedded-core/message/227474 The run-patchtest-selftest script uses an incorrect cwd when executing Git commands during autobuilder tests. This causes failures when the script is launched from outside the expected repository. To resolve this, the run_sh() function is updated to pass the cwd argument to subprocess.check_output, ensuring all Git operations run from the correct directory. + /srv/pokybuild/yocto-worker/patchtest-selftest/build/layers/openembedded-core//meta/lib/patchtest/selftest/selftest Not a Git repository Traceback (most recent call last): File "/srv/pokybuild/yocto-worker/patchtest-selftest/build/layers/openembedded-core//meta/lib/patchtest/selftest/selftest", line 198, in counts = run_tests(patches, counts) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/srv/pokybuild/yocto-worker/patchtest-selftest/build/layers/openembedded-core//meta/lib/patchtest/selftest/selftest", line 173, in run_tests assert git_state['branch'] != temp_branch, f"Cannot run patchtest selftest while on branch '{temp_branch}'" ~~~~~~~~~^^^^^^^^^^ changes in v3: - Simplified printouts message in test_head_detached when test failed - Fixed the result message for test_head_detached - Incrementing xpass so it is properly included in the test results --- meta/lib/patchtest/selftest/selftest | 68 +++++++++++++++++++++++++++- 1 file changed, 67 insertions(+), 1 deletion(-) diff --git a/meta/lib/patchtest/selftest/selftest b/meta/lib/patchtest/selftest/selftest index 92acc4d556..01a0888499 100755 --- a/meta/lib/patchtest/selftest/selftest +++ b/meta/lib/patchtest/selftest/selftest @@ -84,6 +84,47 @@ def analyze_result(results, patch, counts): return counts +def run_sh(cmd): + """Run a shell command and return its stdout as a stripped string.""" + return subprocess.check_output(cmd, cwd=currentdir, stderr=subprocess.STDOUT, universal_newlines=True, shell=True).strip() + +def get_git_state(): + """Return the current Git HEAD state (branch, commit).""" + try: + inside_repo = run_sh("git rev-parse --is-inside-work-tree") + except subprocess.CalledProcessError: + print("Not a Git repository") + return None + + state = { + "branch": run_sh("git rev-parse --abbrev-ref HEAD"), + "commit": run_sh("git rev-parse HEAD"), + } + + return state + +def restore_git_state(git_state): + assert git_state['branch'] is not None, "Failed to restore git state, no valid branch" + if git_state['branch'] == "HEAD": + run_sh(f"git switch --detach {git_state['commit']}") + else: + run_sh(f"git switch {git_state['branch']}") + +def is_git_state_same(before, after): + ret = True + + for k in ("branch", "commit"): + if before[k] != after[k]: + print(f"Git state changed: {k} changed: {before[k]} -> {after[k]}") + ret = False + + return ret + +def git_detach_head(): + run_sh("git switch --detach HEAD") + assert run_sh("git rev-parse --abbrev-ref HEAD") == "HEAD", "Failed to enter detached HEAD state" + + return get_git_state() # Once the tests are in oe-core, we can remove the testdir param and use os.path.dirname to get relative paths def test(root, patch): @@ -101,6 +142,31 @@ def test_head_attached(patches, counts): counts = analyze_result(results, patch_info, counts) return counts +def test_head_detached(patches, counts): + git_state = get_git_state() + git_st_detach_before = git_detach_head() + patch_info = patches[0] + testid = patch_info["testid"] + results = test(patch_info["root"], patch_info["patch"]) + git_st_detach_after = get_git_state() + counts = analyze_result(results, patch_info, counts) + if not is_git_state_same(git_st_detach_before, git_st_detach_after): + print(" Test '%s' failed with git in detach HEAD mode: state changed after test" % testid.strip(".")) + counts["error"] = counts["error"] + 1 + else: + counts["xpass"] = counts["xpass"] + 1 + print("XPASS: %s.test_head_detached" % os.path.basename(__file__)) + + return counts + +def run_tests(patches, counts): + git_state = get_git_state() + counts = test_head_attached(patches, counts) + counts = test_head_detached(patches, counts) + restore_git_state(git_state) + + return counts + if __name__ == '__main__': counts = { "pass": 0, @@ -118,5 +184,5 @@ if __name__ == '__main__': if not patches: print(f"Error: Unable to find patch(es) in {patchesdir}") sys.exit(1) - counts = test_head_attached(patches, counts) + counts = run_tests(patches, counts) print_results(counts) From patchwork Thu Dec 11 15:06:46 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: naftaly.ralamboarivony@smile.fr X-Patchwork-Id: 76298 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 62EA7D41D57 for ; Thu, 11 Dec 2025 15:07:03 +0000 (UTC) Received: from mail-wm1-f53.google.com (mail-wm1-f53.google.com [209.85.128.53]) by mx.groups.io with SMTP id smtpd.msgproc01-g2.11402.1765465614488200924 for ; Thu, 11 Dec 2025 07:06:54 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@smile.fr header.s=google header.b=3qigTea2; spf=pass (domain: smile.fr, ip: 209.85.128.53, mailfrom: naftaly.ralamboarivony@smile.fr) Received: by mail-wm1-f53.google.com with SMTP id 5b1f17b1804b1-477b198f4bcso1711385e9.3 for ; Thu, 11 Dec 2025 07:06:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=smile.fr; s=google; t=1765465613; x=1766070413; darn=lists.openembedded.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=E3kS3vunvv2kQRP1rLXVgo+ylMa2Jc/DyHA3Yh060bo=; b=3qigTea22fHH6z4gQLh0apTTp5amtuctGMBU58kaenG2tbI+4j1IicK5MphBpuhna/ 3Rrn57jAL/4IvlP+IIhkAxpSy2ohRTfq/mnlJ97K04SlLVSfNCRsgwtYQp9AxF/D45Mr BRZYCzQ4NzSLDvKeZth+v/GGmIK+BzHx31BNw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765465613; x=1766070413; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=E3kS3vunvv2kQRP1rLXVgo+ylMa2Jc/DyHA3Yh060bo=; b=YVyYjaDeaFiWDUUvSqxvy3xcDQNvKUzzFvqXxCxI/L7497LBofp/I12KwBch3mTO/o 2iem3tIUkXG5ejckCHMAIo2Ck0K32cpX7pylEvTafPU1++E1nm1eKx/tMTiKcYCIxcIl u7HWnAykZ4uHfUIQz56Cd7AJk/fic/fhMK7TYFWoDLhOfnkCg6znENejkFhRDnVe+lQ0 IF0gGPFOJHG3nH8/Bt8xLHDV1UimFd9w9KAjBx79MXahW3bcwebJ/nxstAHB+uO8Kk5M IhvEiQRGzDJ0NJBROnyvYXC4p+NnwTQxTb8TYuAM1xY5SyqhPW2BYBrTGnjyu5Ky5aWe 54ew== X-Gm-Message-State: AOJu0YzLdjj7TeOe4+xCS2r0mXTaMaPCaQVRp1apx14geHKDls3UcyGn RZkf7vDlV4rFfrNN7G8zoSTrWnQVUV8PWQsQ1uqFvZeeyQgqEY9W/lktiK3lnJJHbV/3AawH6FU JGf59 X-Gm-Gg: AY/fxX6so8p9SCv6jgUjHL+jo2Znrka9XErVGpwFIpqVmyg+PmjTEGQgjFpuTnN+pX4 IsuZ9mrcWJGc06/RA8mp7w0hNQF3S7SWWaJPcRt4v2OJKcXZOyJ4aYeQ0Ecaf2SoWHu9oAtpASk x52TgjO+r39WCxBq77xG0yRqMvjBHZQZmHURLbnBlPyy/Aed1MUVLvxIOCkNnL8n25/V7WWzNQD qY1KYbfu5DY3SOL1eY+vtaTHLc7qWIsROYHaVVdXyP8GYsual9HbL8hh/O3N8JS1PIXgNCXB3Kh A9qeB7pvi3XKbdz1qENcbyq2Vkt6svKJzTFOs1dfR9JQRcKFnwQPSR2ZeIGD9D6ndTsT4t/u5Y9 dgi71K3A0VYsndqWOeMYrrpUhvcZTcae/2JfnmFIxJ3jaMBU8lMhR9lroHZT8/22/+kXenUBaRY oIv/p7v0wdpS09xQkHAcN15qUP8pTfaB6RILj3KeF2Fdnnw9ARqmAxXhtzYz2jUavlBt4Frd5kj kPkVrJfr3AQtFClHNA5/y/xLw5mn6dZ X-Google-Smtp-Source: AGHT+IH1xk7J+PROxOyUNfQXdeh3fqBWUsPMk2BSQmJkcB4MR9r8x/LG679MGbLr0/xIl+2MaiikiA== X-Received: by 2002:a05:600c:4851:b0:479:3a86:dc1e with SMTP id 5b1f17b1804b1-47a83c61a6dmr38039145e9.36.1765465612627; Thu, 11 Dec 2025 07:06:52 -0800 (PST) Received: from P-ASN-DERVAUX.. (2a02-8434-8fe1-4f01-5250-bba4-03e6-c67a.rev.sfr.net. [2a02:8434:8fe1:4f01:5250:bba4:3e6:c67a]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-42fa8a70379sm6504043f8f.11.2025.12.11.07.06.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Dec 2025 07:06:52 -0800 (PST) From: naftaly.ralamboarivony@smile.fr To: openembedded-core@lists.openembedded.org Cc: Naftaly RALAMBOARIVONY Subject: [OE-core][PATCH v4 6/6] patchtest/selftest: Ensure HEAD is attached before running attach tests case Date: Thu, 11 Dec 2025 16:06:46 +0100 Message-Id: <20251211150646.2647853-6-naftaly.ralamboarivony@smile.fr> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20251211150646.2647853-1-naftaly.ralamboarivony@smile.fr> References: <20251211150646.2647853-1-naftaly.ralamboarivony@smile.fr> MIME-Version: 1.0 List-Id: X-Webhook-Received: from 45-33-107-173.ip.linodeusercontent.com [45.33.107.173] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Thu, 11 Dec 2025 15:07:03 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/227544 From: Naftaly RALAMBOARIVONY If the repo is in a detached HEAD state, create and check out a temporary branch to attach HEAD. If the branch already exists, the error is raised via run_sh. Add a check to verify that the Git state has not changed before and after the test in the attached HEAD. Signed-off-by: Naftaly RALAMBOARIVONY --- meta/lib/patchtest/selftest/selftest | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/meta/lib/patchtest/selftest/selftest b/meta/lib/patchtest/selftest/selftest index 01a0888499..43cccf4c85 100755 --- a/meta/lib/patchtest/selftest/selftest +++ b/meta/lib/patchtest/selftest/selftest @@ -120,6 +120,9 @@ def is_git_state_same(before, after): return ret +def git_attach_head(temp_branch): + run_sh(f"git switch -C {temp_branch}") + def git_detach_head(): run_sh("git switch --detach HEAD") assert run_sh("git rev-parse --abbrev-ref HEAD") == "HEAD", "Failed to enter detached HEAD state" @@ -136,10 +139,15 @@ def test(root, patch): return results -def test_head_attached(patches, counts): +def test_head_attached(patches, counts, branch): + + git_attach_head(branch) + git_state_before = get_git_state() for patch_info in patches: results = test(patch_info["root"], patch_info["patch"]) counts = analyze_result(results, patch_info, counts) + git_state_after = get_git_state() + assert is_git_state_same(git_state_before, git_state_after), "Repository state changed after attached HEAD test." return counts def test_head_detached(patches, counts): @@ -160,10 +168,13 @@ def test_head_detached(patches, counts): return counts def run_tests(patches, counts): + temp_branch = "test_patchtest_head_attached" git_state = get_git_state() - counts = test_head_attached(patches, counts) + assert git_state['branch'] != temp_branch, f"Cannot run patchtest selftest while on branch '{temp_branch}'" + counts = test_head_attached(patches, counts, temp_branch) counts = test_head_detached(patches, counts) restore_git_state(git_state) + run_sh(f"git branch -D {temp_branch}") return counts