Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3716BC433FE for ; Sat, 22 Oct 2022 20:44:43 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 9E8E584E3A; Sat, 22 Oct 2022 22:44:40 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=konsulko.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=konsulko.com header.i=@konsulko.com header.b="lMpwjL/s"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id C417384E3D; Sat, 22 Oct 2022 22:44:38 +0200 (CEST) Received: from mail-qt1-x832.google.com (mail-qt1-x832.google.com [IPv6:2607:f8b0:4864:20::832]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id E641A84CBC for ; Sat, 22 Oct 2022 22:44:35 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=konsulko.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=trini@konsulko.com Received: by mail-qt1-x832.google.com with SMTP id h24so3675598qta.7 for ; Sat, 22 Oct 2022 13:44:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=konsulko.com; s=google; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=FhiEGSrZlxrtwZnPK4N9bOTOfORQEQD24jPYvEssvLk=; b=lMpwjL/sdB1ROaXWBZaWci3xWXIo0ohIfX4lp05yL4tLySdnCPTJa0kQKV3pJs49sU eMQF0g6Ncnl1UwFQmeetQlSdQsUidi4xmCo0rJQ38P8WQtlqJiM3P+4C2SkaEmyaLoxm rxes2f0/5BPw9UcsFLghxShP7KTqgCIITISBs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=FhiEGSrZlxrtwZnPK4N9bOTOfORQEQD24jPYvEssvLk=; b=ufR8JNuh6GnFFLBVpKAqwKS7n/KyC61gaVvo/A89zMyGEAM6RfMlQcCpa5gVzM9XTp PTsGxy7rple8DHWzvGy+RqWMKdbTPrR1CUvY8vufmkNn0/4D5zK//IJNlzzmj2NK/po2 a9iX1fhSJuB9dMJmHhsKDedA0yAcVYScExVxm21LIkuaYigagbTVTgJMnQOzwFuiUxgl CzZ7Mv9+QDUA7UDAjgL0lxJ0ZmfBuQXBvkkHRNyP/PRsVpARFKn9D15bif1qiR3nybxc Mq38qbYg8uBn8AVC6y+a+jQBd+8ihsvbw68SfVQx9Cfr7u8bZ4XuuHxIYDLyIvcTCCWk fpwQ== X-Gm-Message-State: ACrzQf1kDObj2S3IiQXnOUrHK18sSt4usyKC3i0Z+mfb2rGV2yAu+iEF xflUagPycR1fUQG/oHlMMYJ+Pw== X-Google-Smtp-Source: AMsMyM7T/KxTAKfnUwWo0HClagFDDkB5DlJ4llfpJtMW8d79Gu3GKNZ5dW+QPzppdL+XVAc2ZUE4AQ== X-Received: by 2002:ac8:584a:0:b0:39c:e0dd:1c9e with SMTP id h10-20020ac8584a000000b0039ce0dd1c9emr22179801qth.659.1666471474537; Sat, 22 Oct 2022 13:44:34 -0700 (PDT) Received: from bill-the-cat (2603-6081-7b00-6400-c8e3-75c2-7f29-be84.res6.spectrum.com. [2603:6081:7b00:6400:c8e3:75c2:7f29:be84]) by smtp.gmail.com with ESMTPSA id de38-20020a05620a372600b006ce30a5f892sm12204392qkb.102.2022.10.22.13.44.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 22 Oct 2022 13:44:33 -0700 (PDT) Date: Sat, 22 Oct 2022 16:44:31 -0400 From: Tom Rini To: Sean Anderson Cc: u-boot@lists.denx.de, Simon Glass , Heinrich Schuchardt Subject: Re: [PATCH] test: Don't use sudo in unit test Message-ID: <20221022204431.GL2020586@bill-the-cat> References: <20221022201649.1346300-1-seanga2@gmail.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="bvZa7CfMr60H2IOE" Content-Disposition: inline In-Reply-To: <20221022201649.1346300-1-seanga2@gmail.com> X-Clacks-Overhead: GNU Terry Pratchett X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean --bvZa7CfMr60H2IOE Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sat, Oct 22, 2022 at 04:16:49PM -0400, Sean Anderson wrote: > I originally did this with fusefat, but it was unbearably slow. It could = be > useful with some optimization work... I switched to mtools instead. I hav= e used > fuse2fs on another project and it worked great. >=20 > I didn't test this too throughoughly; I just made sure that the contents = were > intact (by using a loopback mount). >=20 > Signed-off-by: Sean Anderson > --- >=20 > test/py/tests/test_ut.py | 44 ++++++++++++++++------------------------ > 1 file changed, 18 insertions(+), 26 deletions(-) >=20 > diff --git a/test/py/tests/test_ut.py b/test/py/tests/test_ut.py > index 9d42390373..8bd7153ed7 100644 > --- a/test/py/tests/test_ut.py > +++ b/test/py/tests/test_ut.py > @@ -21,26 +21,14 @@ def setup_bootflow_image(u_boot_console): > """Create a 20MB disk image with a single FAT partition""" > cons =3D u_boot_console > fname =3D os.path.join(cons.config.source_dir, 'mmc1.img') > + fatpart =3D os.path.join(cons.config.source_dir, 'mmc1p1.img') > mnt =3D os.path.join(cons.config.persistent_data_dir, 'mnt') > mkdir_cond(mnt) > =20 > - u_boot_utils.run_and_log(cons, 'qemu-img create %s 20M' % fname) > - u_boot_utils.run_and_log(cons, 'sudo sfdisk %s' % fname, > - stdin=3Db'type=3Dc') > - > - loop =3D None > - mounted =3D False > - complete =3D False > try: > - out =3D u_boot_utils.run_and_log(cons, > - 'sudo losetup --show -f -P %s' % = fname) > - loop =3D out.strip() > - fatpart =3D '%sp1' % loop > - u_boot_utils.run_and_log(cons, 'sudo mkfs.vfat %s' % fatpart) > - u_boot_utils.run_and_log( > - cons, 'sudo mount -o loop %s %s -o uid=3D%d,gid=3D%d' % > - (fatpart, mnt, os.getuid(), os.getgid())) > - mounted =3D True > + with open(fatpart, 'ab') as part: > + part.truncate(19 * 1024 * 1024) > + u_boot_utils.run_and_log(cons, f'mkfs.vfat {fatpart}') > =20 > vmlinux =3D 'vmlinuz-5.3.7-301.fc31.armv7hl' > initrd =3D 'initramfs-5.3.7-301.fc31.armv7hl.img' > @@ -78,17 +66,22 @@ label Fedora-Workstation-armhfp-31-1.9 (5.3.7-301.fc3= 1.armv7hl) > dtb_file =3D os.path.join(mnt, '%s/sandbox.dtb' % dtbdir) > u_boot_utils.run_and_log( > cons, 'dtc -o %s' % dtb_file, stdin=3Db'/dts-v1/; / {};') > - complete =3D True > + > + u_boot_utils.run_and_log(cons, ('mcopy', '-bQmsi', fatpart, > + *(os.path.join(mnt, file) for fi= le in > + (vmlinux, initrd, dtbdir, 'ext= linux')), > + '::')) > + > + with open(fname, 'ab') as image: > + image.truncate(20 * 1024 * 1024) > + u_boot_utils.run_and_log(cons, f'sfdisk {fname}', > + stdin=3Db'type=3Dc, start=3D1M, siz= e=3D19M') > + image.seek(1 * 1024 * 1024) > + with open(fatpart, 'rb') as part: > + image.write(part.read()) > except ValueError as exc: > - print('Falled to create image, failing back to prepared copy: %s= ', > + print('Failed to create image, failing back to prepared copy:', > str(exc)) > - finally: > - if mounted: > - u_boot_utils.run_and_log(cons, 'sudo umount %s' % mnt) > - if loop: > - u_boot_utils.run_and_log(cons, 'sudo losetup -d %s' % loop) > - > - if not complete: > # Use a prepared image since we cannot create one > infname =3D os.path.join(cons.config.source_dir, > 'test/py/tests/bootstd/mmc1.img.xz') > @@ -96,7 +89,6 @@ label Fedora-Workstation-armhfp-31-1.9 (5.3.7-301.fc31.= armv7hl) > cons, > ['sh', '-c', 'xz -dc %s >%s' % (infname, fname)]) > =20 > - > @pytest.mark.buildconfigspec('ut_dm') > def test_ut_dm_init(u_boot_console): > """Initialize data for ut dm tests.""" The test still passes and here the run time doesn't change either. --=20 Tom --bvZa7CfMr60H2IOE Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQGzBAABCgAdFiEEGjx/cOCPqxcHgJu/FHw5/5Y0tywFAmNUVisACgkQFHw5/5Y0 tyyrdwv+Lp+LC/jeye3PGQ5Ll+UnzP8nIu5nBf3hhYOjXq6fOo6prC7DaTGN0/4i uB3d2vbWAGmTblMRmSLK71KF2WO0MQvc2X+SHNhh3HoNC7/x7ApDJZlZNygYnLyF FdAhDwRzEuz5izK2xze4Ru5DtuHdrkI3pbYN1NaAfPQR5SfvrLKVU+U+k+9qvYG5 bo5Gd8iOX3sCfttuF+tYVcd+RchfbxR68AAywmQ3HjtSV9YuCNigh3WT5is1FhmW tXrpfDMVfeVKU/fLzp5E+kzMOrgecUD5wPElYvPsiRPPZxXHAJsbAFiKqjsaULGm kt5zNvIFcpuIRR2xIPQANYCE3Ce3Ym2S01GDcTZZFCcVpMTMcMB2TEIwC7K8hfSh 9g1sb+Yn72TgkJl0ZHquKSQENv6i8H1moU52IzGn0kHJ6TOIvVNk6CgAmt7UExMw /P5VZpf5mzolE7v8xK9wAkgK9y8pzYWzjZf0tlH3EyaC0QQuWLAoe7qbhhy0ysto EwdhD8ZG =K9OU -----END PGP SIGNATURE----- --bvZa7CfMr60H2IOE--