From patchwork Mon Dec 1 16:30:55 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: 75658 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 3BEB6D116F1 for ; Mon, 1 Dec 2025 16:31:51 +0000 (UTC) Received: from mail-ed1-f51.google.com (mail-ed1-f51.google.com [209.85.208.51]) by mx.groups.io with SMTP id smtpd.msgproc02-g2.25965.1764606702366483873 for ; Mon, 01 Dec 2025 08:31:42 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@smile.fr header.s=google header.b=H0ynnPzJ; spf=pass (domain: smile.fr, ip: 209.85.208.51, mailfrom: naftaly.ralamboarivony@smile.fr) Received: by mail-ed1-f51.google.com with SMTP id 4fb4d7f45d1cf-640a3317b89so6899885a12.0 for ; Mon, 01 Dec 2025 08:31:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=smile.fr; s=google; t=1764606700; x=1765211500; 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=H0ynnPzJbP8JIFHpCCP5ODgU9oHAk7F2XkuEdKGd4hsaF4ARHmI895yhHAl9p3EkmG zh2PBkOgknRqjnYD0PVFCNBpH592anKvJPZ3ou8w6dSZOXdXzQJ9a7gT0WDKZLpckdqY An0ROt3YyVQNpHVSohfg+L/P8dK5UFg96kzDI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764606700; x=1765211500; 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=VB+9EI2wiQz1/Nz+Bk5Y8cNPil66eH4tJW59pZW618zrsD9gvXla5YRGqH41ABCpvK GuarjRECUJWrJoa88M1UQxFaN3+3XplqZ/TR0Eya+6+8TgE66aDH4Y1+NE0JeTYZni4D 2YP4yiM7Khmu/RS9aOBu3mEqzYTNNafZTrOB5dWHe3ys9O6pHS9SN8CA3ZP17QS9OMb1 EZaJZiwI+wYIEw8cYB/Ucp61UmKyOUZAkLO+/Eaii2RwUMwhaPppGIcB+0x4JzYoVb0v 4jEZ6pbYt9gORltZvJtcf27LKrPx06M9VkdK+08cQ96G7v1VSk9gj8XmLy75al1MHxjk Rt8g== X-Gm-Message-State: AOJu0YwuSQJx4Y0BmK+Bq1+g7d5Txgs3nE2qacJenB8T4HYIZTW1HJ2m hKeyOqtDtHiIJBtQO451VxI3Pvbxi1ybByGadiX5YRKTqdAmcSVSEy/M772akEAX9WNDJjIaSsf CuDpC X-Gm-Gg: ASbGncvJUnWIAEabrOUHHd29j+yrUcZeZMiZbzHb1m1fbFAcE98inxjD/+qS1dEbKn8 Pg9UwOmDPuDuGXSGU4TR8LprdwoCVEhD4Lvseg2wdz8/yWmEpvf5CDMz68II9dOZHYvo6/3dkRS Ph4cPoQw7FZwyoZY5Ed55wyqy4RWeDB+Yz7rekMFenUXShvImwj01JD2kbPcRZKhkxquU6etPRL /GQaB43mjfG1RRwcPFDx9j4V/6SCgtlAegXD1aSpdf2DcyXl0Cxmdr8SAMYaY0oifOaFo/8voZ6 qelxwq1EvQaS85lxBlosVB4zeEhx9zehVWI6tuCgf+h5QRRVR9Yeg+xhclkvCuNKwfErPPALwUU KMIPXSp1Z6PTs3KGreC1R14yjqOAOxEE62jkuXXJ6qctWRVChiRVCS6LDLN+mvzX20Vcn8QiJUT 2eOFzVtSCvCBLX1tHvkDzEiv231NjjZKHQpwc58odxzpIDws+a93z0iQPJuIze9a5y4pm/+Q/6k xPpGTOKqDUoI+yDmCMNbMY= X-Google-Smtp-Source: AGHT+IEAApefWJnwbEpKEyOu1b/pvY742rgbqM0eM8gSrPbX3/Yg5fmgUfVN2zCjdKANY9Cli9tL2g== X-Received: by 2002:a05:6402:2787:b0:640:9d8f:3c73 with SMTP id 4fb4d7f45d1cf-645eb799fbamr23486372a12.32.1764606700407; Mon, 01 Dec 2025 08:31:40 -0800 (PST) Received: from P-ASN-DERVAUX.. (2a02-8434-8fe1-4f01-3d1a-8466-8f7c-672d.rev.sfr.net. [2a02:8434:8fe1:4f01:3d1a:8466:8f7c:672d]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-64750a90d45sm12980290a12.8.2025.12.01.08.31.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Dec 2025 08:31:40 -0800 (PST) From: naftaly.ralamboarivony@smile.fr To: openembedded-core@lists.openembedded.org Cc: Naftaly RALAMBOARIVONY Subject: [PATCH v2 1/6] patchtest: fix failure when oe-core repo is in detached HEAD Date: Mon, 1 Dec 2025 17:30:55 +0100 Message-Id: <20251201163100.143476-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 ; Mon, 01 Dec 2025 16:31:51 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/227129 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 Mon Dec 1 16:30:56 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: 75662 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 1C421D116F5 for ; Mon, 1 Dec 2025 16:32:01 +0000 (UTC) Received: from mail-ed1-f52.google.com (mail-ed1-f52.google.com [209.85.208.52]) by mx.groups.io with SMTP id smtpd.msgproc02-g2.25970.1764606711000905757 for ; Mon, 01 Dec 2025 08:31:51 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@smile.fr header.s=google header.b=zAr3YlX+; spf=pass (domain: smile.fr, ip: 209.85.208.52, mailfrom: naftaly.ralamboarivony@smile.fr) Received: by mail-ed1-f52.google.com with SMTP id 4fb4d7f45d1cf-6408f9cb1dcso6685133a12.3 for ; Mon, 01 Dec 2025 08:31:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=smile.fr; s=google; t=1764606709; x=1765211509; 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=zAr3YlX+5hCG0nNrBK3nXEwQw/TpDx+M3L7+amWS482iWSkynUMoBb0LS0CTF8r0Tz FrOSmCq5WtnvnApKDDSjNoh7/FzOOrSKuQaXDpYEgNKx0S1XCSXKX1GLjrzN26vDMHCJ l+6kCVezSnNRthSSzOa/oDHwnNuts1UWKoeC0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764606709; x=1765211509; 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=qtMaOFDttr21c3o2ghpbWxMJkIUTnqQj9amWGmogWFmG2+iDI2VBmEWmc1IEfW9F0S rSNDvj7LW5PPRW9pNbco0Z5UyHEk++O07fgpfKpfZJ5li+gZ62/C2jaTXK7QObwwgt+E ucdKalJYQgTyfDy0ycmpevQfjXX0Zdk8/8BlFcbyxJFX5iKqC5bXBN0mWLwSf+Vs5cMD /TH+tVwmK+dY50ElM8TKPRs7znn3G8Y/MtvbTeUxHgyNFU+CzqLX287JSMkXjX1y6lCk bLKWQXb5Doxo+BrnDyphUm+Y1X4u47isIf1TXaN3MsvCqPdZVeMEN3tTuPcY0rh6XvU1 B+LQ== X-Gm-Message-State: AOJu0YzNtkVKMsfBX8B6T1CvKyzaTzCz7ChJVryJVGSwwu6FgRP0110H 3rHjZkBJdMDb7zUkj68n0AQ+RF3bdLE5KhBXfnvgeG26e+C2FUfKoluQpskr1NY56uUV4xfiVV2 YKjCa X-Gm-Gg: ASbGncv9GTwiZuvxPjk7eyf+EqZgL5OydzDZCKnY/iokPkynSY/shIb53U352tEqfxg RR4lWKYdonYqr6bg19eoA4H6YFDRedyMGCGpDvNNLaiGyjTvwx1DaaGmYidjR5pOol/3igvg8jz J8BwWsFuBG8z7T92SOTcEpGBBU2WVhrnQ20jiex0kozjaGZIYWWLCA2+flTp/ctg9ToBo4pC/fI AMix+EEBDszoDz+GZxRF2ulBuPZmZUe1/qqgswHgZjiy2E7AfeXXPaqI3ojFeZgO6R+dlxelnZl XXlV4C6wbmetbaXdbpy3XR3w4vzAIRC/i3Oov/+mVcQ5b9kTfEEUymOrk+XCASQMiiA9BBOP7Qu o9R7zpGU3MU6isZA0ES//kmEKMzB8V9z/D6OlbEWaGyDBJmwjPn0+2+BqV5iAGaNJVwOhQzk0G2 6ixr6Ge/y3ZhLJxIas7HhZwPVR2V810Z94Qjv646dwQ8x/QUvE2uxsKI5snFNSngepRI554oXFK 3axEczEC4P/oaK6dA1dStI= X-Google-Smtp-Source: AGHT+IHNrkh2Y+iuYK45w7ZqrVsqj+nEVQefBLfc5MOyn0g3i8Xa4T9PNUXDAYWgJq0lQGYZcTjzAg== X-Received: by 2002:a05:6402:d0d:b0:640:f481:988 with SMTP id 4fb4d7f45d1cf-645eb296a59mr22952441a12.19.1764606709063; Mon, 01 Dec 2025 08:31:49 -0800 (PST) Received: from P-ASN-DERVAUX.. (2a02-8434-8fe1-4f01-3d1a-8466-8f7c-672d.rev.sfr.net. [2a02:8434:8fe1:4f01:3d1a:8466:8f7c:672d]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-64750a90d45sm12980290a12.8.2025.12.01.08.31.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Dec 2025 08:31:48 -0800 (PST) From: naftaly.ralamboarivony@smile.fr To: openembedded-core@lists.openembedded.org Cc: Naftaly RALAMBOARIVONY Subject: [PATCH v2 2/6] patchtest/selftest: convert separate count variables into a results dictionary Date: Mon, 1 Dec 2025 17:30:56 +0100 Message-Id: <20251201163100.143476-2-naftaly.ralamboarivony@smile.fr> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20251201163100.143476-1-naftaly.ralamboarivony@smile.fr> References: <20251201163100.143476-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 ; Mon, 01 Dec 2025 16:32:01 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/227130 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 Mon Dec 1 16:30:57 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: 75660 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 1B263D116F1 for ; Mon, 1 Dec 2025 16:32:01 +0000 (UTC) Received: from mail-ed1-f45.google.com (mail-ed1-f45.google.com [209.85.208.45]) by mx.groups.io with SMTP id smtpd.msgproc01-g2.25753.1764606714262111206 for ; Mon, 01 Dec 2025 08:31:54 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@smile.fr header.s=google header.b=xoD48Pfm; spf=pass (domain: smile.fr, ip: 209.85.208.45, mailfrom: naftaly.ralamboarivony@smile.fr) Received: by mail-ed1-f45.google.com with SMTP id 4fb4d7f45d1cf-640860f97b5so6875576a12.2 for ; Mon, 01 Dec 2025 08:31:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=smile.fr; s=google; t=1764606712; x=1765211512; 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=xoD48PfmoTzxymrza8r+IIvDs0U81bm406HBNM5vKOUxiw9O7rOnljWLUTkss861kb zTaFDQnLsoqCOKz7zMINJFnd445hIH74WTh84trD9WufPsGvUYpC5AqXd1FZ0jznJc9X lXfPgIBkyTvbqGZ+lx9ZLBUlatJnKueaMyIAo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764606712; x=1765211512; 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=t2WDkVbq90CZZ5AeL5ksMvh+bpVusKC6sUpWDguQmBBG56UuUyXEXBHvM7RyMqp1Cc MMC3GUmol4xFaxMRlMGelDU6+C4LePI7Hi7s+/cZnNSdoWChY192JuFoGnoJ1LEMOW9g 7UZQSigwut9YgvAonDl2o46h2U5HifdbFoCFC19SB9aGoudkMGOhqejki/iDxJ5C+WZ3 evEDwxyyoH7cDPeBqxqBTN4mLu1PZcv3Sd4orYX+fJmPrLWI3Wh3CRx1SfRsTfUdSlZY yR8xBhdYe4G3wWHh5ZpQQ4T8saLn5ONBYxBp5/PfL0qlMIdHf5CF9BmkSczua2a7c8Ay r3lA== X-Gm-Message-State: AOJu0YzAQpudfQqTsmZdUfL+bAi2yBPzOg/v+VZKBSMMTe5RD92tijlA OZgd8WbW1wazh/RtTH3yrU+7CvW1g8jBLmueBQcppRTBTmgkoMp5G68ba/MFAFGqTIZXPbLyNvD 2W1Jr X-Gm-Gg: ASbGncuqkZY/dOvfRYzAttxKnc5IttM/JeM28BycCrSFEpK7sHyqLg94K3G/6c77z4G QjAVvxDye5aGTObn2zR3bf52vYbArPlvax59PZHzDaith70cHiPeOr6Nr2Z2ACg4LaboWX/q9Lf vaWyA3xAnA+/bRM5599nvnULbACRD7QXhlkd+csyVrzodo9n9f6Iy4EVO2C4F1jwuuYTfGxw/XB BZ+LFBm6QZ481KTZFhqWnOeR2oBoRILHK56IstKVE+DYs4lGtj//gS6BW0TgT25wylTLlmlYbGZ kVG4fq5fUa7qYeWQzfY+ats/VC4HntYOUrnAilJHZHvCyOxx8xiC//IM9NyCw5W1kgQXSOicV4J AvYpkSqzg0wCF6QYwE/hrRABIb6f/zEcSN6Wi0QEpacSMmFSdOFnvtUMj/pWljgFMj6EoKNdwDb JEser5csFVC+D2FRA8FCCfSQCq0RZpYt+MuDs9b4WzgnOur0Z++32j9JvbLcGiEk5qNzdQNfQxR DIi5dDpyMxyvKdO7YdpTqo= X-Google-Smtp-Source: AGHT+IHYdit8WtQ4nINlMdRpmBNFBz8PNCQBV8buTl10cVImrJkjtIUPKRyY3/ZK07smfh3DAUGt4g== X-Received: by 2002:a05:6402:42c4:b0:647:8538:fd15 with SMTP id 4fb4d7f45d1cf-64785390039mr18603a12.8.1764606712401; Mon, 01 Dec 2025 08:31:52 -0800 (PST) Received: from P-ASN-DERVAUX.. (2a02-8434-8fe1-4f01-3d1a-8466-8f7c-672d.rev.sfr.net. [2a02:8434:8fe1:4f01:3d1a:8466:8f7c:672d]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-64750a90d45sm12980290a12.8.2025.12.01.08.31.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Dec 2025 08:31:52 -0800 (PST) From: naftaly.ralamboarivony@smile.fr To: openembedded-core@lists.openembedded.org Cc: Naftaly RALAMBOARIVONY Subject: [PATCH v2 3/6] patchtest/selftest: refactor patch retrieval and result analysis Date: Mon, 1 Dec 2025 17:30:57 +0100 Message-Id: <20251201163100.143476-3-naftaly.ralamboarivony@smile.fr> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20251201163100.143476-1-naftaly.ralamboarivony@smile.fr> References: <20251201163100.143476-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 ; Mon, 01 Dec 2025 16:32:01 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/227131 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 Mon Dec 1 16:30:58 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: 75659 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 22A04D116F3 for ; Mon, 1 Dec 2025 16:32:01 +0000 (UTC) Received: from mail-ed1-f43.google.com (mail-ed1-f43.google.com [209.85.208.43]) by mx.groups.io with SMTP id smtpd.msgproc01-g2.25755.1764606717185446175 for ; Mon, 01 Dec 2025 08:31:57 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@smile.fr header.s=google header.b=foi8nmnx; spf=pass (domain: smile.fr, ip: 209.85.208.43, mailfrom: naftaly.ralamboarivony@smile.fr) Received: by mail-ed1-f43.google.com with SMTP id 4fb4d7f45d1cf-640a503fbe8so1077929a12.1 for ; Mon, 01 Dec 2025 08:31:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=smile.fr; s=google; t=1764606715; x=1765211515; 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=foi8nmnxeHAVETVSSuTQyf+NYHwVdOJxAZeWgn/Ke52SkGqqLZlIVM7hTEyaEUGG8I sfwDalFwWv7TdEk0vurdgva6wNwqMs3pUGmzeC9nk4/54KNNsLVFNbzrVH4LyA14+phY II3wE2naYTSxPwO6Fa/D2tybf+ARJc9sUPa6E= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764606715; x=1765211515; 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=T1RXMoa9L7G252nOaQ2j0NS54XeJFdSm9jxOrZ3Ovpq5QWK1AMngtAWlsrcwDUCP2s MXS7bs7WctYFR1YqVHYtEa+QtP41e8ytr8Tm/C+XHJ1IqP2Js6Iyj6HTajO0eU2HCEF+ +hnPgBLPK0zS7iOQYHfZ1w9D7FA/lHimBeEvPL9McRlNAPwXbDZ9KodQOIoofKDCa0r5 XHGhhGje0fk1ML81TipJae9/eebjxKgmT5CegOINL/ynGpWoqPpdnxypJMS8G6W/iIdp Y/JmsFmCo6x30EV3fLlZKb0jJEi7ahTtSVWOd9fY333Lnx+OycnjaMea4iK9LEyuB2N7 jS8g== X-Gm-Message-State: AOJu0YyTY6HSsLXuRo6aIaEYohndUbkg26O7BsWhKiApwklFHev8kcgI CpepnkyidbSyw/GrwkElcbb1i2zKTdvS/Ns33+CO/zrfhAu/jFtNYKBraHO21dsJlDKwC8gymZ/ a9Hhn X-Gm-Gg: ASbGncupzQqiqwJYNF2MtHb5o9elQ6JmUcLdhhpxtb+NJnSfHTR2URowr7dny/ebcNR frn5SJ+yVR0SfJsGX9tfLrXB7+wK+FZOzBE+QC5vIewhTKbzRACFbVDrTKxCWKpxjELj28eOwCs XHyqPrxbtJn+rCsJXpzhm4yFdTTYHdVkAwml31YhAxc8ICCaK/3t8QOQFPUUV8ZhySotGzaomeo cMvUaXItPla7MHha//hqKA4VNNX1Mtg8npqfNMk4YYQQGJhC5n0jOLrq89L+4cHrVHoAicd+J2R dP8feUUdLxmJK9vM1qEJ6WxUHrYV92OZIfYl22NTj9yGzaywJScslktGQRDKjSJtpae4TVc59RU vP9GEr7MYezTst7usS7vmbRon635DisIfL+UtWugAWIYsdHk/p5ExCiizscqTrQw4d/sGi2TpnQ A9tULJEoEd62laDhSjp29NpOqSyu36+2GX1rGJE7AHzAcsoUtKq+abLkFNb3bw9+96Jo7Ml8FO8 zZ0H/GQaAEbt02J73QJNvU= X-Google-Smtp-Source: AGHT+IHPcK2p+CxLn98z7YiGJ6unIG32vo1npjafKNixXEglGudbmzRmejqbSTVpEkdCTzsKxJOdvA== X-Received: by 2002:a05:6402:24d4:b0:647:550a:2f3a with SMTP id 4fb4d7f45d1cf-647550a2f6dmr11257657a12.5.1764606715372; Mon, 01 Dec 2025 08:31:55 -0800 (PST) Received: from P-ASN-DERVAUX.. (2a02-8434-8fe1-4f01-3d1a-8466-8f7c-672d.rev.sfr.net. [2a02:8434:8fe1:4f01:3d1a:8466:8f7c:672d]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-64750a90d45sm12980290a12.8.2025.12.01.08.31.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Dec 2025 08:31:55 -0800 (PST) From: naftaly.ralamboarivony@smile.fr To: openembedded-core@lists.openembedded.org Cc: Naftaly RALAMBOARIVONY Subject: [PATCH v2 4/6] patchtest/selftest: Extract head-attached test loop into function Date: Mon, 1 Dec 2025 17:30:58 +0100 Message-Id: <20251201163100.143476-4-naftaly.ralamboarivony@smile.fr> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20251201163100.143476-1-naftaly.ralamboarivony@smile.fr> References: <20251201163100.143476-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 ; Mon, 01 Dec 2025 16:32:01 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/227132 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 Mon Dec 1 16:30:59 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: 75661 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 2997FD116F6 for ; Mon, 1 Dec 2025 16:32:01 +0000 (UTC) Received: from mail-ed1-f51.google.com (mail-ed1-f51.google.com [209.85.208.51]) by mx.groups.io with SMTP id smtpd.msgproc02-g2.25976.1764606719953605507 for ; Mon, 01 Dec 2025 08:32:00 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@smile.fr header.s=google header.b=qb8LMRI4; spf=pass (domain: smile.fr, ip: 209.85.208.51, mailfrom: naftaly.ralamboarivony@smile.fr) Received: by mail-ed1-f51.google.com with SMTP id 4fb4d7f45d1cf-641677916b5so891066a12.0 for ; Mon, 01 Dec 2025 08:31:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=smile.fr; s=google; t=1764606718; x=1765211518; 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=kvMKt8L+q17DFV0JT8WPvbRvfEPNwCYznrvWQ0ld7+E=; b=qb8LMRI4rSUXiqQjSr3kApJ88kAH1wpiuk/9MvkV8TVsMTDESUBJgJ0m2KjeCpr+us 9hY48r+j2ZGt/+Rrwa+PipdQcZXN44Q3XzJgLsYG4W23vX+MiXzIVsQUWdbSqnP9L1k1 KROl2fK6LV63rSB/62SKDdJ+OGDqIebbIXCzU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764606718; x=1765211518; 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=kvMKt8L+q17DFV0JT8WPvbRvfEPNwCYznrvWQ0ld7+E=; b=r4FOczzIIhSeHYV0rYB8V+5lbMtRNFU+A6Xr35CLqC7gG/ypJ3BvzSSoxkb4ZNAIMV xiTmdT/CrmIPzkSE4c26VEyamMAZcUulb0dhDnxoJXQw9+GiIjJWp6syW6WqxCLF9QaD lbMIYX1al8NwVQjSbCmvuBipjEbqI8n7JEiT0tlzf1VVB2znhLP9hHYE5C0ickaWgfGZ oHVjjh3BRu0yw888NOR3HsCLfjEyW3s8SnQV7Kfz4f67Roj6eHh4vSiRodf0KmFnXmuF 1jqiJG2Uom/wc2zZvYkaQ9LBQCtpPZVr4NRyzy9Pn5SiDjsZbehpBqKiT5oXyJVjCD2E BExQ== X-Gm-Message-State: AOJu0YwuqEMP2s4JsxGSYzBzpEU5w4vAbzmYmcAnJsz/W+CYH5xAYk6M m+DXDOY7CkQx8R+y44uDFMrwMd2ZgnUDwf1/z+fwdYgZMwwoGvGZ6EN/JpGGelDeEfRoBDLt7ZH p+ZrJ X-Gm-Gg: ASbGncvpMz1oBEcMVDk8WlUKxZErpu9L+aS460BOz2AyGSQJixgvhqalG87Sag1Cvog zAm5dpnXJgHwxsg3TNB7ynKOOp2v6/dK37Sc81eLA3/jFqe11hql+HT9uMp5o12QNkLm3K2ILWf P26s500RpwHDrT1Sr9kOKxN0/2ysArz/cAq4vJ6gbCHGUk3Xb/HyCmRmeMAmbZ7b9FxSEXSdHv6 kD2Uv76ELULt6eW6pm2Q6JG+R5M9fG2S98NlFqiTtkGLX58zoPEANSEpQYXhGWaRkSUky0+eR91 wDDXWcNrjo9mEDY0ulwnhbtwvUaraiOJ2+Ku9E1XNMbI8/Okbwm+/iLzAIlipUZL3HQdjppwfEc 6GED4JHyupsKCq/qm/18Ls/KVy9G+X6d/9qPcfbEjhJt/LwUV4+9Uug6zd0D8sFnvDy6JG272gI Gt+azUahJht5ycz/yM1e8tOUDtfyqrQI6Pe/s6QvbieuD49z6DlTYSH63zYX+7rKIORZXTG0ym2 hAshqcBFPcqRbsNai8qsVbdhdv7LDWZbw== X-Google-Smtp-Source: AGHT+IFzEQJefyr/oXzcHhGW+j37imhN3ciLp/RSlyKwuw/7vl7D94TLA9A17gPYxDs+9Nh6N42FAw== X-Received: by 2002:a05:6402:254d:b0:643:1659:758a with SMTP id 4fb4d7f45d1cf-64554677268mr37097312a12.28.1764606718075; Mon, 01 Dec 2025 08:31:58 -0800 (PST) Received: from P-ASN-DERVAUX.. (2a02-8434-8fe1-4f01-3d1a-8466-8f7c-672d.rev.sfr.net. [2a02:8434:8fe1:4f01:3d1a:8466:8f7c:672d]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-64750a90d45sm12980290a12.8.2025.12.01.08.31.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Dec 2025 08:31:57 -0800 (PST) From: naftaly.ralamboarivony@smile.fr To: openembedded-core@lists.openembedded.org Cc: Naftaly RALAMBOARIVONY Subject: [PATCH v2 5/6] patchtest/selftest: Add coverage for detached and attached HEAD cases Date: Mon, 1 Dec 2025 17:30:59 +0100 Message-Id: <20251201163100.143476-5-naftaly.ralamboarivony@smile.fr> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20251201163100.143476-1-naftaly.ralamboarivony@smile.fr> References: <20251201163100.143476-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 ; Mon, 01 Dec 2025 16:32:01 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/227133 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 --- meta/lib/patchtest/selftest/selftest | 67 +++++++++++++++++++++++++++- 1 file changed, 66 insertions(+), 1 deletion(-) diff --git a/meta/lib/patchtest/selftest/selftest b/meta/lib/patchtest/selftest/selftest index 92acc4d556..c85d59c415 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,30 @@ 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 repository state changed after detached HEAD test." % testid.strip(".")) + counts["error"] = counts["error"] + 1 + else: + print(" Test '%s' passed, with git in detach HEAD repository state remained identical after detached HEAD test." % testid.strip(".")) + + 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 +183,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 Mon Dec 1 16:31:00 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: 75663 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 29983D116F1 for ; Mon, 1 Dec 2025 16:32:11 +0000 (UTC) Received: from mail-ej1-f50.google.com (mail-ej1-f50.google.com [209.85.218.50]) by mx.groups.io with SMTP id smtpd.msgproc01-g2.25759.1764606724214484488 for ; Mon, 01 Dec 2025 08:32:04 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@smile.fr header.s=google header.b=0PTfP5aF; spf=pass (domain: smile.fr, ip: 209.85.218.50, mailfrom: naftaly.ralamboarivony@smile.fr) Received: by mail-ej1-f50.google.com with SMTP id a640c23a62f3a-b762de65c07so88863266b.2 for ; Mon, 01 Dec 2025 08:32:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=smile.fr; s=google; t=1764606722; x=1765211522; 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=kPOLotiLY9x+9e8VJGnRhVFCIDwZssgja6Gg7H7luMA=; b=0PTfP5aFfCmNYgF1yPhiYA+ooELi9QhUBBAqOzc4urbZnj8od13mVk1oaemzHKX+gC NuPyo7yx8l77iHwN03IDCu+nHQgYLSnNC5Yg5kXby8oFpkzRCfqbZf+3djHSpMpA4HpY feua6Aej4juhpmINQfNzRi7Y+6QtDOzCjAj78= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764606722; x=1765211522; 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=kPOLotiLY9x+9e8VJGnRhVFCIDwZssgja6Gg7H7luMA=; b=b7sNm28WthEI7iEPeQG27ZBvOSMTHMQ5KHsIagO1mNoLlpaTJaINCc/8Wdd9Ixghfs FLqER9AKqauOTvGGpciOruDOU1v7yCcoem8PU7fzB+8G8Oe88CbiUxF0/oMLJJ/keAFo Hj5fsIL9EKDvUo8vpvXrlYQxIirFHpnfaJH5fujvpadi6382CpPQ8FO2ao3n34KtINPe irckOaPalHM4fZYLi7f4ke+SnJDPo/jXWtTfnqHaIlruBVoaMV2RlVQQd4rEUdTelYIL x79XE36XTHzdOrwVX1nfq0aOL5dOOqhDZwFQExhh1JKBb2Lk/7tLYi+Zi7SwU6ePhv5J tYhw== X-Gm-Message-State: AOJu0YzzxGztA6gY8hMCS8vqd2JQWRluqLaTek6wOmweyBk3eE4Lbmyh HtKA1hTLoJRx9W43vJaiIg7JYqqPJBIR4DXIoZ6jUhvDN+tuNs4ZjrJFD7sWGyO8LxTVTXSipvd mph6V X-Gm-Gg: ASbGncvgJVEVcaO7tX7epC2X0QFMGms9lqDxQ3NniJ7Na1baYzwIjobyHcMjDk2cgrV x5s41jLxvw0QE5RB48//IAXfNky67bffc4Kb34LVZrKUvRuiWr5TBX9aap4z6eLbC2kLt/Wgikh MK6WeAALG4oDalcAqOHMSghlxErSWnQ9n217JvcyQa80XBBCqP49WhAhW2os33T9gWDiJDed4D2 CTNA1+L89w6S2YG6hV4hLfazx5UJuTC4E4P0RzpI1jeYrEMvQ71R7cWWAPNQdpg7QHzx+Cf5ifM +n275aKMoYPseQgAWlvlyvSrPow6xaiLppMvr+S5CL6WhF6TSr2Er2L7Rq6VCmRuFcj1zM/fcp3 2XnaR7nLoAxI+qPtQvLaEv7M0lruyk2FZcPyMQ2cUWdnWcex5JWsG5NyAtfkaAtJcdVeh1xH6pS W7Rhmw4d4KNxIcnBx5wR8VfimnjlFVeQjdYxO09iIAoBsWV5doObNGNG0u+qTBNYiBIEid3DckX 4QstfIeYhm2K6SNfi84Ln0= X-Google-Smtp-Source: AGHT+IFl2YgXBfSeCO18KWpl9PLoYLSMXasJl07KlIJTsnLPE2RmuVQpn5STdnzIJ0W1FvxpqXBOTQ== X-Received: by 2002:a17:907:608f:b0:b73:4aa5:35e5 with SMTP id a640c23a62f3a-b76c546d3a8mr2789061966b.7.1764606722332; Mon, 01 Dec 2025 08:32:02 -0800 (PST) Received: from P-ASN-DERVAUX.. (2a02-8434-8fe1-4f01-3d1a-8466-8f7c-672d.rev.sfr.net. [2a02:8434:8fe1:4f01:3d1a:8466:8f7c:672d]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-64750a90d45sm12980290a12.8.2025.12.01.08.32.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Dec 2025 08:32:02 -0800 (PST) From: naftaly.ralamboarivony@smile.fr To: openembedded-core@lists.openembedded.org Cc: Naftaly RALAMBOARIVONY Subject: [PATCH v2 6/6] patchtest/selftest: Ensure HEAD is attached before running attach tests case Date: Mon, 1 Dec 2025 17:31:00 +0100 Message-Id: <20251201163100.143476-6-naftaly.ralamboarivony@smile.fr> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20251201163100.143476-1-naftaly.ralamboarivony@smile.fr> References: <20251201163100.143476-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 ; Mon, 01 Dec 2025 16:32:11 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/227134 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 c85d59c415..5f742a85ed 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): @@ -159,10 +167,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