From mboxrd@z Thu Jan 1 00:00:00 1970 X-GM-THRID: 7096083842147024896 X-Received: by 2002:a05:6512:25a4:b0:478:56dd:6451 with SMTP id bf36-20020a05651225a400b0047856dd6451mr11210463lfb.516.1653315561477; Mon, 23 May 2022 07:19:21 -0700 (PDT) X-BeenThere: isar-users@googlegroups.com Received: by 2002:a05:6512:1693:b0:448:3742:2320 with SMTP id bu19-20020a056512169300b0044837422320ls1174603lfb.1.gmail; Mon, 23 May 2022 07:19:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzig9LF63bMe9hZLH2tQmb5azPRtqI6pX5V1sFYgT5pKkApslhURnUJ1n3snX/+dXDzxhRD X-Received: by 2002:a05:6512:3229:b0:477:b767:6766 with SMTP id f9-20020a056512322900b00477b7676766mr15823183lfe.99.1653315560321; Mon, 23 May 2022 07:19:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653315560; cv=none; d=google.com; s=arc-20160816; b=WYhkKNyR4GoZQ4+wmI66N4Y32cwKrJV/+FzcgEtm9UHGw2NH/pK12ObJSiPIoIPhHJ asJF+PZ02dAETSDW9R5UpkggIIcv5yJYUprJ64Z7uu07RlfIJx9WFEdvPq9rxkPfjNPj FMrRfy6DNY7WHvREq2/JrmBc7/OKTdwVzUM5c5SCSE2JcyrL/Kv0A8kpfWc4lkR1hg7A 73SkyjP/QM3T2fNzU/qomtM19D8+Y712byAbjZW+KDzqrs/V3nDU/Go2IviuEK5CQF01 SpGl83kpUMGazZWwpiYpCvfUvUoAAutW5eVai+zw2XAyTRvQj3f2Sw5UEgsvDs91F92r uXag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id; bh=urgYPd8wnS7OsIwDjtu1y33+5Z2xuQuWJhOeQN/juDw=; b=aTI5N5Gr7D0/6tGYy4N8dNaKNerI8wWzJ9H/LTeQeraoNaXJ3YgvByfyJo6fXzGycd OmAzuj9lltfzSvsOSz7OAxlQ3HwSX69++vB3VGF6S6EDise8dIHCYNBN9er19Ee+38OK Gqs7wTw7wf9EzqL5bZv6LxDZHMvD2j2sBDnWLT5Vf80b8FESRFEsoDeIFK8UtECvHYJH nCTdl58kf2FHAk/NqovNQHrazomPOk8Gf3Mqf2V25JxFFwQSEkSD5/4lGMkGJsXTbnW/ UZsVXFhWRc4TaBfEWPqs/Jirrkn14+FK0Xiw52YohKKP3Mq3wBAFDt9TUJoTaXsKTK3P bbaQ== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: domain of amikan@ilbers.de designates 85.214.156.166 as permitted sender) smtp.mailfrom=amikan@ilbers.de Return-Path: Received: from shymkent.ilbers.de (shymkent.ilbers.de. [85.214.156.166]) by gmr-mx.google.com with ESMTPS id u2-20020a05651220c200b00472523f3a8esi675247lfr.6.2022.05.23.07.19.20 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 May 2022 07:19:20 -0700 (PDT) Received-SPF: pass (google.com: domain of amikan@ilbers.de designates 85.214.156.166 as permitted sender) client-ip=85.214.156.166; Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of amikan@ilbers.de designates 85.214.156.166 as permitted sender) smtp.mailfrom=amikan@ilbers.de Received: from [127.0.0.1] (host-80-81-17-52.static.customer.m-online.net [80.81.17.52]) (authenticated bits=0) by shymkent.ilbers.de (8.15.2/8.15.2/Debian-8) with ESMTPSA id 24NEJGb6024785 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 23 May 2022 16:19:18 +0200 Message-ID: <1b0bab17-0fc1-445e-aa0d-bb1a7c533fbb@ilbers.de> Date: Mon, 23 May 2022 17:19:16 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.5.0 Subject: Re: [PATCH v3 4/4] ci: test partition layout of splitted-rootfs image Content-Language: en-US To: Felix Moessbauer , isar-users@googlegroups.com Cc: henning.schild@siemens.com, jan.kiszka@siemens.com, florian.bezdeka@siemens.com References: <20220512121507.362108-1-felix.moessbauer@siemens.com> From: Anton Mikanovich In-Reply-To: <20220512121507.362108-1-felix.moessbauer@siemens.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED autolearn=unavailable autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on shymkent.ilbers.de X-TUID: mwDJ+56guMlI 12.05.2022 15:15, Felix Moessbauer wrote: > 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 | 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) Do not introduce new lazy umounts, please. If umount fails we need to fix the reason, but do not mask it. You can maybe use avocado.utils.partition.Partition class for all mount, umount and mountpoint check operations. > + > + 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: Can you make partitions count and mount names to be configurable? It will make this code easier to maintain in case any target changes. > + 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]) Why not to check for mountpoint here? Unmounting without check will cause unnecessary errors in job logs. Moreover, what is the case when this umount will be really needed? > + > + 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] Please cover mount-umount stuff with try-finally to be sure there will be no mounts left in case of failure. > + > + 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) Do we need the logs from build-wic-rootfs for analyzing in case CI fails? If yes - this path should be added into 'artifacts' part of .gitlab-ci.yml