From patchwork Wed Jun 25 13:52:26 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Purdie X-Patchwork-Id: 65617 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 58640C7EE30 for ; Wed, 25 Jun 2025 13:52:40 +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.web11.15937.1750859551616641477 for ; Wed, 25 Jun 2025 06:52:31 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@linuxfoundation.org header.s=google header.b=OOl1lmbP; spf=pass (domain: linuxfoundation.org, ip: 209.85.221.48, mailfrom: richard.purdie@linuxfoundation.org) Received: by mail-wr1-f48.google.com with SMTP id ffacd0b85a97d-3a6cdc27438so5556729f8f.2 for ; Wed, 25 Jun 2025 06:52:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=google; t=1750859549; x=1751464349; darn=lists.openembedded.org; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:from:to:cc:subject:date:message-id:reply-to; bh=Zt+7ffIF1VRL0MiU6KQsgh93xfcYicKUAbB2nyIk7V8=; b=OOl1lmbP12jIYnL7t1YoYxA6TMwCZLFaTHcgcVJmMnrB/QbRmdeA3Y7nkiAsYk938D HmZJJ9+dY+IkuBZ048WwcXj34PNXc4ewSEzh7oqeOqDEj9TTCdXzn0HzIcif6GYrmk6M sU5m1DOX2gl98BctSFRei30EPJyOZhjVdIc5o= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1750859549; x=1751464349; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Zt+7ffIF1VRL0MiU6KQsgh93xfcYicKUAbB2nyIk7V8=; b=QHYi9BTMXoHFMa/q9ZevAlZprSEDO3dPRvwLtatceShCQeultAfYJnDi0LpEa1oBmN PKLHBYVztpH2eDi9lvv15AoFa18bapznaAOAffRHPKFPqLEb1uDfbbZgVbFqfDATOmIA t7LHcTqmcQlJH4MIQJ+EmYy+hYle/XVRb7j7UxLsY+RFQEJdvmzZeix93otW5pEeSuwT wdTD0ikfWKrJdqEB8sU9b7QXBjV0XFE77g0iEpptdKrFiE8hnIwbVK5XVJ3P44kUlh8g ZZn03954Vq3rCXjJUOvm39jg8CVj+rmhZLHqCBfiPfvp7Cv81SXGLisb0NKwcFOoZ8Sm rpuA== X-Gm-Message-State: AOJu0YwwBPoRR6OHBxRPZ9tjBN1Hsfj/jjB8A7BKCiLeSiCYwEjgOFtP 7OrlFR+P1kJkU9CMW3hjDzycQFSm/SKHd51uzEo7N/a9UqFxd6zsDMkJTT8d9xcvukU4xVyrJ24 9qnRE X-Gm-Gg: ASbGncsgZfHTGQBvX/DaeguxOOyV/ZOJ+NMGicNMTeGXP/2xeDN2XmrHwuPIhA7mMaB zv9ntElEeGCrLALS1ogzDF10DmPnKg0SINpcoFIgWpcHNr4GeL3eqfmlevqhjO+36bb/q3YJ+KW Ghh2M+gF+RkiZVbTCJTLNOYyKI7/m/i6lUm6ogsMnseag4iSbRhgc4qvCNAC03Vg4cVcRgh3KBz t7OmStVKyH1SgfrhG37Caqm1bn1kaXE3wAEEYj2HDc6+nsjZLOmgrBzjxDUZpJoE6XKcGwqsSmv 9SDWLVs+IjAmsYiCzd6yy+YGXHkmRzVWdgE2NH3E4bviSRLER51/vcgw4P2gvaVMKPX++J3Yw2D 7Dsv9mGIW1peORAg= X-Google-Smtp-Source: AGHT+IElsk/+z1gf+GGbga82QvzbEjYwFblPdOuG6JoxBa6KgEymE+UtQYwPfycjhwNVNmqEpMylUg== X-Received: by 2002:a05:6000:2502:b0:3a5:2848:2445 with SMTP id ffacd0b85a97d-3a6ed5f27e2mr2474653f8f.16.1750859549390; Wed, 25 Jun 2025 06:52:29 -0700 (PDT) Received: from max.int.rpsys.net ([2001:8b0:aba:5f3c:f1c1:2228:ff4c:9514]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3a6e810b140sm4657419f8f.80.2025.06.25.06.52.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Jun 2025 06:52:28 -0700 (PDT) From: Richard Purdie To: openembedded-core@lists.openembedded.org Subject: [PATCH 1/2] oeqa/sstatetests: Fix NATIVELSBSTRING handling Date: Wed, 25 Jun 2025 14:52:26 +0100 Message-ID: <20250625135227.3106042-1-richard.purdie@linuxfoundation.org> X-Mailer: git-send-email 2.48.1 MIME-Version: 1.0 List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Wed, 25 Jun 2025 13:52:40 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/219320 The NATIVELSBSTRING variable changes value once a BuildStarted event occurs in a build directory. This meant running some of the tests directly in a fresh build directory would fail but they'd pass when run as a group of tests. This is clearly suboptimal. Move the NATIVELSBSTRING handling to a location where the value is consistent and a comment about the interesting behaviour of the variable so it hopefully doesn't catch out others in future. Signed-off-by: Richard Purdie --- meta/lib/oeqa/selftest/cases/sstatetests.py | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/meta/lib/oeqa/selftest/cases/sstatetests.py b/meta/lib/oeqa/selftest/cases/sstatetests.py index 487995acc3a..7231115a6b9 100644 --- a/meta/lib/oeqa/selftest/cases/sstatetests.py +++ b/meta/lib/oeqa/selftest/cases/sstatetests.py @@ -27,17 +27,15 @@ class SStateBase(OESelftestTestCase): def setUpLocal(self): super(SStateBase, self).setUpLocal() self.temp_sstate_location = None - needed_vars = ['SSTATE_DIR', 'NATIVELSBSTRING', 'TCLIBC', 'TUNE_ARCH', + needed_vars = ['SSTATE_DIR', 'TCLIBC', 'TUNE_ARCH', 'TOPDIR', 'TARGET_VENDOR', 'TARGET_OS'] bb_vars = get_bb_vars(needed_vars) self.sstate_path = bb_vars['SSTATE_DIR'] - self.hostdistro = bb_vars['NATIVELSBSTRING'] self.tclibc = bb_vars['TCLIBC'] self.tune_arch = bb_vars['TUNE_ARCH'] self.topdir = bb_vars['TOPDIR'] self.target_vendor = bb_vars['TARGET_VENDOR'] self.target_os = bb_vars['TARGET_OS'] - self.distro_specific_sstate = os.path.join(self.sstate_path, self.hostdistro) def track_for_cleanup(self, path): if not keep_temp_files: @@ -52,10 +50,7 @@ class SStateBase(OESelftestTestCase): config_temp_sstate = "SSTATE_DIR = \"%s\"" % temp_sstate_path self.append_config(config_temp_sstate) self.track_for_cleanup(temp_sstate_path) - bb_vars = get_bb_vars(['SSTATE_DIR', 'NATIVELSBSTRING']) - self.sstate_path = bb_vars['SSTATE_DIR'] - self.hostdistro = bb_vars['NATIVELSBSTRING'] - self.distro_specific_sstate = os.path.join(self.sstate_path, self.hostdistro) + self.sstate_path = get_bb_var('SSTATE_DIR') if add_local_mirrors: config_set_sstate_if_not_set = 'SSTATE_MIRRORS ?= ""' @@ -65,8 +60,16 @@ class SStateBase(OESelftestTestCase): config_sstate_mirror = "SSTATE_MIRRORS += \"file://.* file:///%s/PATH\"" % local_mirror self.append_config(config_sstate_mirror) + def set_hostdistro(self): + # This needs to be read after a BuildStarted event in case it gets changed by event + # handling in uninative.bbclass + self.hostdistro = get_bb_var('NATIVELSBSTRING') + self.distro_specific_sstate = os.path.join(self.sstate_path, self.hostdistro) + # Returns a list containing sstate files def search_sstate(self, filename_regex, distro_specific=True, distro_nonspecific=True): + self.set_hostdistro() + result = [] for root, dirs, files in os.walk(self.sstate_path): if distro_specific and re.search(r"%s/%s/[a-z0-9]{2}/[a-z0-9]{2}$" % (self.sstate_path, self.hostdistro), root): @@ -153,6 +156,8 @@ class SStateBase(OESelftestTestCase): bitbake(['-ccleansstate'] + targets) + self.set_hostdistro() + bitbake(targets) results = self.search_sstate('|'.join(map(str, [s + r'.*?\.tar.zst$' for s in targets])), distro_specific=False, distro_nonspecific=True) filtered_results = [] From patchwork Wed Jun 25 13:52:27 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Purdie X-Patchwork-Id: 65618 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 578BBC7115C for ; Wed, 25 Jun 2025 13:52:40 +0000 (UTC) Received: from mail-wr1-f53.google.com (mail-wr1-f53.google.com [209.85.221.53]) by mx.groups.io with SMTP id smtpd.web10.15856.1750859552983175075 for ; Wed, 25 Jun 2025 06:52:33 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@linuxfoundation.org header.s=google header.b=VMgeboXI; spf=pass (domain: linuxfoundation.org, ip: 209.85.221.53, mailfrom: richard.purdie@linuxfoundation.org) Received: by mail-wr1-f53.google.com with SMTP id ffacd0b85a97d-3a54690d369so5804120f8f.3 for ; Wed, 25 Jun 2025 06:52:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=google; t=1750859551; x=1751464351; darn=lists.openembedded.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=cJqezQHi4cyTkHGxxox1mH/485pIFKKc0PeGK+ogIMM=; b=VMgeboXIAPdNrL7bz6xDmVMkunsBcCnwUV598bO35C2Nfq3g1SSfM0M1Y2vInC+HnG BBTCKF1uwDz//Rxu74/kYZ9VSKnoRpDD5VLF6WmteoRnoWyF0mlZk9ZqLKHXisDc+jqJ Xf5zKPIYrsphlmTr/1VuGweupNM1Kfdi00MEM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1750859551; x=1751464351; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=cJqezQHi4cyTkHGxxox1mH/485pIFKKc0PeGK+ogIMM=; b=d1L9gExlYuRNB2wcYuGA4nDPsvvPsqm4KqWVjt1bK9SNDmCHEljn5gHP0JovevU8Nv grDXBvEnMLd2pmAw9mGY6IfVcoRdno8+qBJHa2esRg5bK9a5V7jd8h5Mj0FtzBWFed2X tG1GLEhntrcQDVO8YormHU2mB8nb2Sx0w5A7n7jjbazNs62VuWZYFHT3+DVj+febWhy6 hA6mWiiwwVlouErdIhlyCOKLNokvErRj2ckFtiW4tcWKSKcteiIzXUIuu8p1rvsOQz06 awvmR0LNj41tiV9jNB+wUFaUSm5rJRUdjLpC5MMKaGVHGjvVIM9ximc4r3tN+/BxgwgM 5Xtg== X-Gm-Message-State: AOJu0Yz3C0vXNC84MoB9nb5f+2Dzor5cVhumKaUpfs+9HauLtiJQLDfO XHcuuVCt69aX5zQ3uVAhJL7npH0Yl/GMB2DkyV0+9UVyZQx7nKYuDtnWm8a1wSkGicu3dzOJOSk eNMnw X-Gm-Gg: ASbGncs8gZeuSCVDgYmsuUNOYyzMmurjnj9h8zk0b+PaTwykEQoWtMtfELb11lM9670 akvPgmeJ8sTiblLtuqzkjrHRQmTXq4JYDhx8x+hCYaGZoZ40Ct4+PVdoTnP9PUyaKsNs7wVnZvj 9SCqh1eOyZOYNcQp8b+xd2wDbX2titjbH9TWIi5tdps6PPNfN9MJ8MVmarZ3PvFOkNcPyngRLak dKsiwvzad9aqJD6SI5IR/k0WCDUOOvBkBtGKYyce1mEDC5QySI5vsswn8TFI4Krvr3BUgvLixeF CLcOGRZVAv0MgNOAtB9Tao/qeldUSEXpxMfwynadS+k42VlYMGEzPTomhTdDQdAKRPS2oOZfTxj W3QDJkAHH2mtl3co= X-Google-Smtp-Source: AGHT+IGDCW1Y9/eUb8S4U4OvoU9etgJSKaMs7Gv6VcGUGv1HtKt6Z3onz9JKypAme+vZgABPIoURIA== X-Received: by 2002:a5d:5e81:0:b0:3a4:ed2f:e80c with SMTP id ffacd0b85a97d-3a6ed644c28mr2523360f8f.31.1750859550726; Wed, 25 Jun 2025 06:52:30 -0700 (PDT) Received: from max.int.rpsys.net ([2001:8b0:aba:5f3c:f1c1:2228:ff4c:9514]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3a6e810b140sm4657419f8f.80.2025.06.25.06.52.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Jun 2025 06:52:29 -0700 (PDT) From: Richard Purdie To: openembedded-core@lists.openembedded.org Subject: [PATCH 2/2] oeqa/sstatetests: Improve/fix sstate creation tests Date: Wed, 25 Jun 2025 14:52:27 +0100 Message-ID: <20250625135227.3106042-2-richard.purdie@linuxfoundation.org> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250625135227.3106042-1-richard.purdie@linuxfoundation.org> References: <20250625135227.3106042-1-richard.purdie@linuxfoundation.org> MIME-Version: 1.0 List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Wed, 25 Jun 2025 13:52:40 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/219321 There are multiple problems with the sstate creation tests. They currently both execute twice, once to check one set of files, then another. We can do this together in one test which makes the code easier to follow. The common test function also has parameters which were always the same value, so those can be simplified. We can use the umask context manager from bb.utils to simplfy the umask code. The badperms test was actually broken, it was detecting bad permissions, then ignoring them. This patch fixes that regression too and allows the check to operate (relying on a separate fix to sstate umask handling). The result should be an easier to understand couple of test cases which should also function correctly and be more reliable. Signed-off-by: Richard Purdie --- meta/lib/oeqa/selftest/cases/sstatetests.py | 78 ++++++++------------- 1 file changed, 30 insertions(+), 48 deletions(-) diff --git a/meta/lib/oeqa/selftest/cases/sstatetests.py b/meta/lib/oeqa/selftest/cases/sstatetests.py index 7231115a6b9..b22e498320b 100644 --- a/meta/lib/oeqa/selftest/cases/sstatetests.py +++ b/meta/lib/oeqa/selftest/cases/sstatetests.py @@ -83,55 +83,43 @@ class SStateBase(OESelftestTestCase): return result # Test sstate files creation and their location and directory perms - def run_test_sstate_creation(self, targets, distro_specific=True, distro_nonspecific=True, temp_sstate_location=True, should_pass=True): - self.config_sstate(temp_sstate_location, [self.sstate_path]) + def run_test_sstate_creation(self, targets, hostdistro_specific): + self.config_sstate(True, [self.sstate_path]) + + bitbake(['-cclean'] + targets) - if self.temp_sstate_location: - bitbake(['-cclean'] + targets) - else: - bitbake(['-ccleansstate'] + targets) - - # We need to test that the env umask have does not effect sstate directory creation - # So, first, we'll get the current umask and set it to something we know incorrect - # See: sstate_task_postfunc for correct umask of os.umask(0o002) - import os - def current_umask(): - current_umask = os.umask(0) - os.umask(current_umask) - return current_umask - - orig_umask = current_umask() # Set it to a umask we know will be 'wrong' - os.umask(0o022) + with bb.utils.umask(0o022): + bitbake(targets) - bitbake(targets) - file_tracker = [] - results = self.search_sstate('|'.join(map(str, targets)), distro_specific, distro_nonspecific) - if distro_nonspecific: - for r in results: - if r.endswith(("_populate_lic.tar.zst", "_populate_lic.tar.zst.siginfo", "_fetch.tar.zst.siginfo", "_unpack.tar.zst.siginfo", "_patch.tar.zst.siginfo")): - continue - file_tracker.append(r) - else: - file_tracker = results + # Distro specific files + distro_specific_files = self.search_sstate('|'.join(map(str, targets)), True, False) - if should_pass: - self.assertTrue(file_tracker , msg="Could not find sstate files for: %s" % ', '.join(map(str, targets))) + # Distro non-specific + distro_non_specific_files = [] + results = self.search_sstate('|'.join(map(str, targets)), False, True) + for r in results: + if r.endswith(("_populate_lic.tar.zst", "_populate_lic.tar.zst.siginfo", "_fetch.tar.zst.siginfo", "_unpack.tar.zst.siginfo", "_patch.tar.zst.siginfo")): + continue + distro_non_specific_files.append(r) + + if hostdistro_specific: + self.assertTrue(distro_specific_files , msg="Could not find sstate files for: %s" % ', '.join(map(str, targets))) + self.assertFalse(distro_non_specific_files, msg="Found sstate files in the wrong place for: %s (found %s)" % (', '.join(map(str, targets)), str(distro_non_specific_files))) else: - self.assertTrue(not file_tracker , msg="Found sstate files in the wrong place for: %s (found %s)" % (', '.join(map(str, targets)), str(file_tracker))) + self.assertTrue(distro_non_specific_files , msg="Could not find sstate files for: %s" % ', '.join(map(str, targets))) + self.assertFalse(distro_specific_files, msg="Found sstate files in the wrong place for: %s (found %s)" % (', '.join(map(str, targets)), str(distro_specific_files))) # Now we'll walk the tree to check the mode and see if things are incorrect. badperms = [] for root, dirs, files in os.walk(self.sstate_path): for directory in dirs: - if (os.stat(os.path.join(root, directory)).st_mode & 0o777) != 0o775: - badperms.append(os.path.join(root, directory)) + mode = os.stat(os.path.join(root, directory)).st_mode & 0o777 + if mode != 0o775: + badperms.append("%s: %s vs %s" % (os.path.join(root, directory), mode, o0775)) - # Return to original umask - os.umask(orig_umask) - - if should_pass: - self.assertTrue(badperms , msg="Found sstate directories with the wrong permissions: %s (found %s)" % (', '.join(map(str, targets)), str(badperms))) + # Check badperms is empty + self.assertFalse(badperms , msg="Found sstate directories with the wrong permissions: %s (found %s)" % (', '.join(map(str, targets)), str(badperms))) # Test the sstate files deletion part of the do_cleansstate task def run_test_cleansstate_task(self, targets, distro_specific=True, distro_nonspecific=True, temp_sstate_location=True): @@ -256,17 +244,11 @@ class SStateTests(SStateBase): bitbake("dbus-wait-test -c unpack") class SStateCreation(SStateBase): - def test_sstate_creation_distro_specific_pass(self): - self.run_test_sstate_creation(['binutils-cross-'+ self.tune_arch, 'binutils-native'], distro_specific=True, distro_nonspecific=False, temp_sstate_location=True) - - def test_sstate_creation_distro_specific_fail(self): - self.run_test_sstate_creation(['binutils-cross-'+ self.tune_arch, 'binutils-native'], distro_specific=False, distro_nonspecific=True, temp_sstate_location=True, should_pass=False) - - def test_sstate_creation_distro_nonspecific_pass(self): - self.run_test_sstate_creation(['linux-libc-headers'], distro_specific=False, distro_nonspecific=True, temp_sstate_location=True) + def test_sstate_creation_distro_specific(self): + self.run_test_sstate_creation(['binutils-cross-'+ self.tune_arch, 'binutils-native'], hostdistro_specific=True) - def test_sstate_creation_distro_nonspecific_fail(self): - self.run_test_sstate_creation(['linux-libc-headers'], distro_specific=True, distro_nonspecific=False, temp_sstate_location=True, should_pass=False) + def test_sstate_creation_distro_nonspecific(self): + self.run_test_sstate_creation(['linux-libc-headers'], hostdistro_specific=False) class SStateCleanup(SStateBase): def test_cleansstate_task_distro_specific_nonspecific(self):