From patchwork Sun Mar 12 14:02:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Purdie X-Patchwork-Id: 20836 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 5A313C6FD19 for ; Sun, 12 Mar 2023 14:02:53 +0000 (UTC) Received: from mail-wm1-f45.google.com (mail-wm1-f45.google.com [209.85.128.45]) by mx.groups.io with SMTP id smtpd.web10.66966.1678629767983338972 for ; Sun, 12 Mar 2023 07:02:48 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@linuxfoundation.org header.s=google header.b=RyuhlW/l; spf=pass (domain: linuxfoundation.org, ip: 209.85.128.45, mailfrom: richard.purdie@linuxfoundation.org) Received: by mail-wm1-f45.google.com with SMTP id x22so815177wmj.3 for ; Sun, 12 Mar 2023 07:02:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=google; t=1678629766; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:from:to:cc:subject:date:message-id:reply-to; bh=/2Bg2hj+Ft0G4/5uH0yUj+xyMAKYXFTfiEYnhPPdkTQ=; b=RyuhlW/lXHXN9xnK+K5z/dqkHCm731HMwJWOgAwG+rwa+5JDD+yfzNdyPewv1hvphE eyFu8gQcnX68zmN0tXrrJO3NaueEhzlbKYtFzC8y/rEFabVOqocM86JWYbu7ZUWDzeDr QPMKimakgreuqsjnSh+DYLagUgCBOL4wZ9/1w= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678629766; 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=/2Bg2hj+Ft0G4/5uH0yUj+xyMAKYXFTfiEYnhPPdkTQ=; b=OtcHfVJB+Okfzzd2vZwl1+/b4Btna2HpjTfC3B1SY45r7VfM+u6OrFQkMqxbBQ3Ya4 3zlUZ3jtOn0yhbgYQi/fq1hhqsuK26SA8GI5ZQkiozNOpiTS8Oo5Mz8ZVKYLgAIj519E UyHpdT34W8aNZS0r4uTFUbCQKyuxLZLV9V690M8e8WGGu/KHQGUKjaK67lMARPYfPc45 UrNJqVR3ngtgOzaVlSyd2zahqyS+mRRtKOW0oseVvdFvxU3oZpoGq9iVDnyj4gcQ9bVr eiNYcnNFof33ed2qi5O+EsxktwvyH/uGvJjiPyukWYnylIEBPEvphr5zFImBUbMDUXZA MOWg== X-Gm-Message-State: AO0yUKXb89fBvqYe1Gy/Ihqgbrqlo+2JDv1N5KQX/2E1K2HS3J9U05Sz 1jkRZI323zFoG49CBgT5DKg0deZIDQelFI91NCE= X-Google-Smtp-Source: AK7set9T5shUVl+PgFhIBTIgmW3P2QLEPU5dB6U+Uqfb2Vvknwq3RCZOxX692Fb94mPdi6PLlc8znw== X-Received: by 2002:a05:600c:4e8e:b0:3e0:1a9:b1d7 with SMTP id f14-20020a05600c4e8e00b003e001a9b1d7mr8451785wmq.19.1678629766039; Sun, 12 Mar 2023 07:02:46 -0700 (PDT) Received: from max.int.rpsys.net ([2001:8b0:aba:5f3c:ee:6264:1be3:a6af]) by smtp.gmail.com with ESMTPSA id t21-20020a7bc3d5000000b003ed2384566fsm1312089wmj.21.2023.03.12.07.02.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 Mar 2023 07:02:45 -0700 (PDT) From: Richard Purdie To: openembedded-core@lists.openembedded.org Subject: [PATCH 1/3] oeqa/selftest/sstate: Merge sstate test class with tests themselves Date: Sun, 12 Mar 2023 14:02:42 +0000 Message-Id: <20230312140244.3565436-1-richard.purdie@linuxfoundation.org> X-Mailer: git-send-email 2.38.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 ; Sun, 12 Mar 2023 14:02:53 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/178388 Having this base class as a separate file is just confusing. Merge with the rest of the test code. Signed-off-by: Richard Purdie --- .../selftest/cases/_sstatetests_noauto.py | 2 +- meta/lib/oeqa/selftest/cases/sstate.py | 66 ------------------- meta/lib/oeqa/selftest/cases/sstatetests.py | 62 ++++++++++++++++- 3 files changed, 60 insertions(+), 70 deletions(-) delete mode 100644 meta/lib/oeqa/selftest/cases/sstate.py diff --git a/meta/lib/oeqa/selftest/cases/_sstatetests_noauto.py b/meta/lib/oeqa/selftest/cases/_sstatetests_noauto.py index 5f1c8df2d49..2c9584d3291 100644 --- a/meta/lib/oeqa/selftest/cases/_sstatetests_noauto.py +++ b/meta/lib/oeqa/selftest/cases/_sstatetests_noauto.py @@ -9,7 +9,7 @@ import shutil import oeqa.utils.ftools as ftools from oeqa.utils.commands import runCmd, bitbake, get_bb_var -from oeqa.selftest.cases.sstate import SStateBase +from oeqa.selftest.cases.sstatetests import SStateBase class RebuildFromSState(SStateBase): diff --git a/meta/lib/oeqa/selftest/cases/sstate.py b/meta/lib/oeqa/selftest/cases/sstate.py deleted file mode 100644 index e73bb948841..00000000000 --- a/meta/lib/oeqa/selftest/cases/sstate.py +++ /dev/null @@ -1,66 +0,0 @@ -# -# Copyright OpenEmbedded Contributors -# -# SPDX-License-Identifier: MIT -# - -import datetime -import os -import re - -from oeqa.selftest.case import OESelftestTestCase -from oeqa.utils.commands import get_bb_vars - - -class SStateBase(OESelftestTestCase): - - def setUpLocal(self): - super(SStateBase, self).setUpLocal() - self.temp_sstate_location = None - needed_vars = ['SSTATE_DIR', 'NATIVELSBSTRING', '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) - - # Creates a special sstate configuration with the option to add sstate mirrors - def config_sstate(self, temp_sstate_location=False, add_local_mirrors=[]): - self.temp_sstate_location = temp_sstate_location - - if self.temp_sstate_location: - temp_sstate_path = os.path.join(self.builddir, "temp_sstate_%s" % datetime.datetime.now().strftime('%Y%m%d%H%M%S')) - 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) - - if add_local_mirrors: - config_set_sstate_if_not_set = 'SSTATE_MIRRORS ?= ""' - self.append_config(config_set_sstate_if_not_set) - for local_mirror in add_local_mirrors: - self.assertFalse(os.path.join(local_mirror) == os.path.join(self.sstate_path), msg='Cannot add the current sstate path as a sstate mirror') - config_sstate_mirror = "SSTATE_MIRRORS += \"file://.* file:///%s/PATH\"" % local_mirror - self.append_config(config_sstate_mirror) - - # Returns a list containing sstate files - def search_sstate(self, filename_regex, distro_specific=True, distro_nonspecific=True): - 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): - for f in files: - if re.search(filename_regex, f): - result.append(f) - if distro_nonspecific and re.search(r"%s/[a-z0-9]{2}/[a-z0-9]{2}$" % self.sstate_path, root): - for f in files: - if re.search(filename_regex, f): - result.append(f) - return result diff --git a/meta/lib/oeqa/selftest/cases/sstatetests.py b/meta/lib/oeqa/selftest/cases/sstatetests.py index ae766f91bd8..a6a688cc19d 100644 --- a/meta/lib/oeqa/selftest/cases/sstatetests.py +++ b/meta/lib/oeqa/selftest/cases/sstatetests.py @@ -9,13 +9,69 @@ import shutil import glob import subprocess import tempfile +import datetime +import re -from oeqa.utils.commands import runCmd, bitbake, get_bb_var, create_temp_layer -from oeqa.selftest.cases.sstate import SStateBase -import oe +from oeqa.utils.commands import runCmd, bitbake, get_bb_var, create_temp_layer, get_bb_vars +from oeqa.selftest.case import OESelftestTestCase +import oe import bb.siggen +class SStateBase(OESelftestTestCase): + + def setUpLocal(self): + super(SStateBase, self).setUpLocal() + self.temp_sstate_location = None + needed_vars = ['SSTATE_DIR', 'NATIVELSBSTRING', '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) + + # Creates a special sstate configuration with the option to add sstate mirrors + def config_sstate(self, temp_sstate_location=False, add_local_mirrors=[]): + self.temp_sstate_location = temp_sstate_location + + if self.temp_sstate_location: + temp_sstate_path = os.path.join(self.builddir, "temp_sstate_%s" % datetime.datetime.now().strftime('%Y%m%d%H%M%S')) + 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) + + if add_local_mirrors: + config_set_sstate_if_not_set = 'SSTATE_MIRRORS ?= ""' + self.append_config(config_set_sstate_if_not_set) + for local_mirror in add_local_mirrors: + self.assertFalse(os.path.join(local_mirror) == os.path.join(self.sstate_path), msg='Cannot add the current sstate path as a sstate mirror') + config_sstate_mirror = "SSTATE_MIRRORS += \"file://.* file:///%s/PATH\"" % local_mirror + self.append_config(config_sstate_mirror) + + # Returns a list containing sstate files + def search_sstate(self, filename_regex, distro_specific=True, distro_nonspecific=True): + 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): + for f in files: + if re.search(filename_regex, f): + result.append(f) + if distro_nonspecific and re.search(r"%s/[a-z0-9]{2}/[a-z0-9]{2}$" % self.sstate_path, root): + for f in files: + if re.search(filename_regex, f): + result.append(f) + return result + + class SStateTests(SStateBase): def test_autorev_sstate_works(self): # Test that a git repository which changes is correctly handled by SRCREV = ${AUTOREV} From patchwork Sun Mar 12 14:02:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Purdie X-Patchwork-Id: 20837 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 70C8DC6FA99 for ; Sun, 12 Mar 2023 14:02:53 +0000 (UTC) Received: from mail-wm1-f50.google.com (mail-wm1-f50.google.com [209.85.128.50]) by mx.groups.io with SMTP id smtpd.web10.66968.1678629768606126945 for ; Sun, 12 Mar 2023 07:02:48 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@linuxfoundation.org header.s=google header.b=Vcn2Asv+; spf=pass (domain: linuxfoundation.org, ip: 209.85.128.50, mailfrom: richard.purdie@linuxfoundation.org) Received: by mail-wm1-f50.google.com with SMTP id j19-20020a05600c191300b003eb3e1eb0caso9201590wmq.1 for ; Sun, 12 Mar 2023 07:02:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=google; t=1678629767; 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=j90C4DpAIMyXit1hq2VseGhGXfY2cm2lYqnXra6DtV4=; b=Vcn2Asv+ek6+FCQO19rahDC+kHy6BlEfjWqvUV4owI+il7dELeD0zDE7SEGCZTwmhG 1BSdpZSMPzLy3vlCGZ+UO++ArbywyOjs/d+KEqeNnh9BOlPxiLUnRXdCa0shep18rgmA R0HhXp581lndXUt3EoZd+I46lFhfeoH+tfwFo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678629767; 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=j90C4DpAIMyXit1hq2VseGhGXfY2cm2lYqnXra6DtV4=; b=ZwX/x58B65cb11iYg7mkd48sBj2HBwQLSGNrVGwUEChIdwUJjcHahGv350MugOfwcB lwNU283k/o+08FT1Kl6fz4v6HOFj6qj54y+YZlmzf1HnS6sNb3fsodgJ8Drsdb+IMUAa gtPiOWuiHeSkXW55Pl6i8zD7z2WlkoyrcEX/kf18UiJ5tkSS1hYWtds5sCHoJDfA4v+p vOJIla41xoS/PBdobBVeZ/NjgMZwkz4OXhbFro/6KLz+S933/9xbIN6zq0D3VIZSnmLU QnPOkYWZlsNZpykOtPZII0tWoujFUlTt9mO0smuSIidjmUUcXjp6xnC3kZb3pXOB2HyY TT5g== X-Gm-Message-State: AO0yUKXC40KTFhjUDecu8QUw1sLb4b5GeHeHy6xp/wsOqCzUAOrTmvYc ++qrWlkO7EGACa19Sf3SyQ+XjvhFYtL/qg6iHZ8= X-Google-Smtp-Source: AK7set83FpdbwTLMgYqVaprtuL50r73kUkl73INlvPX+D7gXKZpviy0MDvrCbE1edGyKWpZR1+eOag== X-Received: by 2002:a05:600c:19d1:b0:3e2:dba:7155 with SMTP id u17-20020a05600c19d100b003e20dba7155mr7943723wmq.20.1678629766711; Sun, 12 Mar 2023 07:02:46 -0700 (PDT) Received: from max.int.rpsys.net ([2001:8b0:aba:5f3c:ee:6264:1be3:a6af]) by smtp.gmail.com with ESMTPSA id t21-20020a7bc3d5000000b003ed2384566fsm1312089wmj.21.2023.03.12.07.02.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 Mar 2023 07:02:46 -0700 (PDT) From: Richard Purdie To: openembedded-core@lists.openembedded.org Subject: [PATCH 2/3] oeqa/selftest/sstate: Move common code to base class Date: Sun, 12 Mar 2023 14:02:43 +0000 Message-Id: <20230312140244.3565436-2-richard.purdie@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230312140244.3565436-1-richard.purdie@linuxfoundation.org> References: <20230312140244.3565436-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 ; Sun, 12 Mar 2023 14:02:53 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/178389 Move the other common shares test functions to the base class to improve the code structure. Signed-off-by: Richard Purdie --- meta/lib/oeqa/selftest/cases/sstatetests.py | 197 ++++++++++---------- 1 file changed, 98 insertions(+), 99 deletions(-) diff --git a/meta/lib/oeqa/selftest/cases/sstatetests.py b/meta/lib/oeqa/selftest/cases/sstatetests.py index a6a688cc19d..aedc35c2626 100644 --- a/meta/lib/oeqa/selftest/cases/sstatetests.py +++ b/meta/lib/oeqa/selftest/cases/sstatetests.py @@ -71,47 +71,6 @@ class SStateBase(OESelftestTestCase): result.append(f) return result - -class SStateTests(SStateBase): - def test_autorev_sstate_works(self): - # Test that a git repository which changes is correctly handled by SRCREV = ${AUTOREV} - # when PV does not contain SRCPV - - tempdir = tempfile.mkdtemp(prefix='sstate_autorev') - tempdldir = tempfile.mkdtemp(prefix='sstate_autorev_dldir') - self.track_for_cleanup(tempdir) - self.track_for_cleanup(tempdldir) - create_temp_layer(tempdir, 'selftestrecipetool') - self.add_command_to_tearDown('bitbake-layers remove-layer %s' % tempdir) - self.append_config("DL_DIR = \"%s\"" % tempdldir) - runCmd('bitbake-layers add-layer %s' % tempdir) - - # Use dbus-wait as a local git repo we can add a commit between two builds in - pn = 'dbus-wait' - srcrev = '6cc6077a36fe2648a5f993fe7c16c9632f946517' - url = 'git://git.yoctoproject.org/dbus-wait' - result = runCmd('git clone %s noname' % url, cwd=tempdir) - srcdir = os.path.join(tempdir, 'noname') - result = runCmd('git reset --hard %s' % srcrev, cwd=srcdir) - self.assertTrue(os.path.isfile(os.path.join(srcdir, 'configure.ac')), 'Unable to find configure script in source directory') - - recipefile = os.path.join(tempdir, "recipes-test", "dbus-wait-test", 'dbus-wait-test_git.bb') - os.makedirs(os.path.dirname(recipefile)) - srcuri = 'git://' + srcdir + ';protocol=file;branch=master' - result = runCmd(['recipetool', 'create', '-o', recipefile, srcuri]) - self.assertTrue(os.path.isfile(recipefile), 'recipetool did not create recipe file; output:\n%s' % result.output) - - with open(recipefile, 'a') as f: - f.write('SRCREV = "${AUTOREV}"\n') - f.write('PV = "1.0"\n') - - bitbake("dbus-wait-test -c fetch") - with open(os.path.join(srcdir, "bar.txt"), "w") as f: - f.write("foo") - result = runCmd('git add bar.txt; git commit -asm "add bar"', cwd=srcdir) - bitbake("dbus-wait-test -c unpack") - - # Test sstate files creation and their location 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]) @@ -137,18 +96,6 @@ class SStateTests(SStateBase): 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))) - 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_nonspecific_fail(self): - self.run_test_sstate_creation(['linux-libc-headers'], distro_specific=True, distro_nonspecific=False, temp_sstate_location=True, should_pass=False) - # 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): self.config_sstate(temp_sstate_location, [self.sstate_path]) @@ -166,20 +113,6 @@ class SStateTests(SStateBase): archives_removed = self.search_sstate('|'.join(map(str, [s + r'.*?\.tar.zst$' for s in targets])), distro_specific, distro_nonspecific) self.assertTrue(not archives_removed, msg="do_cleansstate didn't remove .tar.zst sstate files for: %s (%s)" % (', '.join(map(str, targets)), str(archives_removed))) - def test_cleansstate_task_distro_specific_nonspecific(self): - targets = ['binutils-cross-'+ self.tune_arch, 'binutils-native'] - targets.append('linux-libc-headers') - self.run_test_cleansstate_task(targets, distro_specific=True, distro_nonspecific=True, temp_sstate_location=True) - - def test_cleansstate_task_distro_nonspecific(self): - self.run_test_cleansstate_task(['linux-libc-headers'], distro_specific=False, distro_nonspecific=True, temp_sstate_location=True) - - def test_cleansstate_task_distro_specific(self): - targets = ['binutils-cross-'+ self.tune_arch, 'binutils-native'] - targets.append('linux-libc-headers') - self.run_test_cleansstate_task(targets, distro_specific=True, distro_nonspecific=False, temp_sstate_location=True) - - # Test rebuilding of distro-specific sstate files def run_test_rebuild_distro_specific_sstate(self, targets, temp_sstate_location=True): self.config_sstate(temp_sstate_location, [self.sstate_path]) @@ -212,6 +145,104 @@ class SStateTests(SStateBase): created_once = [x for x in file_tracker_2 if x not in file_tracker_1] self.assertTrue(created_once == [], msg="The following sstate files were created only in the second run: %s" % ', '.join(map(str, created_once))) + def sstate_common_samesigs(self, configA, configB, allarch=False): + + self.write_config(configA) + self.track_for_cleanup(self.topdir + "/tmp-sstatesamehash") + bitbake("world meta-toolchain -S none") + self.write_config(configB) + self.track_for_cleanup(self.topdir + "/tmp-sstatesamehash2") + bitbake("world meta-toolchain -S none") + + def get_files(d, result): + for root, dirs, files in os.walk(d): + for name in files: + if "meta-environment" in root or "cross-canadian" in root: + continue + if "do_build" not in name: + # 1.4.1+gitAUTOINC+302fca9f4c-r0.do_package_write_ipk.sigdata.f3a2a38697da743f0dbed8b56aafcf79 + (_, task, _, shash) = name.rsplit(".", 3) + result[os.path.join(os.path.basename(root), task)] = shash + + files1 = {} + files2 = {} + subdirs = sorted(glob.glob(self.topdir + "/tmp-sstatesamehash/stamps/*-nativesdk*-linux")) + if allarch: + subdirs.extend(sorted(glob.glob(self.topdir + "/tmp-sstatesamehash/stamps/all-*-linux"))) + + for subdir in subdirs: + nativesdkdir = os.path.basename(subdir) + get_files(self.topdir + "/tmp-sstatesamehash/stamps/" + nativesdkdir, files1) + get_files(self.topdir + "/tmp-sstatesamehash2/stamps/" + nativesdkdir, files2) + + self.maxDiff = None + self.assertEqual(files1, files2) + +class SStateTests(SStateBase): + def test_autorev_sstate_works(self): + # Test that a git repository which changes is correctly handled by SRCREV = ${AUTOREV} + # when PV does not contain SRCPV + + tempdir = tempfile.mkdtemp(prefix='sstate_autorev') + tempdldir = tempfile.mkdtemp(prefix='sstate_autorev_dldir') + self.track_for_cleanup(tempdir) + self.track_for_cleanup(tempdldir) + create_temp_layer(tempdir, 'selftestrecipetool') + self.add_command_to_tearDown('bitbake-layers remove-layer %s' % tempdir) + self.append_config("DL_DIR = \"%s\"" % tempdldir) + runCmd('bitbake-layers add-layer %s' % tempdir) + + # Use dbus-wait as a local git repo we can add a commit between two builds in + pn = 'dbus-wait' + srcrev = '6cc6077a36fe2648a5f993fe7c16c9632f946517' + url = 'git://git.yoctoproject.org/dbus-wait' + result = runCmd('git clone %s noname' % url, cwd=tempdir) + srcdir = os.path.join(tempdir, 'noname') + result = runCmd('git reset --hard %s' % srcrev, cwd=srcdir) + self.assertTrue(os.path.isfile(os.path.join(srcdir, 'configure.ac')), 'Unable to find configure script in source directory') + + recipefile = os.path.join(tempdir, "recipes-test", "dbus-wait-test", 'dbus-wait-test_git.bb') + os.makedirs(os.path.dirname(recipefile)) + srcuri = 'git://' + srcdir + ';protocol=file;branch=master' + result = runCmd(['recipetool', 'create', '-o', recipefile, srcuri]) + self.assertTrue(os.path.isfile(recipefile), 'recipetool did not create recipe file; output:\n%s' % result.output) + + with open(recipefile, 'a') as f: + f.write('SRCREV = "${AUTOREV}"\n') + f.write('PV = "1.0"\n') + + bitbake("dbus-wait-test -c fetch") + with open(os.path.join(srcdir, "bar.txt"), "w") as f: + f.write("foo") + result = runCmd('git add bar.txt; git commit -asm "add bar"', cwd=srcdir) + bitbake("dbus-wait-test -c unpack") + + 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_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_cleansstate_task_distro_specific_nonspecific(self): + targets = ['binutils-cross-'+ self.tune_arch, 'binutils-native'] + targets.append('linux-libc-headers') + self.run_test_cleansstate_task(targets, distro_specific=True, distro_nonspecific=True, temp_sstate_location=True) + + def test_cleansstate_task_distro_nonspecific(self): + self.run_test_cleansstate_task(['linux-libc-headers'], distro_specific=False, distro_nonspecific=True, temp_sstate_location=True) + + def test_cleansstate_task_distro_specific(self): + targets = ['binutils-cross-'+ self.tune_arch, 'binutils-native'] + targets.append('linux-libc-headers') + self.run_test_cleansstate_task(targets, distro_specific=True, distro_nonspecific=False, temp_sstate_location=True) + + def test_rebuild_distro_specific_sstate_cross_native_targets(self): self.run_test_rebuild_distro_specific_sstate(['binutils-cross-' + self.tune_arch, 'binutils-native'], temp_sstate_location=True) @@ -433,38 +464,6 @@ BB_SIGNATURE_HANDLER = "OEBasicHash" """ self.sstate_common_samesigs(configA, configB) - def sstate_common_samesigs(self, configA, configB, allarch=False): - - self.write_config(configA) - self.track_for_cleanup(self.topdir + "/tmp-sstatesamehash") - bitbake("world meta-toolchain -S none") - self.write_config(configB) - self.track_for_cleanup(self.topdir + "/tmp-sstatesamehash2") - bitbake("world meta-toolchain -S none") - - def get_files(d, result): - for root, dirs, files in os.walk(d): - for name in files: - if "meta-environment" in root or "cross-canadian" in root: - continue - if "do_build" not in name: - # 1.4.1+gitAUTOINC+302fca9f4c-r0.do_package_write_ipk.sigdata.f3a2a38697da743f0dbed8b56aafcf79 - (_, task, _, shash) = name.rsplit(".", 3) - result[os.path.join(os.path.basename(root), task)] = shash - - files1 = {} - files2 = {} - subdirs = sorted(glob.glob(self.topdir + "/tmp-sstatesamehash/stamps/*-nativesdk*-linux")) - if allarch: - subdirs.extend(sorted(glob.glob(self.topdir + "/tmp-sstatesamehash/stamps/all-*-linux"))) - - for subdir in subdirs: - nativesdkdir = os.path.basename(subdir) - get_files(self.topdir + "/tmp-sstatesamehash/stamps/" + nativesdkdir, files1) - get_files(self.topdir + "/tmp-sstatesamehash2/stamps/" + nativesdkdir, files2) - - self.maxDiff = None - self.assertEqual(files1, files2) def test_sstate_sametune_samesigs(self): """ From patchwork Sun Mar 12 14:02:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Purdie X-Patchwork-Id: 20835 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 5B510C6FD1F for ; Sun, 12 Mar 2023 14:02:53 +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.web11.66804.1678629768994691000 for ; Sun, 12 Mar 2023 07:02:49 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@linuxfoundation.org header.s=google header.b=h6v8t2nP; spf=pass (domain: linuxfoundation.org, ip: 209.85.128.48, mailfrom: richard.purdie@linuxfoundation.org) Received: by mail-wm1-f48.google.com with SMTP id o5-20020a05600c510500b003ec0e4ec6deso3120273wms.3 for ; Sun, 12 Mar 2023 07:02:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=google; t=1678629767; 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=3fdkJL2hQeuCq2BPaEHpSYuX6jViQ3zqYLLriaFSD/Y=; b=h6v8t2nPSAhL8hQHkWffAqCHwQBZuUOmZAERr9usT0M6wpwJqHjQLZ9Aol/hod4hFE dE+hPLXSY7yeJoYnejHbtyMamg5EmaFy6wr639Yky2JoJY4abGc32VoAiPA2wu8bYioy uLc/NjnGeJvVAVMcA776AIaf+UZ1/eVa2wVsM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678629767; 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=3fdkJL2hQeuCq2BPaEHpSYuX6jViQ3zqYLLriaFSD/Y=; b=Y/RN32UZW3EVkUNt7itaFtdQccbMlQKhJuMylk2n208RLdSL4PA7EPuMO7sBCdxX8j KE70PosFq73nrTbdH/aNjRTO01UZgtFKluSqnWFGNrbUCsbXMMFzq7jf1/MGLO8TJkXd /5vcatHD+2hC20ydqxWYjJptt6M4GWQpEVDljw1puoLby/mEsmHi+SG1qKWZJbWxBO16 SfES2R61b8XgjcGIMJrxE6/1zC/Qlf4Zn8nI/vbdQS50rnw9x41suj+G0WaX+3xR/B5E mfLsO+bIi1H8wanCNPeKwb/xvTfEKSXOtMdpz/4yMn/xPf894sjR2bTFWtCsESpw9U1w q/Ww== X-Gm-Message-State: AO0yUKWFTK1uUAyaJ9akaY+MeYrGAS70eDieQJRtI0zcLW8rZ4JHxSu/ Cbf/YyF3yglPdepVFcxq4hhifAzHj6FG6RcLxn0= X-Google-Smtp-Source: AK7set92kkD/1ykUgDRt+kyPm8J7PPo3ED4jwKSILU2w1dsGn4xHcMn+DI5zZqRr7DQe/p2STLjtBA== X-Received: by 2002:a05:600c:458e:b0:3eb:37ce:4c3d with SMTP id r14-20020a05600c458e00b003eb37ce4c3dmr7848938wmo.38.1678629767356; Sun, 12 Mar 2023 07:02:47 -0700 (PDT) Received: from max.int.rpsys.net ([2001:8b0:aba:5f3c:ee:6264:1be3:a6af]) by smtp.gmail.com with ESMTPSA id t21-20020a7bc3d5000000b003ed2384566fsm1312089wmj.21.2023.03.12.07.02.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 Mar 2023 07:02:47 -0700 (PDT) From: Richard Purdie To: openembedded-core@lists.openembedded.org Subject: [PATCH 3/3] oeqa/selftest/sstate: Split classes to allow more parallelism Date: Sun, 12 Mar 2023 14:02:44 +0000 Message-Id: <20230312140244.3565436-3-richard.purdie@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230312140244.3565436-1-richard.purdie@linuxfoundation.org> References: <20230312140244.3565436-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 ; Sun, 12 Mar 2023 14:02:53 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/178390 By splitting the single class into multiple classes, it allows more parallelism in the execution. These tests don't have interdependencies that benefit from sstate reuse or anything like that so this makes sense to improve overall test execution time if/where possible. Signed-off-by: Richard Purdie --- meta/lib/oeqa/selftest/cases/sstatetests.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/meta/lib/oeqa/selftest/cases/sstatetests.py b/meta/lib/oeqa/selftest/cases/sstatetests.py index aedc35c2626..e978313c61f 100644 --- a/meta/lib/oeqa/selftest/cases/sstatetests.py +++ b/meta/lib/oeqa/selftest/cases/sstatetests.py @@ -217,6 +217,7 @@ class SStateTests(SStateBase): result = runCmd('git add bar.txt; git commit -asm "add bar"', cwd=srcdir) 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) @@ -229,6 +230,7 @@ class SStateTests(SStateBase): 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) +class SStateCleanup(SStateBase): def test_cleansstate_task_distro_specific_nonspecific(self): targets = ['binutils-cross-'+ self.tune_arch, 'binutils-native'] targets.append('linux-libc-headers') @@ -242,7 +244,7 @@ class SStateTests(SStateBase): targets.append('linux-libc-headers') self.run_test_cleansstate_task(targets, distro_specific=True, distro_nonspecific=False, temp_sstate_location=True) - +class SStateDistroTests(SStateBase): def test_rebuild_distro_specific_sstate_cross_native_targets(self): self.run_test_rebuild_distro_specific_sstate(['binutils-cross-' + self.tune_arch, 'binutils-native'], temp_sstate_location=True) @@ -252,7 +254,7 @@ class SStateTests(SStateBase): def test_rebuild_distro_specific_sstate_native_target(self): self.run_test_rebuild_distro_specific_sstate(['binutils-native'], temp_sstate_location=True) - +class SStateCacheManagement(SStateBase): # Test the sstate-cache-management script. Each element in the global_config list is used with the corresponding element in the target_config list # global_config elements are expected to not generate any sstate files that would be removed by sstate-cache-management.sh (such as changing the value of MACHINE) def run_test_sstate_cache_management_script(self, target, global_config=[''], target_config=[''], ignore_patterns=[]): @@ -331,6 +333,7 @@ class SStateTests(SStateBase): target_config.append('') self.run_test_sstate_cache_management_script('m4', global_config, target_config, ignore_patterns=['populate_lic']) +class SStateHashSameSigs(SStateBase): def test_sstate_32_64_same_hash(self): """ The sstate checksums for both native and target should not vary whether @@ -416,6 +419,7 @@ BB_SIGNATURE_HANDLER = "OEBasicHash" self.maxDiff = None self.assertCountEqual(files1, files2) +class SStateHashSameSigs2(SStateBase): def test_sstate_allarch_samesigs(self): """ The sstate checksums of allarch packages should be independent of whichever @@ -464,7 +468,7 @@ BB_SIGNATURE_HANDLER = "OEBasicHash" """ self.sstate_common_samesigs(configA, configB) - +class SStateHashSameSigs3(SStateBase): def test_sstate_sametune_samesigs(self): """ The sstate checksums of two identical machines (using the same tune) should be the @@ -552,7 +556,7 @@ BB_SIGNATURE_HANDLER = "OEBasicHash" self.maxDiff = None self.assertCountEqual(files1, files2) - +class SStateHashSameSigs4(SStateBase): def test_sstate_noop_samesigs(self): """ The sstate checksums of two builds with these variables changed or