From patchwork Tue Dec 23 01:16:24 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1068 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=1766452628; bh=fI8PC3r5CabF0DBzMTOwKRptHTHUmmSUlBNtlwk/QQI=; 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=OwwQpdCrmFKti639HvJLDlanAaHW4jrdx/f3YijmD3A21M2tzoP/gu5A0xRDGRbnZ YpFg6UTz1TMWjYCGDW27xxPLDQ3XY0mlw6o0QYaxYbL0oYIsaWbPBQXZJZXkk9dxmv oKNkYLDpLSK7dfZ8zYd3apb7SL7pYvoE+uBejMM03prD9ac+gdYMiHuNsXowupRSqC QjU5H5bLo2Omvsa6/MG4++MfktGOPsJhyH/0iyK7hhX9o3Y+6bCUm051nxgjxp8Lse BHUahFzI/M+nh+HGF6sSQU75opKAkMjoX5QjhsIeYmCuHBXbyDUFXfwYbZ6kr1xkTh 2uVbtMVLxQwKA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id EBB4B64DA8 for ; Mon, 22 Dec 2025 18:17:08 -0700 (MST) 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 NRp50NwbaTyc for ; Mon, 22 Dec 2025 18:17:08 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1766452628; bh=fI8PC3r5CabF0DBzMTOwKRptHTHUmmSUlBNtlwk/QQI=; 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=OwwQpdCrmFKti639HvJLDlanAaHW4jrdx/f3YijmD3A21M2tzoP/gu5A0xRDGRbnZ YpFg6UTz1TMWjYCGDW27xxPLDQ3XY0mlw6o0QYaxYbL0oYIsaWbPBQXZJZXkk9dxmv oKNkYLDpLSK7dfZ8zYd3apb7SL7pYvoE+uBejMM03prD9ac+gdYMiHuNsXowupRSqC QjU5H5bLo2Omvsa6/MG4++MfktGOPsJhyH/0iyK7hhX9o3Y+6bCUm051nxgjxp8Lse BHUahFzI/M+nh+HGF6sSQU75opKAkMjoX5QjhsIeYmCuHBXbyDUFXfwYbZ6kr1xkTh 2uVbtMVLxQwKA== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id D9FB064D45 for ; Mon, 22 Dec 2025 18:17:08 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1766452627; bh=pCamRCFj57vR/hslN2+mtp4k/YCCFyFDSm9EqQiBAfU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eKuCA/Xas79I7NVjBv6NJKZPiLU1Y+IvTDDiA6e1eDohyxVe6cTK5xSrjx+a+qXH+ HR5uukS/PAZbcfVXep8Nb1dNj1+vFSto+GU9TBhB1jk3nu+AKmA4mj1IrPyYKKpmFm XKPoGpr2MkZerIzEUuhw4JSNNjs6iAoalvRp1/9J9/n0vqNtxxU4RiBEd7cAkOTkNp 6QrqqldPEAw/Yo+EcR5k82tt53Zm/WB5fV3coyaT5ENsIJGIgUs4LMXbMpy19OTPM0 TWxxrnN78fnna95TAEROOWqhgWPqzpfS0lQ7GqjC/5rin+hVFbWedYVEfkW6dQB+/L mIyqMAYWYBnnA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 737EA64D43; Mon, 22 Dec 2025 18:17:07 -0700 (MST) 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 0TrwdFecyfo6; Mon, 22 Dec 2025 18:17:07 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1766452619; bh=F/vMemnDjpfcrLRppGVo+CCMCDysI6A9bW9lqwZid6M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WHHVlzOXb5GizTSviECHPAVXidcM3K/qPfTHyvl9NEi2Dj/w4cHi0Ihl9q1i34pzi M4Y/GyM7ryqw8wDqWAK5MVEMv5PNKA4bYwWzy2njzjl+6keI/hzOyGS0K9V+DlHySC lsr+YxnrPb8GXBy9HYFrD7ZCSkzG/ax2UZr0DxVqoUr3M3aERrtPky3l1/3AwtyIvG lkTYsffnM4KvjEbRR/XUhxcIG2P3al7VP+SZAayLIkishq3oMHiG7/jYZA/taDKfTs 1dsUC+NFs3la/RA+Vtvfb4OWoD4EZVuQaOolxf4UG0irdcsP3vRcrwasnYD0dRInRA jlEyKM+1yQuCw== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id F1F4D64D45; Mon, 22 Dec 2025 18:16:58 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Mon, 22 Dec 2025 18:16:24 -0700 Message-ID: <20251223011632.380026-10-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251223011632.380026-1-sjg@u-boot.org> References: <20251223011632.380026-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: VVTQRRT2LDK2ZGJTGPLU6TGZE3WEOQFG X-Message-ID-Hash: VVTQRRT2LDK2ZGJTGPLU6TGZE3WEOQFG 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 , Claude X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 09/12] test: fs: Add ext4l filesystem tests 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 initial tests for the ext4l filesystem driver: - fs_test_ext4l_probe_norun: verifies the driver can probe and mount an ext4 filesystem - fs_test_ext4l_msgs_norun: verifies the ext4l_msgs env var causes mount messages to be printed The C tests use UTF_MANUAL flag and accept fs_image argument, following the pattern established by fs_basic.c. The Python wrapper creates an ext4 image and calls the C tests. Co-developed-by: Claude Signed-off-by: Simon Glass --- test/fs/Makefile | 1 + test/fs/ext4l.c | 81 +++++++++++++++++++++++++++++ test/py/tests/test_fs/test_ext4l.py | 59 +++++++++++++++++++++ 3 files changed, 141 insertions(+) create mode 100644 test/fs/ext4l.c create mode 100644 test/py/tests/test_fs/test_ext4l.py diff --git a/test/fs/Makefile b/test/fs/Makefile index 5899be8e667..a8fd1227a1d 100644 --- a/test/fs/Makefile +++ b/test/fs/Makefile @@ -1,3 +1,4 @@ # SPDX-License-Identifier: GPL-2.0+ obj-y += fs_basic.o +obj-$(CONFIG_FS_EXT4L) += ext4l.o diff --git a/test/fs/ext4l.c b/test/fs/ext4l.c new file mode 100644 index 00000000000..e566c9e97b0 --- /dev/null +++ b/test/fs/ext4l.c @@ -0,0 +1,81 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Tests for ext4l filesystem (Linux ext4 port) + * + * Copyright 2025 Canonical Ltd + * Written by Simon Glass + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define EXT4L_ARG_IMAGE 0 /* fs_image: path to filesystem image */ + +/** + * fs_test_ext4l_probe_norun() - Test probing an ext4l filesystem + * + * This test verifies that the ext4l driver can successfully probe and + * mount an ext4 filesystem image. + * + * Arguments: + * fs_image: Path to the ext4 filesystem image + */ +static int fs_test_ext4l_probe_norun(struct unit_test_state *uts) +{ + const char *fs_image = ut_str(EXT4L_ARG_IMAGE); + + ut_assertnonnull(fs_image); + ut_assertok(run_commandf("host bind 0 %s", fs_image)); + ut_assertok(fs_set_blk_dev("host", "0", FS_TYPE_ANY)); + + return 0; +} +FS_TEST_ARGS(fs_test_ext4l_probe_norun, UTF_SCAN_FDT | UTF_CONSOLE | UTF_MANUAL, + { "fs_image", UT_ARG_STR }); + +/** + * fs_test_ext4l_msgs_norun() - Test ext4l_msgs env var output + * + * This test verifies that setting ext4l_msgs=y causes mount messages + * to be printed when probing an ext4 filesystem. + * + * Arguments: + * fs_image: Path to the ext4 filesystem image + */ +static int fs_test_ext4l_msgs_norun(struct unit_test_state *uts) +{ + const char *fs_image = ut_str(EXT4L_ARG_IMAGE); + char uuid_str[UUID_STR_LEN + 1]; + u8 uuid[16]; + + ut_assertnonnull(fs_image); + ut_assertok(env_set("ext4l_msgs", "y")); + console_record_reset_enable(); + ut_assertok(run_commandf("host bind 0 %s", fs_image)); + ut_assertok(fs_set_blk_dev("host", "0", FS_TYPE_ANY)); + + /* Get the UUID and clear the env var now we have the output */ + ut_assertok(ext4l_get_uuid(uuid)); + uuid_bin_to_str(uuid, uuid_str, UUID_STR_FORMAT_STD); + ut_assertok(env_set("ext4l_msgs", NULL)); + + /* + * Check messages. The probe test runs first and doesn't unmount, + * so the journal needs recovery. Verify both messages. + */ + ut_assert_nextline("EXT4-fs (ext4l_mmc0): recovery complete"); + ut_assert_nextline("EXT4-fs (ext4l_mmc0): mounted filesystem %s r/w with ordered data mode. Quota mode: disabled.", + uuid_str); + ut_assert_console_end(); + + return 0; +} +FS_TEST_ARGS(fs_test_ext4l_msgs_norun, UTF_SCAN_FDT | UTF_CONSOLE | UTF_MANUAL, + { "fs_image", UT_ARG_STR }); diff --git a/test/py/tests/test_fs/test_ext4l.py b/test/py/tests/test_fs/test_ext4l.py new file mode 100644 index 00000000000..3b206293cbc --- /dev/null +++ b/test/py/tests/test_fs/test_ext4l.py @@ -0,0 +1,59 @@ +# SPDX-License-Identifier: GPL-2.0+ +# Copyright 2025 Canonical Ltd +# Written by Simon Glass +# +# Test for ext4l filesystem driver + +""" +Test ext4l filesystem probing via C unit test. +""" + +import os +from subprocess import CalledProcessError, check_call + +import pytest + + +@pytest.mark.boardspec('sandbox') +class TestExt4l: + """Test ext4l filesystem operations.""" + + @pytest.fixture(scope='class') + def ext4_image(self, u_boot_config): + """Create an ext4 filesystem image for testing. + + Args: + u_boot_config (u_boot_config): U-Boot configuration. + + Yields: + str: Path to the ext4 image file. + """ + image_path = os.path.join(u_boot_config.persistent_data_dir, + 'ext4l_test.img') + try: + # Create a 64MB ext4 image + check_call(f'dd if=/dev/zero of={image_path} bs=1M count=64 2>/dev/null', + shell=True) + check_call(f'mkfs.ext4 -q {image_path}', shell=True) + except CalledProcessError: + pytest.skip('Failed to create ext4 image') + + yield image_path + + # Cleanup + if os.path.exists(image_path): + os.remove(image_path) + + def test_probe(self, ubman, ext4_image): + """Test that ext4l can probe an ext4 filesystem.""" + with ubman.log.section('Test ext4l probe'): + output = ubman.run_command( + f'ut -f fs fs_test_ext4l_probe_norun fs_image={ext4_image}') + assert 'failures: 0' in output + + def test_msgs(self, ubman, ext4_image): + """Test that ext4l_msgs env var produces mount messages.""" + with ubman.log.section('Test ext4l msgs'): + output = ubman.run_command( + f'ut -f fs fs_test_ext4l_msgs_norun fs_image={ext4_image}') + assert 'failures: 0' in output