From patchwork Tue Dec 9 10:55:08 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: 76084 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 7E384D3B7EA for ; Tue, 9 Dec 2025 10:55:51 +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.5062.1765277740868235312 for ; Tue, 09 Dec 2025 02:55:41 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@smile.fr header.s=google header.b=lv50/JLJ; 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-4779ce2a624so69695495e9.2 for ; Tue, 09 Dec 2025 02:55:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=smile.fr; s=google; t=1765277739; x=1765882539; 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=lv50/JLJSZsLNZlJtcvolgRtDgzC0PVzSXkRmMUTcLHq44FIOAZRTIV0A1dGPJ/jt2 /zJ2Dg03D7UujV54GKtI30zgmi5+jjLOWO5pgObY1ZeEXUUJ/LuGRnF2whlCGJ5InS5+ kNc3J+8ePUpsG7Yyb3mLw8L5s80ObXxoGvKW0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765277739; x=1765882539; 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=vXXSBrVMrXP/9nE1H3LRmgITgG5gA3dNDxTgbTq/tpKGXIe/OFg9XVmQD99vDLrhJ8 nZxR2OlbAE7DxShWjpi1cX/4tfPXtSDl37kvHOos5tiea+h/kko2QT5rdcLan6gGT5T8 1s7bSMPYOxSEbnD+LJ2Xjh/yynQOxd01bSjhbPKqDrb1bHWgT2zONbsIA2+8CmXPRfc3 UfyktpI+nOdVpJ63MjGCmGVEYSZmUbzpp+AXZeenLNQRoKfP1+tEwHm/dAnx2/OLr/eN kKHtxqaFfoEyo2HlkoO76fIXTnnVil7oZNvrjc7K3gsqEufpRFZaJDBOJCVAu6zkFhPx WlAA== X-Gm-Message-State: AOJu0YxyxHMrULM8XbCIp/h8yvnl9e9g5cCklOVso9Gx73Eny3cc35nK MoOd9ex/iNEfiR1YZ5ptoL9DrtOVXyPBMo53zeE/q2llCestbXZyIbZuG64yvV5vCAvjHO6AbrN ckMxJ X-Gm-Gg: ASbGnctg4hk+ZHjBv28SUKAmjmLN3RPIJUkbffNe1CK9gbPlmV8CP8BpgXdJoFAbJZP 5UA2ptHWY3qwg9kKV29mSAXaJZMZS87vtiW4hMd7cDhMcpV3SWCHe/JBBW1BIaDxsSVhxxqHl/l ZIL44zKaB3e9slHlvkOWkqahKISwrGq4Lusw0RS/liQMxmrFlH7kZWEZY/RQSKWedsNO6FvODA9 xT5uJw/VHheF5H0TUkOtbygbXXOXqpLMLIno2rdyUzOtft1q6BeId9uqfum3GrlD5ub+0sj7yVN xeRr7BNSHBM+5+eq5oXq92gtjD6vL3YdbVUeVD2zZFpDjhhu1yt//l0JNYK+A+dlX63A0cIEVIE CiiLYXtHDMl56aSeY9HHIMEA6bIgy2uuHTDDgvZQQzeKOWcFjuUMGCEgi4d12hBgHQ7VSEYHMiZ xt5JGtsxci8MEoGdvXtOXv6rztfqN5NVPN6BsAAzVR3VEJDot2Ld5dwTlucaUPn2sxPVyjRZfC6 4nr2SkuPkG7VNWyNhomoXM= X-Google-Smtp-Source: AGHT+IGjfudUTfqG0rlH2Trp5OflUYBWQXlPz9wiOuNHDXt4nJn8x+CdmhD9PQylMMMp0SVhG+M4Hg== X-Received: by 2002:a05:600c:8108:b0:477:a977:b8c2 with SMTP id 5b1f17b1804b1-47939dfdc1fmr96156745e9.13.1765277739021; Tue, 09 Dec 2025 02:55:39 -0800 (PST) Received: from P-ASN-DERVAUX.. (2a02-8434-8fe1-4f01-fc4a-65a9-382e-6f5d.rev.sfr.net. [2a02:8434:8fe1:4f01:fc4a:65a9:382e:6f5d]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-47a7d2e7435sm17412895e9.0.2025.12.09.02.55.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Dec 2025 02:55:38 -0800 (PST) From: naftaly.ralamboarivony@smile.fr To: openembedded-core@lists.openembedded.org Cc: Naftaly RALAMBOARIVONY Subject: [OE-core][PATCH v3 1/6] patchtest: fix failure when oe-core repo is in detached HEAD Date: Tue, 9 Dec 2025 11:55:08 +0100 Message-Id: <20251209105513.273859-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 ; Tue, 09 Dec 2025 10:55:51 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/227425 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 Tue Dec 9 10:55:09 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: 76083 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 7F383D3B7F3 for ; Tue, 9 Dec 2025 10:55:51 +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.5195.1765277741788876185 for ; Tue, 09 Dec 2025 02:55:42 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@smile.fr header.s=google header.b=gTsoSxLA; 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-4779ce2a624so69695745e9.2 for ; Tue, 09 Dec 2025 02:55:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=smile.fr; s=google; t=1765277740; x=1765882540; 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=gTsoSxLAAaOaZn/ykbC0ytdrEKUkakF1VT2q9rndPnz/2X9Bw9HGx9ReQ/sqETUnoQ z0uG6iSyPHMvqHqivVbh+P7Wwq0oWkwR3oVLN+AwqIvNLd+eFBbZdv8b1s7Ds+qPLRAG oQ20AQbGBOy2vmE7U8T/3O94Nsavd+UvLSTpI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765277740; x=1765882540; 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=fDhgYyOJqokob7lmQ3givyINDwye+tE0jcJ2UuvmVEXe9ruw45X3otsLVnED+ukKSa R40WBdcUuxheZmhJj+zNIRlMYWBndDgPLnas25p5ChdhiaBvHN3XB3P6/PC2hURxcZ4O PxxYeUip5mQe0x48G2sZeZeW8BrVKBJUJQve5ML8NPgvIzw5RjrzaYVspGVteFtnAGOS 4QkPO6ErAxvzgS3lOh2y76cZPKsgBx0iNLSWUIEOp/VA9yvukIDKtNRBFa4afRzRyUvb BPYp0+hfq+pCt95s8Lj186UYfNrcdpaBVXolunxYJ3uQorzpCBqEJHUZuKFDmpEPe5uJ EOfg== X-Gm-Message-State: AOJu0YzScSUAmB3UsWMpEcmu96eZQuAgwZGfXKFFnsSLElRoS5rhVsnm a4gaqFOZnv9or+sjoeZVqJc68pU1dESgck+SBEszGLnEzlFAwMMXIw0WW3eP/Ei3eee3ZIi7ouz 7Dyar X-Gm-Gg: ASbGncvaWTtdWdh6vDYS0Nf1nCfgaYyPeRTUhLFhZoVT2ImWR7cE1uPkhkyXxXCNcv0 8zwSM+DEucK237Au6q7us54pDAmbXyDf2g2+DthMFFPz72J9m+uB/ERLDKqcjodG8wdkEuFUuha t3Xh0gf06xirhWwq+ALtiS+FEr20Mi//tCPyShGUodtt+o/3krx73rCiKm/EOa1yeyi9R2VPt/l cyTQizLh3dmLeD78B0+MS2Otil+tZbLIA4gKp2VrgK0PW6AzliBfJQRiIbnbBKsOtOLiYmhgeeu TeswjMU114M+JAxxAv+sbylyt5P08FCtJzVdKNE26tMAWnNXKpfBgggleHH4x9SH3K98b77Iunb hg6IMQ1kwBwlyO8jqgtAsFFSY/KLD/h+q2PffouCBAoHL3h5YSTnBNAd3isIkax1bRQgnrBv84f X/Nra9HPRQIQ/f9YVCTBTCStokUGChTZwwojZos2TLSIbVTGCzwoQ9VB+ctqW9IH8ELY0pFt+SV HBNZCCbur/IYsZFNgdaAH0= X-Google-Smtp-Source: AGHT+IGyx+tOrIMGxtTcoAw6A1yUJG281lFstxQyDsaWFoxIoW8lM0khP7wfEMA0AeH0IeM03rl2+Q== X-Received: by 2002:a05:600c:4743:b0:477:fcb:2256 with SMTP id 5b1f17b1804b1-47939e206cdmr108655905e9.17.1765277739740; Tue, 09 Dec 2025 02:55:39 -0800 (PST) Received: from P-ASN-DERVAUX.. (2a02-8434-8fe1-4f01-fc4a-65a9-382e-6f5d.rev.sfr.net. [2a02:8434:8fe1:4f01:fc4a:65a9:382e:6f5d]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-47a7d2e7435sm17412895e9.0.2025.12.09.02.55.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Dec 2025 02:55:39 -0800 (PST) From: naftaly.ralamboarivony@smile.fr To: openembedded-core@lists.openembedded.org Cc: Naftaly RALAMBOARIVONY Subject: [OE-core][PATCH v3 2/6] patchtest/selftest: convert separate count variables into a results dictionary Date: Tue, 9 Dec 2025 11:55:09 +0100 Message-Id: <20251209105513.273859-2-naftaly.ralamboarivony@smile.fr> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20251209105513.273859-1-naftaly.ralamboarivony@smile.fr> References: <20251209105513.273859-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 ; Tue, 09 Dec 2025 10:55:51 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/227426 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 Tue Dec 9 10:55:10 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: 76086 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 8D541D1CDC6 for ; Tue, 9 Dec 2025 10:55:51 +0000 (UTC) Received: from mail-wm1-f54.google.com (mail-wm1-f54.google.com [209.85.128.54]) by mx.groups.io with SMTP id smtpd.msgproc01-g2.5196.1765277742184866839 for ; Tue, 09 Dec 2025 02:55:42 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@smile.fr header.s=google header.b=x6HVr2wB; spf=pass (domain: smile.fr, ip: 209.85.128.54, mailfrom: naftaly.ralamboarivony@smile.fr) Received: by mail-wm1-f54.google.com with SMTP id 5b1f17b1804b1-477a2ab455fso63253085e9.3 for ; Tue, 09 Dec 2025 02:55:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=smile.fr; s=google; t=1765277740; x=1765882540; 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=x6HVr2wBwnvS+FZ/BeEbs99d8ZP4I9ICIXgGMhmDAnf/X2OVKJ9RlwFqqARqZLc5cN 9mDqCk8ksv5GN9QVgnMJLNUKxRDzz76bq0Wqf1s3lWApJ8bbapBS3iUFVXYW0J072w1q vk7JaapsLup5zoP4c1Xmsjv9viYmydo+ehAbo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765277740; x=1765882540; 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=DY3684FTImlon44nXAWssFyH/SqhWV/bXk9XTL2x14Q/2shq7WrcxM0fOgB8wvz49Q JiFi9vK2I+aBU5XPYV3O1v9em1ZyftCONZpMtStzrihcxiJb6gy9cJqXmMgeG66DVWlR fHzMZ9yJcWF1L4xD0nycyuHZpfKUNBh9h8q8qInhj3cCnyfABKm4lGWXS2eMrErJlkSm HS+Nm/5arnaKrwkFVrzqsqFPo+G+pV8wBIfN0J6nkNicMSVMUogKgCQdkLWYTn4HeIEL +6Tk+vDcTvsfRmQKWzi6qBtCWcUcHc/brrK00OXdqXrEf2yML51hLGMxFp7S2nOdPev5 RxfA== X-Gm-Message-State: AOJu0YzEURfX7undSyXUSmoKkBKYnDpQpJs74uKbzYKM6AbCYXkqYUQU QGF1k83c74sZgUoRN0Grx3zPRDuOXTIc6ieizSSaIVPhSXtq3NSzc+oOvGJLE/KlCycwYp7dE07 5oHZ2 X-Gm-Gg: ASbGncsDqS5Axi6IOqf3feKxwVdnSgugyeo3OIL3GlrclbpFq1CdRq6o2VIpLizFRsp bjXXzrbskcJqrVwhxYMcqnLg7/YX3kouzDZ23VNZFN7Gnx7iQMEjt9C7oEZXS49187lakRbY5hX cJnsSvl6gEr56BUGTFxalluRsjl9aWjNo7j8fH+vD98VU8yL8pwSZ9YyBtpW9OdG54/tyHTyT13 /3PRvPvS0RKGC0QuLMTP7oxnrrb4cvPGSBFPxQa1sNvjUwSS6Z/JRfitV0la40tMyHCuECUdmBg UH3VXTMHb9l5XbrKNU/+t4TxvmMgma9tNEi/5PVdzgnPypr6KDBnqp50krivPQgQ1Z6+5F0aV6I 8HMOu+0WSAbg7KftTi1eBttXTKIJxYdR984uneEy2KDbgYagihfLJuAoyqJWBvv3U39z1pCOffc OLXg6qMLDgXxkPUtZxNLzuPtAkz3v00+Pu4EmnVyj89ya6yDqzuRM1NDMz4EIcl87u2ARLV4Mk9 AyvRWRBkRjwBdRYC1wb5/g= X-Google-Smtp-Source: AGHT+IEIdaWaAiS2w8PuLwzaqvB+oHVd41DwKoy+OnEVq5YatbqZm5p1PFytOo+ZPg1v+HyhUA6D4Q== X-Received: by 2002:a05:600c:3013:b0:479:3a86:dc1b with SMTP id 5b1f17b1804b1-4793a86dca1mr60024135e9.37.1765277740329; Tue, 09 Dec 2025 02:55:40 -0800 (PST) Received: from P-ASN-DERVAUX.. (2a02-8434-8fe1-4f01-fc4a-65a9-382e-6f5d.rev.sfr.net. [2a02:8434:8fe1:4f01:fc4a:65a9:382e:6f5d]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-47a7d2e7435sm17412895e9.0.2025.12.09.02.55.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Dec 2025 02:55:40 -0800 (PST) From: naftaly.ralamboarivony@smile.fr To: openembedded-core@lists.openembedded.org Cc: Naftaly RALAMBOARIVONY Subject: [OE-core][PATCH v3 3/6] patchtest/selftest: refactor patch retrieval and result analysis Date: Tue, 9 Dec 2025 11:55:10 +0100 Message-Id: <20251209105513.273859-3-naftaly.ralamboarivony@smile.fr> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20251209105513.273859-1-naftaly.ralamboarivony@smile.fr> References: <20251209105513.273859-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 ; Tue, 09 Dec 2025 10:55:51 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/227427 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 Tue Dec 9 10:55:11 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: 76085 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 956D7D3B7FC for ; Tue, 9 Dec 2025 10:55:51 +0000 (UTC) Received: from mail-wm1-f43.google.com (mail-wm1-f43.google.com [209.85.128.43]) by mx.groups.io with SMTP id smtpd.msgproc02-g2.5063.1765277742543528970 for ; Tue, 09 Dec 2025 02:55:42 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@smile.fr header.s=google header.b=iG27X++Y; spf=pass (domain: smile.fr, ip: 209.85.128.43, mailfrom: naftaly.ralamboarivony@smile.fr) Received: by mail-wm1-f43.google.com with SMTP id 5b1f17b1804b1-4779adb38d3so51079625e9.2 for ; Tue, 09 Dec 2025 02:55:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=smile.fr; s=google; t=1765277741; x=1765882541; 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=iG27X++Y58XjOcjumfS4TfjeETCuuMHYUmRpT5XZI7n1FVBWD6gBMmXbkIBRAvsRIQ BWT4P0IyEElG1O0J40uTjUF5/UhKugFFl3yh6+9RDDEmHQEHsvjOzS8qLyk05dg1Anvw 04pMw+nTz+8ls9qlDr0w8aBD0w8NIIUgN87Bo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765277741; x=1765882541; 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=TkXjcmXBNgwVK/FbQ+D85KO2Ysa/YqsPhCCFbR2zFX9DOyGKKliIXw3WG6tJKH3XBi NcayKRB5J5WMm9m1dMDgOsxhwgNVK+dO4uY19HjKgQMmpbLY6uHNinlJQQ8F6lI/EIYd sid9rQ/geEm5bTnblWaEUoUW/t12NGeb/cJB9qN+oXlbRytOmdgKaXbpgy8pzkUCoSpB MO9mQt4ynamwL0xNHhetX3WuU7pkXgFSLQ3UO111JQGqK8Ual8kOqVOAORzhMZ2pi4Fu QSN0Ze5Bc5YiMwKcnshchVu1W8njUZDOBoZNnTa6cSYvhcJgDwIrzGJ3j5JfGVLCdJ7b T2lQ== X-Gm-Message-State: AOJu0YwfMf5QVoGDjMDj/3lXf6hAHhQ6uQomO8rf1PPuROWvAZamZc62 J9fxVwBScB6bHLwY6C2OKKiIFXerVa6hF+asCCxSSJDzfLvR3OQfsv4Z1w+p1nylGXeTQfOt+uU PTTj5 X-Gm-Gg: ASbGncsNF33je97Amt4ugJxNgZFJoxevMaNVKCdGFpOj+iMTADElE5YUSoQS+jLr5d0 +b2r1Tymv3ceByEqmFLgsfCZyEI9EbXsi/Vo9TUttF1IoH9ZmtfZmHI4iCvAJl6pLqchOHdjrBi UKiaZONTrJdYesvU432qqOV3/nFujVEgwQxxSnm0Tyn8wg/7PGhuWjNzwfFdQ7WxwXdYk7tRLqP 2Qzfuw0LAOk2U/v+nqio2nynsk6CRzLtvjpAxGJX3hugF8UMW9XSHEXi7uicqWiGGxDdTUFk37E ujpZV+kh5nthHjozkmC3Fi3XunEbn3TCZxxhIFC0eZAK6rY2ZyKNeT8PLESdn0LDHcu698IcJgW PAn+Mt6+c3uNLH6hLYUx443rxoIGYQq1FNs+1PvPgWMzzDpFOLrMNCeNCFKg9ptdZR/2+d5Feqm 2H0HzQpSGxzlamZ6pZpuB45013AChYMEAqvnFO+xqaA0Z8x8j36ANcWJQXK9MBkTjyxVrYs0NnM hm65O9TvrvnB9rS3h309Ts= X-Google-Smtp-Source: AGHT+IF5CGdpJESxu9vjjvxK3c52XY9jdxO9jhqI5ak2KezPBZ1/xIjlbLzvR5Wag1p9txhpihEuVQ== X-Received: by 2002:a05:600c:350b:b0:477:79f8:da9d with SMTP id 5b1f17b1804b1-47939e3d074mr117150725e9.24.1765277740828; Tue, 09 Dec 2025 02:55:40 -0800 (PST) Received: from P-ASN-DERVAUX.. (2a02-8434-8fe1-4f01-fc4a-65a9-382e-6f5d.rev.sfr.net. [2a02:8434:8fe1:4f01:fc4a:65a9:382e:6f5d]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-47a7d2e7435sm17412895e9.0.2025.12.09.02.55.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Dec 2025 02:55:40 -0800 (PST) From: naftaly.ralamboarivony@smile.fr To: openembedded-core@lists.openembedded.org Cc: Naftaly RALAMBOARIVONY Subject: [OE-core][PATCH v3 4/6] patchtest/selftest: Extract head-attached test loop into function Date: Tue, 9 Dec 2025 11:55:11 +0100 Message-Id: <20251209105513.273859-4-naftaly.ralamboarivony@smile.fr> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20251209105513.273859-1-naftaly.ralamboarivony@smile.fr> References: <20251209105513.273859-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 ; Tue, 09 Dec 2025 10:55:51 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/227428 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 Tue Dec 9 10:55:12 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: 76087 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 954E3D3B7F8 for ; Tue, 9 Dec 2025 10:55:51 +0000 (UTC) Received: from mail-wm1-f54.google.com (mail-wm1-f54.google.com [209.85.128.54]) by mx.groups.io with SMTP id smtpd.msgproc02-g2.5064.1765277743269902682 for ; Tue, 09 Dec 2025 02:55:43 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@smile.fr header.s=google header.b=2dDnXpCq; spf=pass (domain: smile.fr, ip: 209.85.128.54, mailfrom: naftaly.ralamboarivony@smile.fr) Received: by mail-wm1-f54.google.com with SMTP id 5b1f17b1804b1-477619f8ae5so42636555e9.3 for ; Tue, 09 Dec 2025 02:55:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=smile.fr; s=google; t=1765277741; x=1765882541; 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=uGQlNp2uNdzR9boq3JF5o7GfOo+2iFUN3orS5SRXRIQ=; b=2dDnXpCqNq5UJFljTN11KI41cl74WJmo+zWAMiB5Li67cotuzrw+V4wQBh/cEWVyRm U3x/wdWsBcl98EGSMU+dOqMDNTkwOXyXDfprBqM6pe0LbjoA4Gim5HuCZI7rS83CEegu G2c6llUfL4K+5ZvuEenLZEVaWm9kGQ+eBKdu8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765277741; x=1765882541; 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=uGQlNp2uNdzR9boq3JF5o7GfOo+2iFUN3orS5SRXRIQ=; b=QZUyRAmlKpQymRMz/qwP2Vo2iN6rYa/oQ4q5NFijS/aycF0f5IbY7PrBXqAW1LV6b6 stoHB0txMMSZQnuUR48ojqEU691fF2QxdZVxjmu/M8DDVXkjmgvyeW+yggJMCfDo3YQd ROrYhdvJ40X+iNpkd/qoFRDEq++eoDj1q3xX0B0uL1I/hs3hUvN/6abng8QPHUypse5C ewq3XAJTaysRZuzDtZ3doR+MRaEp0VZCTLWQSRKAUURb+dEzmj88rV5ebW5iV72QWI2g 7C4ST2Q01UjqbblkZZjlFD6O0qqvVbr+UQBNdRPohxyl8Ph7Rm1M2m9i5Bm4FGu4FC7P DBXg== X-Gm-Message-State: AOJu0Yx/thJG+t6fnh5OGUeU8o8s7tQN2C1ZF/OyURSlz9nbP9JqkL5f LAmQtoop6d3FRAN3Bxu2hcmznZuzWkw08ux7pWfZA2c1DT/5vEQBBH0yu3Gx3vaKUAL02YA9+GX l8NIc X-Gm-Gg: ASbGncvTIELHCZTIYh54moZVgcFJcIbndUfpz5UfjjfMsJIYnqLe8LUc6GBd/8MIviK KnHdILeweW4wzkCBoQoGnqgRna3dEPER2/H+F82xEmmCP5Vdd+0tO0aBy9JG6GvRFUblwUXQg7h SGTNopuVNIAyNEDQeohBc2aWt4/i84RCCGI5ZMMTj0ZOLs9WKa7bpX6WtfpM8OmQuTlo9FqEINB H/Ot2Y8zx1nEXVLWqfpoVqR29gj/n8eIVOZqiRvYuDBzcC/cXgsI6Ivl06McBvgr4yGKLcXAyH4 fNJ4RU0IMTDL9tGxMUoxu1Oh6e3r5PQcI8H/06pTJ4EIkEPyguEgQGUxq88UXqTebr3RXLQ2DjS n65soMSxRti4nrJFA+FbOfA1WwiLuHwBMNzyucb3PI0Z+QUJvWpi6CJeuFGaoaAz/bRC9eya3lh fj1e0pVnQgjRqShXach1iePyCTH70nOgyigcy5g3roPaMkt+JiCx/EUGmsr0pn1Fs6r5HUDRGEb KwJB03l8BJFhvdxcubyexA= X-Google-Smtp-Source: AGHT+IHPbFGelh+sJoGOTCb8quqwLwyKJ/KFH7qp4zcsXRQNgd1fF31qy1Oty9e+Qg53saCRmbRTtA== X-Received: by 2002:a05:600c:1990:b0:477:73e9:dbe7 with SMTP id 5b1f17b1804b1-47939e4d013mr122339545e9.35.1765277741519; Tue, 09 Dec 2025 02:55:41 -0800 (PST) Received: from P-ASN-DERVAUX.. (2a02-8434-8fe1-4f01-fc4a-65a9-382e-6f5d.rev.sfr.net. [2a02:8434:8fe1:4f01:fc4a:65a9:382e:6f5d]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-47a7d2e7435sm17412895e9.0.2025.12.09.02.55.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Dec 2025 02:55:41 -0800 (PST) From: naftaly.ralamboarivony@smile.fr To: openembedded-core@lists.openembedded.org Cc: Naftaly RALAMBOARIVONY Subject: [OE-core][PATCH v3 5/6] patchtest/selftest: Add coverage for detached and attached HEAD cases Date: Tue, 9 Dec 2025 11:55:12 +0100 Message-Id: <20251209105513.273859-5-naftaly.ralamboarivony@smile.fr> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20251209105513.273859-1-naftaly.ralamboarivony@smile.fr> References: <20251209105513.273859-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 ; Tue, 09 Dec 2025 10:55:51 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/227429 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 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..74b50f65e9 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, 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 Tue Dec 9 10:55:13 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: 76088 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 A4D0DD3B7FB for ; Tue, 9 Dec 2025 10:55:51 +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.msgproc01-g2.5199.1765277743712778945 for ; Tue, 09 Dec 2025 02:55:44 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@smile.fr header.s=google header.b=HMDA5fsx; 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-47118259fd8so44594435e9.3 for ; Tue, 09 Dec 2025 02:55:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=smile.fr; s=google; t=1765277742; x=1765882542; 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=SBLTGZNLSPZEAMHPCdlWjaMHwlo7lsl/mMKKYW3VfQc=; b=HMDA5fsxzFrH4KsbhXxKUa9/1tHz7IK+VSAdaXle5heUYuf36vsSiU118nUGizw7qP QvI3gCQd2wY4PWxaH/tWoRlCCrEYytipJrZ1yLWYVxEpLmy/gWpYwh9IzRbaVcpWoUmD XjpLdZcRH0PLmfTFVmOsKnOVXdsSEbsasnAcU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765277742; x=1765882542; 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=SBLTGZNLSPZEAMHPCdlWjaMHwlo7lsl/mMKKYW3VfQc=; b=cwpU/zGLHDpa98C4uNQYHRB4lTK/LIJG0pqASi+gCLrAQnoHnYqb7zN6ZkmSaKkWiP Q3GntswmEIXjuw4sGeKgpZFB3mr5eNS/zkX3KCJN9RFin1ME99oONVA6Lod3M5gmSgLT G/6BxZsLyH6KCMC5EHnCOmXWtFMcASQkaZg0wZ0DKZgP8tkG11xq5laZ8fOy5bdwhgkO jmomUCTA9qYjcSKQSSjloadylvi+EqIOtG6vTCkufmFA6ABXRtTxV1v1GXgXLooa8zkr m7sJyLevx5DLjwMgzpl2Yp84Sqeprp3J3fjgNAXB6cqDUXote1Xw7ikuJGbyJ9D4G/N2 bFQg== X-Gm-Message-State: AOJu0Yyvi062cuAv+pAAIwMYj8Tn4iaMj6fFOPWQrFUFWH6Cn/wT3GV1 az8NM+pT5u0l2oPvfVZwdVCJqSAao+ZdIjDC9wbgC/oUo8v/IUvhrZOHhRtMtgJNrvc4DGAJ+gd ha3+R X-Gm-Gg: ASbGnctopEZFQA+0JomxqEyVY/AVU0uUhxiKFsSt1rbCgOgeku94kaLCxJk0HpOVZ3f LhCnOb2SKQ1BveBx8TdKDnn0uf5Fz2fCiBge3QMATLtObD5FzWoyFKebCmyxpcXQfNQTU4RhtDl t6J//e2jrErJSqAMBBVvA/qX8Mx49BYVueZtmVJZ6ywXQf5wJ1P4Oqh0P2eIMJnWoA9i13nsN5l 2j/6oDZH2UiuvNaUs58ARL3i8f2539rvgJPOYr3D6LwhGclA1/qfgZFAhmwa4y6RntvGqys0pG4 LA8uoy0NYiCX8ui9RlDh0A/fcWCxY0yruY3h6k3IrpDSgvsaC5ydEOYiv2E9yb9pHxPau1LMJVn iUHxm4aIhKPXPJ4OV9nLmqeA+mBwgbXq4VYWlQt695WTVDyrZnbfJ6Z24F3V2G/RUfnS8NOgQoO SBE+3W675NFnKS3Ng3bQ68a+0G85JgzMEmn8OlMCJkwVWJwj/12g0INRj1NJxjMzLtEOrhXzADf +foA9seBI6YcUUoWP1x3eQ= X-Google-Smtp-Source: AGHT+IFek1OV7pbv8TyVfD3d9zY1ecY+j3eVvkJZJIEy7yz2y/j0UlDAfvmgRwWNz9UAC2uhGB5WzQ== X-Received: by 2002:a05:600c:4586:b0:477:7658:572a with SMTP id 5b1f17b1804b1-47939e27924mr97112595e9.20.1765277741938; Tue, 09 Dec 2025 02:55:41 -0800 (PST) Received: from P-ASN-DERVAUX.. (2a02-8434-8fe1-4f01-fc4a-65a9-382e-6f5d.rev.sfr.net. [2a02:8434:8fe1:4f01:fc4a:65a9:382e:6f5d]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-47a7d2e7435sm17412895e9.0.2025.12.09.02.55.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Dec 2025 02:55:41 -0800 (PST) From: naftaly.ralamboarivony@smile.fr To: openembedded-core@lists.openembedded.org Cc: Naftaly RALAMBOARIVONY Subject: [OE-core][PATCH v3 6/6] patchtest/selftest: Ensure HEAD is attached before running attach tests case Date: Tue, 9 Dec 2025 11:55:13 +0100 Message-Id: <20251209105513.273859-6-naftaly.ralamboarivony@smile.fr> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20251209105513.273859-1-naftaly.ralamboarivony@smile.fr> References: <20251209105513.273859-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 ; Tue, 09 Dec 2025 10:55:51 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/227430 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 74b50f65e9..dc8a636821 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