From patchwork Sat Apr 11 00:36:40 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2163 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1775867838; bh=zCmsleLP/YuCYVsRLCm2CqlppZYFQI4BnNqO2ntC0MY=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=TLyfH4EOsMXYOffCn1vUzPEP/elY2w9W26/k7XG5La10FAUlGv3YpiOAs1uPSRatE ZUjdKNRhEWg7dC4TJAc2T6/PS/fU2HqhANjqsciKLn6Mmmx6OweIP4mDY5o1VSaq/L 6fcOFefE8vNiPUk7btmaDRL//SFOKjqI09TbW4k7Dv8TTTz9bFcZTKeSai982ydmaA iyTl3/HecCj2F76fXSmgnvNSy5emOPoRTuBSnr+wbJJ4c4/bxGDq9GA0aIWhrXzcMP xxonzH2Pi2DubTWiKPRtkDCm+NNDwgQ7eR3/O2wcSj8S5OSTeGYUAiMkBDwZToCcCF iA/DE5LrXuJxQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id E1F616A430 for ; Fri, 10 Apr 2026 18:37:18 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id sdPqKtJNRJfo for ; Fri, 10 Apr 2026 18:37:18 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1775867838; bh=zCmsleLP/YuCYVsRLCm2CqlppZYFQI4BnNqO2ntC0MY=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=TLyfH4EOsMXYOffCn1vUzPEP/elY2w9W26/k7XG5La10FAUlGv3YpiOAs1uPSRatE ZUjdKNRhEWg7dC4TJAc2T6/PS/fU2HqhANjqsciKLn6Mmmx6OweIP4mDY5o1VSaq/L 6fcOFefE8vNiPUk7btmaDRL//SFOKjqI09TbW4k7Dv8TTTz9bFcZTKeSai982ydmaA iyTl3/HecCj2F76fXSmgnvNSy5emOPoRTuBSnr+wbJJ4c4/bxGDq9GA0aIWhrXzcMP xxonzH2Pi2DubTWiKPRtkDCm+NNDwgQ7eR3/O2wcSj8S5OSTeGYUAiMkBDwZToCcCF iA/DE5LrXuJxQ== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 04F666A434 for ; Fri, 10 Apr 2026 18:37:18 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1775867834; bh=Yp5JjVzRkkJKQWKmdhGPnugNF64CmJSEtwUzh2JQpYU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EG0XcsJkyeTk+PdwL14w9YhwTU38RwAo1jcyqk8rxLMkYyqyl6UYipi3hEIqzvI8B lEo/O1VxXFyGe3PCTX5YB3Yxaj/kWv14w2c1Y5vtf6tOt5qd+lt0NJ1DlAaxLLeSQM Hrp5X9pBK7JrppQrnrS5fFbIC50/HM2/fdTvUBMBXj2UR5L7C3Ed9VTe9SH8dmkLMz ad+5v/R0QA+t3Y11P9OENutbZgQpCur0Fqwwq5HR0Y3X2WNzskzROVwvP+I+PGhP8/ +w50SN6nqJpLbynY5rEQpvho9vpRbigBpPUVyneOKvN3R4Ysg9jDv3lI5yHL4mfVtO CZ9sj92rRV+JQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 6716C6A429; Fri, 10 Apr 2026 18:37:14 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id EKE14LwlpHFj; Fri, 10 Apr 2026 18:37:14 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1775867831; bh=UAkPq1wLVvp8oavW4Q7dSBQdVQC5DsAPPa3qSFcHAR4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nE7B1bcLyYVYbo2619Ryd4eQ0dDnRVLHmdEc+ipKEfS0gO0T4qLWFGDY3/K0G+1rI 1NqFmekSpTQMK95AkquFKi1eHkGJwheV4dD0o5TmQAq548lWpjb+S2TAEjeuX01Gtr tk8gFL3YoeIDWF3WzibHyfaN6tokcpOAcnZjDaJRRkp81HcYLBVnDbx7ft298uie2y VgeZSceyigwclljwSEMLhs1p3wmSC40edIEBPTunXKzZUtwWLYIyjWPWEt4+Ijcznm c2Kxvxe9Pdl+ycKQXa+wNukkQkQ3623Nb7rZ2yCG53s8VyQdh/s2RjFkV1b0bSEPRn uxFUxak0xcA/Q== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 7D8D56A42B; Fri, 10 Apr 2026 18:37:11 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Fri, 10 Apr 2026 18:36:40 -0600 Message-ID: <20260411003647.2592586-9-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260411003647.2592586-1-sjg@u-boot.org> References: <20260411003647.2592586-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: XPDXGV553EHQJZP6FKBBFT5ELNQZBAGB X-Message-ID-Hash: XPDXGV553EHQJZP6FKBBFT5ELNQZBAGB X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Simon Glass X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 8/8] ext4l: Add dual-mount test List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass Add a test that mounts two different ext4 images simultaneously via VFS and reads a file from each, verifying they return different content. Signed-off-by: Simon Glass --- test/fs/ext4l.c | 82 +++++++++++++++++++++++++++++ test/py/tests/test_fs/test_ext4l.py | 34 ++++++++++++ 2 files changed, 116 insertions(+) diff --git a/test/fs/ext4l.c b/test/fs/ext4l.c index 7548c3049bb..9e4c8823f2f 100644 --- a/test/fs/ext4l.c +++ b/test/fs/ext4l.c @@ -6,13 +6,19 @@ * Written by Simon Glass */ +#include #include +#include #include #include #include #include #include +#include +#include #include +#include +#include #include #include #include @@ -650,3 +656,79 @@ static int fs_test_ext4l_rename_norun(struct unit_test_state *uts) } FS_TEST_ARGS(fs_test_ext4l_rename_norun, UTF_SCAN_FDT | UTF_CONSOLE | UTF_MANUAL, { "fs_image", UT_ARG_STR }); + +#define EXT4L_ARG_IMAGE_A 0 +#define EXT4L_ARG_IMAGE_B 1 +#define BUF_ADDR 0x10000 + +/** + * fs_test_ext4l_dual_mount_norun() - Test two ext4l mounts simultaneously + * + * Mount two different ext4 images at /mnt and /mnt2, read a file from + * each, and verify they return different content. + * + * Arguments: + * fs_image_a: Path to first ext4 filesystem image (contains "alpha\n") + * fs_image_b: Path to second ext4 filesystem image (contains "bravo\n") + */ +static int fs_test_ext4l_dual_mount_norun(struct unit_test_state *uts) +{ + const char *image_a = ut_str(EXT4L_ARG_IMAGE_A); + const char *image_b = ut_str(EXT4L_ARG_IMAGE_B); + struct udevice *dev_a, *dev_b, *blk; + struct blk_desc *desc; + char *buf; + + ut_assertok(vfs_init()); + + /* Mount first image at /mnt */ + ut_assertok(host_create_device("ext4a", true, DEFAULT_BLKSZ, &dev_a)); + ut_assertok(host_attach_file(dev_a, image_a)); + ut_assertok(blk_get_from_parent(dev_a, &blk)); + ut_assertok(device_probe(blk)); + desc = dev_get_uclass_plat(blk); + ut_assertok(run_commandf("mount host %x:0 /mnt", desc->devnum)); + ut_assert_console_end(); + + /* Mount second image at /mnt2 */ + ut_assertok(host_create_device("ext4b", true, DEFAULT_BLKSZ, &dev_b)); + ut_assertok(host_attach_file(dev_b, image_b)); + ut_assertok(blk_get_from_parent(dev_b, &blk)); + ut_assertok(device_probe(blk)); + desc = dev_get_uclass_plat(blk); + ut_assertok(run_commandf("mount host %x:0 /mnt2", desc->devnum)); + ut_assert_console_end(); + + /* Read from first mount */ + buf = map_sysmem(BUF_ADDR, 0x100); + memset(buf, '\0', 0x100); + ut_assertok(run_commandf("load %x /mnt/id.txt", BUF_ADDR)); + ut_assert_nextline("6 bytes read"); + ut_assert_console_end(); + ut_asserteq_str("alpha\n", buf); + + /* Read from second mount */ + memset(buf, '\0', 0x100); + ut_assertok(run_commandf("load %x /mnt2/id.txt", BUF_ADDR)); + ut_assert_nextline("6 bytes read"); + ut_assert_console_end(); + ut_asserteq_str("bravo\n", buf); + unmap_sysmem(buf); + + /* Unmount both */ + ut_assertok(run_command("umount /mnt2", 0)); + ut_assert_console_end(); + ut_assertok(run_command("umount /mnt", 0)); + ut_assert_console_end(); + + ut_assertok(host_detach_file(dev_b)); + ut_assertok(device_unbind(dev_b)); + ut_assertok(host_detach_file(dev_a)); + ut_assertok(device_unbind(dev_a)); + + return 0; +} +FS_TEST_ARGS(fs_test_ext4l_dual_mount_norun, + UTF_SCAN_FDT | UTF_CONSOLE | UTF_MANUAL, + { "fs_image_a", UT_ARG_STR }, + { "fs_image_b", UT_ARG_STR }); diff --git a/test/py/tests/test_fs/test_ext4l.py b/test/py/tests/test_fs/test_ext4l.py index eb332d1b154..e029539572f 100644 --- a/test/py/tests/test_fs/test_ext4l.py +++ b/test/py/tests/test_fs/test_ext4l.py @@ -14,6 +14,8 @@ from tempfile import NamedTemporaryFile import pytest +from tests.fs_helper import FsHelper + @pytest.mark.buildconfigspec('sandbox') @pytest.mark.buildconfigspec('fs_ext4l') @@ -146,3 +148,35 @@ class TestExt4l: """Test that ext4l can rename files and directories.""" with ubman.log.section('Test ext4l rename'): ubman.run_ut('fs', 'fs_test_ext4l_rename', fs_image=ext4_image) + + @pytest.fixture(scope='class') + def dual_images(self, u_boot_config): + """Create two ext4 images with different content. + + Image A contains id.txt with "alpha\\n". + Image B contains id.txt with "bravo\\n". + + Yields: + tuple: (path_a, path_b) paths to the two images + """ + helpers = [] + for label, content in [('a', 'alpha'), ('b', 'bravo')]: + fsh = FsHelper(u_boot_config, 'ext4', 64, f'dual_{label}') + fsh.setup() + with open(os.path.join(fsh.srcdir, 'id.txt'), 'w') as f: + f.write(content + '\n') + fsh.mk_fs() + helpers.append(fsh) + + yield tuple(fsh.fs_img for fsh in helpers) + + for fsh in helpers: + fsh.cleanup() + + @pytest.mark.buildconfigspec('cmd_vfs') + def test_dual_mount(self, ubman, dual_images): + """Test that two ext4l filesystems can be mounted simultaneously.""" + image_a, image_b = dual_images + with ubman.log.section('Test ext4l dual mount'): + ubman.run_ut('fs', 'fs_test_ext4l_dual_mount', + fs_image_a=image_a, fs_image_b=image_b)