From mboxrd@z Thu Jan 1 00:00:00 1970 X-GM-THRID: 7102799916284510208 X-Received: by 2002:a05:6512:104f:b0:478:7c57:956c with SMTP id c15-20020a056512104f00b004787c57956cmr20163491lfb.554.1653749491592; Sat, 28 May 2022 07:51:31 -0700 (PDT) X-BeenThere: isar-users@googlegroups.com Received: by 2002:a05:6512:1693:b0:448:3742:2320 with SMTP id bu19-20020a056512169300b0044837422320ls2728674lfb.1.gmail; Sat, 28 May 2022 07:51:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJybrsIfEPOEu9VQ8d5phRBeSCs3zlGjugWytj9M84giMj3mxKi9goRBf51CBPUi7hIsI8BI X-Received: by 2002:ac2:505a:0:b0:478:5082:eb1e with SMTP id a26-20020ac2505a000000b004785082eb1emr28492842lfm.551.1653749490497; Sat, 28 May 2022 07:51:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653749490; cv=none; d=google.com; s=arc-20160816; b=DMbgWokDrYKXYe4z6YhlzbuzKcSUQ1ezA02iGCFR2vwXRLZ0vKHoUyEHV9sFcyIYwM ByF+nxZXCUhExA4vCCRAr/8JXt1sh8285dD+j/S3o40EMvIq5lbAL1hKcqk9p7By0Uc8 gg5EtMgXKq1uyNa1myhWo7UH3f5K2Pogw7g9hB2fAuvdmJM+ybUzhiYbI2FNWlnr7P4R WJu0jMhg9cKfUIp21LMlY5s2YWbuvh2H0ir62ErMbPjHjdZ1cJMQqZmv0nH5ECz8q3vW yYfeGNvnhREEnLldJs7M+DmAe60Nix0AgYTmMopWOfjV0ufVpXZlDfmXmt9p2ojx0TF4 x6mA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=feedback-id:content-transfer-encoding:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature; bh=XGlcOlNiN/J4/u56wG4Cn1kWMV6Rr9qx2ao/bx3834E=; b=yLjNbbbG9khw39vIl41jpjYQC0VT0jcxLPK6w+OxuY8rxOxBUzHLkCZy4bL2k18pHY UInAFihsbJKD6PKuaQ92+/MwhBl7hgQljaJXNUo7XM4TxAY50Jkkq889upT6aOORX0se l2Ex2uVNCqsiVqNtzxzzVdS45eM7Gp/nFHaoIcPvTzXrtpSYFssMKJrDT4U4J9PRRs44 422S/S5QMiyXSjdnEKNiJ9e/ES5JtFRM+7o+7aPGLEbQjr+4KX9pJ694PQjyWqiLbHZm rWNlmhVRqgaKmw2/ZUS/UFGQ7QaloeL2eeZtRS8LNoD1Z59MOyXh4FjLG8ifhjJWuQlT NV4w== ARC-Authentication-Results: i=1; gmr-mx.google.com; dkim=pass header.i=@siemens.com header.s=fm1 header.b=ky6yolbH; spf=pass (google.com: domain of fm-72506-202205281451291b40a8e7c428bf0b7b-dz5z0t@rts-flowmailer.siemens.com designates 185.136.64.226 as permitted sender) smtp.mailfrom=fm-72506-202205281451291b40a8e7c428bf0b7b-dZ5Z0T@rts-flowmailer.siemens.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=siemens.com Return-Path: Received: from mta-64-226.siemens.flowmailer.net (mta-64-226.siemens.flowmailer.net. [185.136.64.226]) by gmr-mx.google.com with ESMTPS id k22-20020a2ea276000000b0024da01a8c6dsi305584ljm.1.2022.05.28.07.51.30 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 28 May 2022 07:51:30 -0700 (PDT) Received-SPF: pass (google.com: domain of fm-72506-202205281451291b40a8e7c428bf0b7b-dz5z0t@rts-flowmailer.siemens.com designates 185.136.64.226 as permitted sender) client-ip=185.136.64.226; Authentication-Results: gmr-mx.google.com; dkim=pass header.i=@siemens.com header.s=fm1 header.b=ky6yolbH; spf=pass (google.com: domain of fm-72506-202205281451291b40a8e7c428bf0b7b-dz5z0t@rts-flowmailer.siemens.com designates 185.136.64.226 as permitted sender) smtp.mailfrom=fm-72506-202205281451291b40a8e7c428bf0b7b-dZ5Z0T@rts-flowmailer.siemens.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=siemens.com Received: by mta-64-226.siemens.flowmailer.net with ESMTPSA id 202205281451291b40a8e7c428bf0b7b for ; Sat, 28 May 2022 16:51:29 +0200 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; s=fm1; d=siemens.com; i=felix.moessbauer@siemens.com; h=Date:From:Subject:To:Message-ID:MIME-Version:Content-Type:Content-Transfer-Encoding:Cc:References:In-Reply-To; bh=XGlcOlNiN/J4/u56wG4Cn1kWMV6Rr9qx2ao/bx3834E=; b=ky6yolbH2zjoX3vPNFho68vwP2PuFSIFl+0la9Ou71V+p5E2nIt5pZpyGaP7CdtVx++haw 1QpHbjecTqhW4L3FhuOLy+tJ1VlGHcfmk3R/qNG+MRybLwILMmDEezyycJjqIYJ9eGXRnJoD l0MIhPc7CX49GHxRqVwnJihNh+JcI=; From: Felix Moessbauer To: isar-users@googlegroups.com Cc: jan.kiszka@siemens.com, henning.schild@siemens.com, florian.bezdeka@siemens.com, amikan@ilbers.de, Felix Moessbauer Subject: [PATCH v4 4/5] ci: test partition layout of splitted-rootfs image Date: Sat, 28 May 2022 16:50:41 +0200 Message-Id: <20220528145042.130894-5-felix.moessbauer@siemens.com> In-Reply-To: <20220528145042.130894-1-felix.moessbauer@siemens.com> References: <20220528145042.130894-1-felix.moessbauer@siemens.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Flowmailer-Platform: Siemens Feedback-ID: 519:519-72506:519-21489:flowmailer X-TUID: sOc0xwKIfSsn This adds a test that checks if splitting the rootfs across multiple partitions correctly works. The following is checked: file-permissions (based on wic internal check): WIC already has a built-in check for correct file permissions. In case the permission db is missing, a WIC warning is emitted. We simply check for this warning. partition layout and excluded paths: Specifying exclude paths is error prone. Hence, we check that all generated partitions do not contain excluded paths. Further, we check that the expected paths are there. Signed-off-by: Felix Moessbauer --- testsuite/cibase.py | 59 ++++++++++++++++++++++++++++++++++++++++++ testsuite/cibuilder.py | 6 ++++- testsuite/citest.py | 14 ++++++++++ 3 files changed, 78 insertions(+), 1 deletion(-) diff --git a/testsuite/cibase.py b/testsuite/cibase.py index 2ffb8191..fddf9af5 100755 --- a/testsuite/cibase.py +++ b/testsuite/cibase.py @@ -167,3 +167,62 @@ class CIBaseTest(CIBuilder): ['do_rootfs_install_setscene', '!do_rootfs_install']) ]): self.fail("Failed rebuild package and image") + + def perform_partition_layout_test(self, mc_target, **kwargs): + def _mount(device, mountpoint): + process.run(f'mount -o ro {device} {mountpoint}', sudo=True, ignore_status=False) + + def _umount(mountpoint): + process.run(f'umount {mountpoint}', sudo=True, ignore_status=False) + + def check_output_for_warnings(target, machine): + wic_output_files = glob.glob(f'{self.build_dir}/tmp/work/*/{target}-{machine}/*/temp/log.do_image_wic') + if len(wic_output_files) == 0: + self.fail('could not find WIC output file') + with open(wic_output_files[0], 'r') as output: + # in case we had permission problems, a WIC warning is in the logs + for line in output: + token = line.split() + if len(token) > 0 and token[0] == 'WARNING:': + self.fail(f'WIC issue found: {line}') + + def check_part_layout(target, machine): + pattern = f'{self.build_dir}/tmp/deploy/images/{machine}/{target}-*-{machine}.wic.p*' + partitions = sorted(glob.glob(pattern)) + if len(partitions) != 3: + self.fail(f'expected 3 partitions, but got {len(partitions)} (in {pattern})') + mountpoints = [os.path.join(self.build_dir, mp) for mp in 'mnt_efi mnt_root mnt_home'.split()] + + try: + [os.makedirs(mp) for mp in mountpoints] + [_mount(p,mp) for p,mp in zip(partitions, mountpoints)] + + # in boot partition, we expect /EFI + if not os.path.isdir(os.path.join(mountpoints[0], 'EFI')): + self.fail('boot partition does not provide /EFI') + # in root partition, boot and home should be excluded + if not os.path.isdir(os.path.join(mountpoints[1], 'etc')) or \ + os.path.isdir(os.path.join(mountpoints[1], 'home')) or \ + os.path.isdir(os.path.join(mountpoints[1], 'boot')): + self.fail('root partition does not contain expected dirs') + # home partition should contain home of user "user" + if not os.path.isdir(os.path.join(mountpoints[2], 'user')): + self.fail('home partition does not contain home of user') + finally: + [_umount(p) for p in partitions] + [os.removedirs(mp) for mp in mountpoints] + + mc_spec = mc_target.split(':') + target = mc_spec[2] + machine = mc_spec[1].split('-')[0] + + self.configure( + sstate=False, + compat_arch=False, + interactive_user=True, + **kwargs) + + self.bitbake(mc_target, **kwargs) + + check_output_for_warnings(target, machine) + check_part_layout(target, machine) diff --git a/testsuite/cibuilder.py b/testsuite/cibuilder.py index bc48d47f..e3fbb859 100755 --- a/testsuite/cibuilder.py +++ b/testsuite/cibuilder.py @@ -54,7 +54,7 @@ class CIBuilder(Test): def configure(self, compat_arch=True, cross=None, debsrc_cache=False, container=False, ccache=False, sstate=False, offline=False, - gpg_pub_key=None, **kwargs): + gpg_pub_key=None, interactive_user=False, **kwargs): # write configuration file and set bitbake_args # can run multiple times per test case self.check_init() @@ -107,6 +107,10 @@ class CIBuilder(Test): f.write('BASE_REPO_KEY="file://' + gpg_pub_key + '"\n') if distro_apt_premir: f.write('DISTRO_APT_PREMIRRORS = "%s"\n' % distro_apt_premir) + if interactive_user: + f.write('USERS += "user"\n') + f.write('USER_user[home] = "/home/user"\n') + f.write('USER_user[flags] = "create-home"\n') # include ci_build.conf in local.conf with open(self.build_dir + '/conf/local.conf', 'r+') as f: diff --git a/testsuite/citest.py b/testsuite/citest.py index 16e38d07..1f3e4abc 100755 --- a/testsuite/citest.py +++ b/testsuite/citest.py @@ -318,3 +318,17 @@ class VmBootTestFull(CIBaseTest): def test_amd64_focal(self): self.init() self.vm_start('amd64','focal') + +class SplittedRootfsTest(CIBaseTest): + + """ + Test partition layout of splitted rootfs image + + :avocado: tags=splittedrootfs,full + """ + + def test_wic_partition_layout(self): + mc_target = 'mc:qemuamd64-bookworm:isar-image-base' + + self.init('build-wic-rootfs') + self.perform_partition_layout_test(mc_target) -- 2.30.2