From mboxrd@z Thu Jan 1 00:00:00 1970 X-GM-THRID: 7016230395466219520 X-Received: by 2002:a19:495c:: with SMTP id l28mr3571557lfj.484.1636026689137; Thu, 04 Nov 2021 04:51:29 -0700 (PDT) X-BeenThere: isar-users@googlegroups.com Received: by 2002:a05:6512:3499:: with SMTP id v25ls140581lfr.0.gmail; Thu, 04 Nov 2021 04:51:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxVwxK9V2+s6Uwg4xYYYsDvLcnCHKTPzbSSB9/ysSesNctEVYJsnLcJWNHrzgQH3b2R0bFE X-Received: by 2002:a05:6512:3e22:: with SMTP id i34mr17721272lfv.77.1636026688094; Thu, 04 Nov 2021 04:51:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1636026688; cv=none; d=google.com; s=arc-20160816; b=T52DB4KqfYaUoVnkTTSHmWub/AdJ1lYQ+7xgfY8zdD2z3lIYuw8gS4lY3TXrRmIDfs f62CC10OHrV2eIqMXarKBm+B2L0hkRX9vWIzFpud6pZbETrnKOI1NqcZCRwPR2be0A8s azJPF2deo6CAHsXOKmOuYnlk+VzSTVVsZFOCBPy1A82i7h/KzRGqnBHgoLqfYyzGEP5H w9qZ/pKeacZtJSNZQyt4HvbUJr3S5dfW/D4/YVI9blv1akI1Njlm8AOGHD0jITN+uyKP Fog8m1qJRDROsrhc0A535ywtkBklB6BWVESl6YUDpE7AjNl4y580lNHEH5aehKq7RlwS fm5A== 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=VFEIca6XjG3MiI5Sv4SXuQ9Isn/j8BeaPQll8mWs+tFZhsuuJhLu1PvFO0LlTEp4yT io7F4xHUpIQuxOtE03YgGb5q3Ew04U912UWOQoC0MtGLXr/Zbxv1H4Stpihx1VSR6P86 w/25NMakzN8BipjDGDU3koLNuvw6k/zD3W3be7vkKR/4y23XakptVQ6l0HqnM9kX+Ayq 41BqXtpGjIlPvviEF3bUGn9Kgg6ublrS5oAE36S0tmJIByh7ZAve5XJuZkSLfsxoh8m7 EFIkjy1pE8ltuByVQ3r/ZDoVlKzj7xDUDwSqDfE3/YxPgUNdAnhnfOAXa9yKG5WvU7Xb G9qg== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: domain of adriaan.schmidt@siemens.com designates 194.138.37.40 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 gecko.sbs.de (gecko.sbs.de. [194.138.37.40]) by gmr-mx.google.com with ESMTPS id v138si376487lfa.2.2021.11.04.04.51.27 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 04 Nov 2021 04:51:28 -0700 (PDT) Received-SPF: pass (google.com: domain of adriaan.schmidt@siemens.com designates 194.138.37.40 as permitted sender) client-ip=194.138.37.40; Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of adriaan.schmidt@siemens.com designates 194.138.37.40 as permitted sender) smtp.mailfrom=adriaan.schmidt@siemens.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=siemens.com Received: from mail1.sbs.de (mail1.sbs.de [192.129.41.35]) by gecko.sbs.de (8.15.2/8.15.2) with ESMTPS id 1A4BpQNo027826 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 4 Nov 2021 12:51:26 +0100 Received: from random.ppmd.siemens.net (random.ppmd.siemens.net [139.25.68.25]) by mail1.sbs.de (8.15.2/8.15.2) with ESMTP id 1A4BpPbR026036; Thu, 4 Nov 2021 12:51:26 +0100 From: Adriaan Schmidt To: isar-users@googlegroups.com Cc: Adriaan Schmidt Subject: [PATCH v5 13/13] sstate: add test case Date: Thu, 4 Nov 2021 12:51:23 +0100 Message-Id: <20211104115123.2519356-14-adriaan.schmidt@siemens.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211104115123.2519356-1-adriaan.schmidt@siemens.com> References: <20211104115123.2519356-1-adriaan.schmidt@siemens.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TUID: qW3IYyp+b7Qj 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