{"id":2219799,"url":"http://patchwork.ozlabs.org/api/patches/2219799/?format=json","web_url":"http://patchwork.ozlabs.org/project/uboot/patch/20260404140328.3724864-2-sjg@chromium.org/","project":{"id":18,"url":"http://patchwork.ozlabs.org/api/projects/18/?format=json","name":"U-Boot","link_name":"uboot","list_id":"u-boot.lists.denx.de","list_email":"u-boot@lists.denx.de","web_url":null,"scm_url":null,"webscm_url":null,"list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<20260404140328.3724864-2-sjg@chromium.org>","list_archive_url":null,"date":"2026-04-04T14:03:05","name":"[01/14] test: Add a helper class to create disk images","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"4908074d91251d79203fe19ba59c77255ce97d32","submitter":{"id":6170,"url":"http://patchwork.ozlabs.org/api/people/6170/?format=json","name":"Simon Glass","email":"sjg@chromium.org"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/uboot/patch/20260404140328.3724864-2-sjg@chromium.org/mbox/","series":[{"id":498729,"url":"http://patchwork.ozlabs.org/api/series/498729/?format=json","web_url":"http://patchwork.ozlabs.org/project/uboot/list/?series=498729","date":"2026-04-04T14:03:04","name":"test: Convert tests to use FsHelper and DiskHelper","version":1,"mbox":"http://patchwork.ozlabs.org/series/498729/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/2219799/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2219799/checks/","tags":{},"related":[],"headers":{"Return-Path":"<u-boot-bounces@lists.denx.de>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@legolas.ozlabs.org","Authentication-Results":["legolas.ozlabs.org;\n\tdkim=pass (1024-bit key;\n unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256\n header.s=google header.b=k8Frh7uQ;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de\n (client-ip=85.214.62.61; helo=phobos.denx.de;\n envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org)","phobos.denx.de;\n dmarc=pass (p=none dis=none) header.from=chromium.org","phobos.denx.de;\n spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de","phobos.denx.de;\n\tdkim=pass (1024-bit key;\n unprotected) header.d=chromium.org header.i=@chromium.org\n header.b=\"k8Frh7uQ\";\n\tdkim-atps=neutral","phobos.denx.de;\n dmarc=pass (p=none dis=none) header.from=chromium.org","phobos.denx.de;\n spf=pass smtp.mailfrom=sjg@chromium.org"],"Received":["from phobos.denx.de (phobos.denx.de [85.214.62.61])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4fny4j4GN7z1yG2\n\tfor <incoming@patchwork.ozlabs.org>; Sun, 05 Apr 2026 01:04:05 +1100 (AEDT)","from h2850616.stratoserver.net (localhost [IPv6:::1])\n\tby phobos.denx.de (Postfix) with ESMTP id 16FD983B48;\n\tSat,  4 Apr 2026 16:03:56 +0200 (CEST)","by phobos.denx.de (Postfix, from userid 109)\n id A9306840AA; Sat,  4 Apr 2026 16:03:55 +0200 (CEST)","from mail-oa1-x30.google.com (mail-oa1-x30.google.com\n [IPv6:2001:4860:4864:20::30])\n (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits))\n (No client certificate requested)\n by phobos.denx.de (Postfix) with ESMTPS id 709A480325\n for <u-boot@lists.denx.de>; Sat,  4 Apr 2026 16:03:53 +0200 (CEST)","by mail-oa1-x30.google.com with SMTP id\n 586e51a60fabf-40efc77933fso1722559fac.3\n for <u-boot@lists.denx.de>; Sat, 04 Apr 2026 07:03:53 -0700 (PDT)","from chromium.org ([73.34.74.121]) by smtp.gmail.com with ESMTPSA id\n 586e51a60fabf-4232eb3d0e4sm2348235fac.6.2026.04.04.07.03.49\n (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n Sat, 04 Apr 2026 07:03:50 -0700 (PDT)"],"X-Spam-Checker-Version":"SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de","X-Spam-Level":"","X-Spam-Status":"No, score=-2.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,\n DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,\n RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham\n autolearn_force=no version=3.4.2","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=chromium.org; s=google; t=1775311431; x=1775916231; darn=lists.denx.de;\n h=content-transfer-encoding:mime-version:references:in-reply-to\n :message-id:date:subject:cc:to:from:from:to:cc:subject:date\n :message-id:reply-to;\n bh=OCSzA3zLHBWTczbsOx7QtwIfFwAR3aipzS+RhcQ445M=;\n b=k8Frh7uQFcsEOcNMtgw1a7JxeFBWGOj4lIJ0MeD//Sioi3O0nGI6iMdK8cn16dDIC9\n PZNyFt+i4x6L5hwBMa55FO1rCBtML/6p9dD7rIEj5mKPKYCPT6wY7apDKVkq/GvtXLiK\n t5sj6O9yzycFvrZDSvfzosU+GaXvFeZKmjgRw=","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20251104; t=1775311431; x=1775916231;\n h=content-transfer-encoding:mime-version:references:in-reply-to\n :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from\n :to:cc:subject:date:message-id:reply-to;\n bh=OCSzA3zLHBWTczbsOx7QtwIfFwAR3aipzS+RhcQ445M=;\n b=H2FYPxi5HEo4QDyuz1b8lCxnVgET2aneQue8RDaY9ml+SvzjAP7VHzx/zVByT+UWgK\n cWddRrw7hg9+u24Z7zH26rPTkJe6wjH7POxUWqsnNElarX0QkEW/Qky5C12Rdg8vsIMV\n 1n8fFKTPPV/oJ/2Beq/BKqAMd2tJ15XcvwuCAVCIDkBwJ1nVsblEzuVDp1Y4gezlPmZY\n tB6ORsiEAAYhewk+jV4hw24vpU8hWi7Y/OCRCOeuN2yVS6rW2cWU8K9Nl6MzN0Ilc61T\n VOt2vlbZfLq4pj1iDg1d83XuRpdfUzk/rT7SvCu9rxa8iOoIwahmNqNrbVrFKurxa5uz\n hbiQ==","X-Gm-Message-State":"AOJu0Ywh5MJtDPIOlZWJ2UzKRUhFSfQlQz7BOs+QTaSJIi66rU6MMwCq\n qI6f+x/OF8SdQR+737Y86aa5/PKcUIgybnRBzYf/CUlDn6OIqU4rGJAwmdh0cvQmi6EB2r5B1uN\n bwpU=","X-Gm-Gg":"AeBDieskkUKAXF2NN4hCwfdUVS82onA+7e0BiHjVS7iJ6K+sABeoA+KNYc7i5J+zXjr\n xnOyZVCL8x08rMRfwe+HQ0Z3TkGVmzM94iOxx1+oaLDlmAJpJ8ANESkz43dvomL3/IqM+9LFhE9\n yS9ZWEQLRqGsDHfgroUUOzUEBnOEd7oq9Ry7omUYFEJB3Yw1mSRNZILPy7859ZOQMYyKAwzBhTV\n ouEAc48KqETzAej/KlP8c0mfWM5LeqPmkVZYxV8PpVcqHN9igtLJoAe3Jeh8QnHOdyP/PNnYi6U\n rCgpVWEZHr/oQjNu0EnsZtbJj1NsNWVQZH2F21wQ8OXz8djbixsYHjLWjb61o/xAElmTY1P7WdW\n s6ZSSY3nyddX9v5arWcF4kiUTg0Y10LEjgHTsMHkiZQPKoKLMn+VjHRA9HFxRUpZZC8WyuAg8ox\n a/PQbWmaVFktdSPXST+Q==","X-Received":"by 2002:a05:6870:934a:b0:417:5a8c:feba with SMTP id\n 586e51a60fabf-4230fcbd3ebmr3772651fac.12.1775311431385;\n Sat, 04 Apr 2026 07:03:51 -0700 (PDT)","From":"Simon Glass <sjg@chromium.org>","To":"u-boot@lists.denx.de","Cc":"Simon Glass <sjg@chromium.org>,\n Christian Taedcke <christian.taedcke@weidmueller.com>,\n Tom Rini <trini@konsulko.com>","Subject":"[PATCH 01/14] test: Add a helper class to create disk images","Date":"Sat,  4 Apr 2026 08:03:05 -0600","Message-ID":"<20260404140328.3724864-2-sjg@chromium.org>","X-Mailer":"git-send-email 2.43.0","In-Reply-To":"<20260404140328.3724864-1-sjg@chromium.org>","References":"<20260404140328.3724864-1-sjg@chromium.org>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","X-BeenThere":"u-boot@lists.denx.de","X-Mailman-Version":"2.1.39","Precedence":"list","List-Id":"U-Boot discussion <u-boot.lists.denx.de>","List-Unsubscribe":"<https://lists.denx.de/options/u-boot>,\n <mailto:u-boot-request@lists.denx.de?subject=unsubscribe>","List-Archive":"<https://lists.denx.de/pipermail/u-boot/>","List-Post":"<mailto:u-boot@lists.denx.de>","List-Help":"<mailto:u-boot-request@lists.denx.de?subject=help>","List-Subscribe":"<https://lists.denx.de/listinfo/u-boot>,\n <mailto:u-boot-request@lists.denx.de?subject=subscribe>","Errors-To":"u-boot-bounces@lists.denx.de","Sender":"\"U-Boot\" <u-boot-bounces@lists.denx.de>","X-Virus-Scanned":"clamav-milter 0.103.8 at phobos.denx.de","X-Virus-Status":"Clean"},"content":"Provide a way to create disk images which consist of multiple filesystem\nimages.\n\nInclude a cur_dir option to place the disk image in the current\ndirectory rather than in the persistent-data directory. This matches the\nbehaviour of setup_image() which places disk images in source_dir where\nsandbox expects to find them. This flag is a temporary feature and\nshould be removed once all tests are migrated to use the persistent-data\ndirectory instead.\n\nSigned-off-by: Simon Glass <sjg@chromium.org>\n---\n\n test/py/tests/fs_helper.py | 92 ++++++++++++++++++++++++++++++++++++++\n 1 file changed, 92 insertions(+)","diff":"diff --git a/test/py/tests/fs_helper.py b/test/py/tests/fs_helper.py\nindex 800376b1e7d..e323a97b220 100644\n--- a/test/py/tests/fs_helper.py\n+++ b/test/py/tests/fs_helper.py\n@@ -97,6 +97,98 @@ class FsHelper:\n         self.cleanup()\n \n \n+class DiskHelper:\n+    \"\"\"Helper class for creating disk images containing filesytems\n+\n+    Usage:\n+        with DiskHelper(ubman.config, 0, 'mmc') as img, \\\n+                FsHelper(ubman.config, 'ext1', 1, 'mmc') as fsh:\n+            # Write files to fsh.srcdir\n+            ...\n+\n+            # Create the filesystem\n+            fsh.mk_fs()\n+\n+            # Add this filesystem to the disk\n+            img.add_fs(fsh, DiskHelper.VFAT)\n+\n+            # Add more filesystems as needed (add another 'with' clause)\n+            ...\n+\n+            # Get the final disk image\n+            data = img.create()\n+    \"\"\"\n+\n+    # Partition-type codes\n+    VFAT  = 0xc\n+    EXT4  = 0x83\n+\n+    def __init__(self, config, devnum, prefix, cur_dir=False):\n+        \"\"\"Set up a new disk image\n+\n+        Args:\n+            config (u_boot_config): U-Boot configuration\n+            devnum (int): Device number (for filename)\n+            prefix (str): Prefix string of volume's file name\n+            cur_dir (bool): True to put the file in the current directory,\n+                instead of the persistent-data directory\n+        \"\"\"\n+        self.fs_list = []\n+        self.fname = os.path.join('' if cur_dir else config.persistent_data_dir,\n+                                  f'{prefix}{devnum}.img')\n+\n+    def add_fs(self, fs_img, part_type, bootable=False):\n+        \"\"\"Add a new filesystem\n+\n+        Args:\n+            fs_img (FsHelper): Filesystem to add\n+            part_type (DiskHelper.FAT or DiskHelper.EXT4): Partition type\n+            bootable (bool): True to set the 'bootable' flat\n+        \"\"\"\n+        self.fs_list.append([fs_img, part_type, bootable])\n+\n+    def create(self):\n+        \"\"\"Create the disk image\n+\n+        Create an image with a partition table and the filesystems\n+        \"\"\"\n+        spec = ''\n+        pos = 1   # Reserve 1MB for the partition table itself\n+        for fsi, part_type, bootable in self.fs_list:\n+            if spec:\n+                spec += '\\n'\n+            spec += f'type={part_type:x}, size={fsi.size_mb}M, start={pos}M'\n+            if bootable:\n+                spec += ', bootable'\n+            pos += fsi.size_mb\n+\n+        img_size = pos\n+        try:\n+            check_call(f'qemu-img create {self.fname} {img_size}M', shell=True)\n+            check_call(f'printf \"{spec}\" | sfdisk {self.fname}', shell=True)\n+        except CalledProcessError:\n+            os.remove(self.fname)\n+            raise\n+\n+        pos = 1   # Reserve 1MB for the partition table itself\n+        for fsi, part_type, bootable in self.fs_list:\n+            check_call(\n+                f'dd if={fsi.fs_img} of={self.fname} bs=1M seek={pos} conv=notrunc',\n+                shell=True)\n+            pos += fsi.size_mb\n+        return self.fname\n+\n+    def cleanup(self, remove_full_img=False):\n+        \"\"\"Remove created file\"\"\"\n+        os.remove(self.fname)\n+\n+    def __enter__(self):\n+        return self\n+\n+    def __exit__(self, extype, value, traceback):\n+        self.cleanup()\n+\n+\n def mk_fs(config, fs_type, size, prefix, src_dir=None, fs_img=None, quiet=False):\n     \"\"\"Create a file system volume\n \n","prefixes":["01/14"]}