From mboxrd@z Thu Jan 1 00:00:00 1970 X-GM-THRID: 7096083842147024896 X-Received: by 2002:a5d:514c:0:b0:20c:b378:67b7 with SMTP id u12-20020a5d514c000000b0020cb37867b7mr22960748wrt.202.1652348749826; Thu, 12 May 2022 02:45:49 -0700 (PDT) X-BeenThere: isar-users@googlegroups.com Received: by 2002:a5d:64ca:0:b0:20c:bb44:bd7 with SMTP id f10-20020a5d64ca000000b0020cbb440bd7ls1906968wri.0.gmail; Thu, 12 May 2022 02:45:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxT8op6ioOefT94bnW1fNz0KJec7n1rdtVOYIybLTHKAQV8JY0U9x0JoKkcj/u6w80V8+Y8 X-Received: by 2002:adf:d1ec:0:b0:20c:61ef:93b6 with SMTP id g12-20020adfd1ec000000b0020c61ef93b6mr26480853wrd.694.1652348748799; Thu, 12 May 2022 02:45:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652348748; cv=none; d=google.com; s=arc-20160816; b=N6vanLi+qvLtDAlDiGSUO7D/+kgVRxsjf6fDznuiMqRTzISi9mkOw93eqG+7Yd6Qyf wYcscr3mTW6zRFOsZIqh6Y6v+uTsx5/kKcxjp7PyvbOr+mX4PkoZwWuaHNSz6YtmK3Fp npMS54RQAc4+pqcFSII9d6I0ywdfF8FsmphZNPf3WDcse8xBxM75eK2eF6ojBfJSVIkq UOGTX8+yO7wxjkiJ3nFFnsV6V0+7kpHtMkJz0T1m05VZbIhPEY8gTKxnpLKh++BC8tT3 s8l5t7yZ+ohnsyKo/lwjZNoKmERnsxIifWo6CmuHzHt6vLU7W+EfEIeexpqZA9kEjwXy NSqQ== 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=o5fYs5w71msqLaUXvYjd7VpEaM1gh1svKX80QcP1zyE=; b=JJpSdQSdWEgJmS2URWZSbqq9laTvdMBmQSpsnYegyxsA1MZgA3Yjde+HsSw6MOTa8L DMcNLzAc+QNkiABUE0L1vZAoKoXABNPp2JsRxldGGEuGLS/+KqWGCj2xRyFtxetNh6zj HQ05UqzUK4IfMgAk1mI5kb9TS7angCWXlNW30EQIk+weBt8MSvGQyrlZ/WT5kDZO2FhB Icdfiv508+OlH16rJjZuNWCB2dDxU7R3yNdhnT7Vmjz1UucoFNJA+v4Ht+jNZ1h7UDrY MiOejDdOs2hD5gEiwTB72taZaVwaH9qyClnuH4A7t6ZoxnIWSsrhhK7X7NHuAatDfiLr qjlw== ARC-Authentication-Results: i=1; gmr-mx.google.com; dkim=pass header.i=@siemens.com header.s=fm1 header.b=NNI5E+1x; spf=pass (google.com: domain of fm-72506-20220512094548f0f47ff8f2d683fb9a-hx9rvx@rts-flowmailer.siemens.com designates 185.136.65.227 as permitted sender) smtp.mailfrom=fm-72506-20220512094548f0f47ff8f2d683fb9a-HX9Rvx@rts-flowmailer.siemens.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=siemens.com Return-Path: Received: from mta-65-227.siemens.flowmailer.net (mta-65-227.siemens.flowmailer.net. [185.136.65.227]) by gmr-mx.google.com with ESMTPS id bg13-20020a05600c3c8d00b00394803e5756si192663wmb.0.2022.05.12.02.45.48 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 12 May 2022 02:45:48 -0700 (PDT) Received-SPF: pass (google.com: domain of fm-72506-20220512094548f0f47ff8f2d683fb9a-hx9rvx@rts-flowmailer.siemens.com designates 185.136.65.227 as permitted sender) client-ip=185.136.65.227; Authentication-Results: gmr-mx.google.com; dkim=pass header.i=@siemens.com header.s=fm1 header.b=NNI5E+1x; spf=pass (google.com: domain of fm-72506-20220512094548f0f47ff8f2d683fb9a-hx9rvx@rts-flowmailer.siemens.com designates 185.136.65.227 as permitted sender) smtp.mailfrom=fm-72506-20220512094548f0f47ff8f2d683fb9a-HX9Rvx@rts-flowmailer.siemens.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=siemens.com Received: by mta-65-227.siemens.flowmailer.net with ESMTPSA id 20220512094548f0f47ff8f2d683fb9a for ; Thu, 12 May 2022 11:45:48 +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=o5fYs5w71msqLaUXvYjd7VpEaM1gh1svKX80QcP1zyE=; b=NNI5E+1xrojFNHo3wsphhKmlLqQQdJCnErDq54QorJouWzqHaxzabJM08U6f4me57t3AAt ZWaOOUezpKvV7SYAgGhWz+xUWlsYFKyzX9onyGtrYL+sDRAJn8E+sX73+6InxCCJZuHjfe9w 5+7ZB04YTZt2kjILd+K+rz5QkbSZ8=; From: Felix Moessbauer To: isar-users@googlegroups.com Cc: henning.schild@siemens.com, jan.kiszka@siemens.com, Felix Moessbauer Subject: [PATCH v2 4/4] ci: test partition layout of splitted-rootfs image Date: Thu, 12 May 2022 11:45:24 +0200 Message-Id: <20220512094524.216340-5-felix.moessbauer@siemens.com> In-Reply-To: <20220512094524.216340-1-felix.moessbauer@siemens.com> References: <20220512094524.216340-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: rA/KGuzMfKGu 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 the path exclusions is error prone. Hence, we check that all generated partitions do not contain excluded paths. Further, we check that expected path are there. Signed-off-by: Felix Moessbauer --- testsuite/cibase.py | 58 ++++++++++++++++++++++++++++++++++++++++++ testsuite/cibuilder.py | 6 ++++- testsuite/citest.py | 14 ++++++++++ 3 files changed, 77 insertions(+), 1 deletion(-) diff --git a/testsuite/cibase.py b/testsuite/cibase.py index b25c356e..fd272ef5 100755 --- a/testsuite/cibase.py +++ b/testsuite/cibase.py @@ -164,3 +164,61 @@ 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 -l {mountpoint}', sudo=True, ignore_status=True) + + 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()] + for i in range(3): + os.makedirs(mountpoints[i], exist_ok=True) + _umount(mountpoints[i]) + _mount(partitions[i], mountpoints[i]) + + # in boot partition, we expect /boot + 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') + + [_umount(mnt) for mnt 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 8d00054a..26101010 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