From mboxrd@z Thu Jan 1 00:00:00 1970 X-GM-THRID: 7016230395466219520 X-Received: by 2002:a17:907:160a:: with SMTP id hb10mr6489025ejc.83.1636613259905; Wed, 10 Nov 2021 22:47:39 -0800 (PST) X-BeenThere: isar-users@googlegroups.com Received: by 2002:aa7:c0d9:: with SMTP id j25ls2050878edp.3.gmail; Wed, 10 Nov 2021 22:47:38 -0800 (PST) X-Google-Smtp-Source: ABdhPJzJwmJpnfDAcQMov7nAy6a8j67AonFWMaAIxXz71CpoVtgepvDHol6ZXRQZlWnAs49Z+N66 X-Received: by 2002:a05:6402:28a1:: with SMTP id eg33mr7201419edb.161.1636613258896; Wed, 10 Nov 2021 22:47:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1636613258; cv=none; d=google.com; s=arc-20160816; b=MIvYJyKhNfJWtyfwfpUaBKzJvgSBqA3CyELIABuOg1/klgFDU+olNPM6osqGxWzZzS dFv/mGovlyqIuF+iw2gJdW5XZICQ7Hy9knerU41Z8mIkJUjbqcQENTqpfuW/+6y/1SYh aq6YPHgWn1nQl2HNZUOcneXpryzGMruhtCoRYtnUaymmUmW713V/imSaFlQxzEJiElCt dgo7F9qhCHkmHyJ9Jwi7aP2I5fIZ9cWDPwRZbvF0J7WsJoQXqObb8Dy6IHZSAyBfmhOQ SW71hRy8In7EQ+DEFCv/EaIth8HxC1yiMGDKeYwi+xBiGFudAKNGJY9SIrCrfBOlXWhz EFTQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=/1woNA7/5Yz+enqOvpZzec81M9Aex8owtgBBegxSQlo=; b=foCQOuobUMW2jJlcwhL2C+Pzfa4Rqji4wZH3pgcdw3iLX3mjN/xxhc9+DI0W4q70m8 3JV46m6CW7TDrtQzxYGu1kKIQfCA0DBXwGzSHp+Q/Lk+xZWR9KsVlT3uL5PHSgxt7mC7 lQ2oGlSarfMiRZMXNpKQq9F3TRFPbiUhlV8CZT9Ym+rFNCWvOcGCh5HdJ9WJGur2m3/J tCbTIJnlQyWZLlNKzQkdQHtPraNs9mEaoRyDgKn3fDL3BEAt4QxqFU03RIouj9ZZfUIT LL4B3ZbXqMU4k7VQiLJ4Z3CZC8/WP3xyFVt2th3E1wH7VBCyp4FeoED0O/HXV/Qp02AT mZGA== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: domain of adriaan.schmidt@siemens.com designates 192.35.17.2 as permitted sender) smtp.mailfrom=adriaan.schmidt@siemens.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=siemens.com Return-Path: Received: from thoth.sbs.de (thoth.sbs.de. [192.35.17.2]) by gmr-mx.google.com with ESMTPS id bi21si158133edb.0.2021.11.10.22.47.38 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 10 Nov 2021 22:47:38 -0800 (PST) Received-SPF: pass (google.com: domain of adriaan.schmidt@siemens.com designates 192.35.17.2 as permitted sender) client-ip=192.35.17.2; Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of adriaan.schmidt@siemens.com designates 192.35.17.2 as permitted sender) smtp.mailfrom=adriaan.schmidt@siemens.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=siemens.com Received: from mail2.sbs.de (mail2.sbs.de [192.129.41.66]) by thoth.sbs.de (8.15.2/8.15.2) with ESMTPS id 1AB6lcMF017681 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 11 Nov 2021 07:47:38 +0100 Received: from random.ppmd.siemens.net (random.ppmd.siemens.net [139.25.68.25]) by mail2.sbs.de (8.15.2/8.15.2) with ESMTP id 1AB6lbcg012388; Thu, 11 Nov 2021 07:47:38 +0100 From: Adriaan Schmidt To: isar-users@googlegroups.com Cc: Adriaan Schmidt Subject: [PATCH v6 13/13] sstate: add test case Date: Thu, 11 Nov 2021 07:47:28 +0100 Message-Id: <20211111064728.2375760-14-adriaan.schmidt@siemens.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211111064728.2375760-1-adriaan.schmidt@siemens.com> References: <20211111064728.2375760-1-adriaan.schmidt@siemens.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TUID: CqpmViqxWuYp This also adds a parameter `sstate` to the build function, which is only passed as `1` for the actual sstate test. None of the other tests uses sstate caching. Signed-off-by: Adriaan Schmidt --- testsuite/build_test/build_test.py | 101 ++++++++++++++++++++++++++--- testsuite/build_test/cibase.py | 14 ++-- 2 files changed, 101 insertions(+), 14 deletions(-) diff --git a/testsuite/build_test/build_test.py b/testsuite/build_test/build_test.py index d39c10c..817f4ce 100644 --- a/testsuite/build_test/build_test.py +++ b/testsuite/build_test/build_test.py @@ -1,9 +1,10 @@ #!/usr/bin/env python3 +import glob import os from avocado import skipUnless -from avocado.utils import path +from avocado.utils import path, process from cibase import CIBaseTest UMOCI_AVAILABLE = True @@ -58,7 +59,7 @@ class CrossTest(CIBaseTest): 'mc:rpi-stretch:isar-image-base' ] - self.perform_build_test(targets, 1, None) + self.perform_build_test(targets, 1, 0, None) def test_cross_ubuntu(self): targets = [ @@ -66,7 +67,7 @@ class CrossTest(CIBaseTest): ] try: - self.perform_build_test(targets, 1, None) + self.perform_build_test(targets, 1, 0, None) except: self.cancel('KFAIL') @@ -76,7 +77,7 @@ class CrossTest(CIBaseTest): ] try: - self.perform_build_test(targets, 1, None) + self.perform_build_test(targets, 1, 0, None) except: self.cancel('KFAIL') @@ -90,7 +91,7 @@ class SdkTest(CIBaseTest): def test_sdk(self): targets = ['mc:qemuarm-stretch:isar-image-base'] - self.perform_build_test(targets, 1, 'do_populate_sdk') + self.perform_build_test(targets, 1, 0, 'do_populate_sdk') class NoCrossTest(CIBaseTest): @@ -123,7 +124,7 @@ class NoCrossTest(CIBaseTest): self.deletetmp(self.params.get('build_dir', default=os.path.dirname(__file__) + '/../../build')) - self.perform_build_test(targets, 0, None) + self.perform_build_test(targets, 0, 0, None) def test_nocross_bullseye(self): targets = [ @@ -134,7 +135,7 @@ class NoCrossTest(CIBaseTest): ] try: - self.perform_build_test(targets, 0, None) + self.perform_build_test(targets, 0, 0, None) except: self.cancel('KFAIL') @@ -158,7 +159,7 @@ class RebuildTest(CIBaseTest): try: self.perform_build_test('mc:qemuamd64-stretch:isar-image-base', - is_cross_build, None) + is_cross_build, 0, None) finally: self.restorefile(dpkgbase_file) @@ -206,3 +207,87 @@ class ContainerSdkTest(CIBaseTest): targets = ['mc:container-amd64-stretch:isar-image-base'] self.perform_container_test(targets, 'do_populate_sdk') + +class SstateTest(CIBaseTest): + + """ + Test builds with artifacts taken from sstate cache + + :avocado: tags=sstate,fast,full + """ + def check_executed_tasks(self, build_dir, target, expected): + taskorder_file = glob.glob(f'{build_dir}/tmp/work/{self.distro_distroarch}/{target}/*/temp/log.task_order') + try: + with open(taskorder_file[0], 'r') as f: + tasks = [l.split()[0] for l in f.readlines()] + except (FileNotFoundError, IndexError): + tasks = [] + if expected is None: + # require that no tasks were executed + return len(tasks) == 0 + for e in expected: + should_run = True + if e.startswith('!'): + should_run = False + e = e[1:] + if should_run != (e in tasks): + self.log.error(f"{target}: executed tasks {str(tasks)} did not match expected {str(expected)}") + return False + return True + + def test_sstate(self): + build_dir, bb_args = self.prep('Sstate', '', 0, 1, 1) + image_target = 'mc:qemuamd64-bullseye:isar-image-base' + package_target = 'mc:qemuamd64-bullseye:hello' + self.distro_distroarch = 'debian-bullseye-amd64' + + # Cleanup sstate and tmp before test + process.run(f'rm -rf {build_dir}/sstate-cache', sudo=True) + self.deletetmp(build_dir) + + # Populate cache + self.perform_build_test(image_target, 0, 1, None) + + # Rebuild image + self.deletetmp(build_dir) + self.perform_build_test(image_target, 0, 1, None) + if not all([ + self.check_executed_tasks(build_dir, 'isar-bootstrap-target', + ['do_bootstrap_setscene', '!do_bootstrap']), + self.check_executed_tasks(build_dir, 'buildchroot-target', + ['do_rootfs_setscene', '!do_rootfs']), + self.check_executed_tasks(build_dir, 'isar-image-base-*-wic-img', + ['do_rootfs_setscene', '!do_rootfs']) + ]): + self.fail("Failed rebuild image") + + # Rebuild single package + self.deletetmp(build_dir) + self.perform_build_test(package_target, 0, 1, None) + if not all([ + self.check_executed_tasks(build_dir, 'isar-bootstrap-target', + ['do_bootstrap_setscene']), + self.check_executed_tasks(build_dir, 'buildchroot-target', + ['!do_buildchroot_deploy']), + self.check_executed_tasks(build_dir, 'hello', + ['do_dpkg_build_setscene', 'do_deploy_deb', '!do_dpkg_build']) + ]): + self.fail("Failed rebuild single package") + + # Rebuild package and image + self.deletetmp(build_dir) + process.run(f'find {build_dir}/sstate-cache/ -name sstate:hello:* -delete') + self.perform_build_test(image_target, 0, 1, None) + if not all([ + self.check_executed_tasks(build_dir, 'isar-bootstrap-target', + ['do_bootstrap_setscene', '!do_bootstrap']), + self.check_executed_tasks(build_dir, 'buildchroot-target', + ['do_rootfs_setscene', '!do_rootfs']), + self.check_executed_tasks(build_dir, 'hello', + ['do_fetch', 'do_dpkg_build']), + # TODO: if we actually make a change to hello, then we could test that do_rootfs is executed. + # currently, hello is rebuilt, but its sstate sig/hash does not change. + self.check_executed_tasks(build_dir, 'isar-image-base-*-wic-img', + ['do_rootfs_setscene', '!do_rootfs']) + ]): + self.fail("Failed rebuild package and image") diff --git a/testsuite/build_test/cibase.py b/testsuite/build_test/cibase.py index 0bff7e4..3cba412 100644 --- a/testsuite/build_test/cibase.py +++ b/testsuite/build_test/cibase.py @@ -11,7 +11,7 @@ isar_root = os.path.dirname(__file__) + '/../..' class CIBaseTest(CIBuilder): - def prep(self, testname, targets, cross, debsrc_cache): + def prep(self, testname, targets, cross, debsrc_cache, sstate): build_dir = self.params.get('build_dir', default=isar_root + '/build') build_dir = os.path.realpath(build_dir) quiet = int(self.params.get('quiet', default=0)) @@ -19,6 +19,8 @@ class CIBaseTest(CIBuilder): if not quiet: bitbake_args.append('-v') + if not sstate: + bitbake_args.append('--no-setscene') self.log.info('===================================================') self.log.info('Running ' + testname + ' test for:') @@ -31,8 +33,8 @@ class CIBaseTest(CIBuilder): return build_dir, bitbake_args; - def perform_build_test(self, targets, cross, bitbake_cmd): - build_dir, bb_args = self.prep('Isar build', targets, cross, 1) + def perform_build_test(self, targets, cross, sstate, bitbake_cmd): + build_dir, bb_args = self.prep('Isar build', targets, cross, 1, sstate) self.log.info('Starting build...') @@ -40,7 +42,7 @@ class CIBaseTest(CIBuilder): def perform_repro_test(self, targets, signed): cross = int(self.params.get('cross', default=0)) - build_dir, bb_args = self.prep('repro Isar build', targets, cross, 0) + build_dir, bb_args = self.prep('repro Isar build', targets, cross, 0, 0) gpg_pub_key = os.path.dirname(__file__) + '/../base-apt/test_pub.key' gpg_priv_key = os.path.dirname(__file__) + '/../base-apt/test_priv.key' @@ -79,7 +81,7 @@ class CIBaseTest(CIBuilder): def perform_wic_test(self, targets, wks_path, wic_path): cross = int(self.params.get('cross', default=0)) - build_dir, bb_args = self.prep('WIC exclude build', targets, cross, 1) + build_dir, bb_args = self.prep('WIC exclude build', targets, cross, 1, 0) layerdir_isar = self.getlayerdir('isar') @@ -108,7 +110,7 @@ class CIBaseTest(CIBuilder): def perform_container_test(self, targets, bitbake_cmd): cross = int(self.params.get('cross', default=0)) - build_dir, bb_args = self.prep('Isar Container', targets, cross, 1) + build_dir, bb_args = self.prep('Isar Container', targets, cross, 1, 0) self.containerprep(build_dir) -- 2.30.2