{"id":2222499,"url":"http://patchwork.ozlabs.org/api/1.2/patches/2222499/?format=json","web_url":"http://patchwork.ozlabs.org/project/uboot/patch/20260412111958.943933-12-sjg@chromium.org/","project":{"id":18,"url":"http://patchwork.ozlabs.org/api/1.2/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":"<20260412111958.943933-12-sjg@chromium.org>","list_archive_url":null,"date":"2026-04-12T11:19:48","name":"[v2,11/12] test: fs: add C-based filesystem tests","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"f00052a96dac48b1becc209690240d1ed725367d","submitter":{"id":6170,"url":"http://patchwork.ozlabs.org/api/1.2/people/6170/?format=json","name":"Simon Glass","email":"sjg@chromium.org"},"delegate":{"id":3651,"url":"http://patchwork.ozlabs.org/api/1.2/users/3651/?format=json","username":"trini","first_name":"Tom","last_name":"Rini","email":"trini@ti.com"},"mbox":"http://patchwork.ozlabs.org/project/uboot/patch/20260412111958.943933-12-sjg@chromium.org/mbox/","series":[{"id":499596,"url":"http://patchwork.ozlabs.org/api/1.2/series/499596/?format=json","web_url":"http://patchwork.ozlabs.org/project/uboot/list/?series=499596","date":"2026-04-12T11:19:37","name":"test: Add support for passing arguments to C unit tests","version":2,"mbox":"http://patchwork.ozlabs.org/series/499596/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/2222499/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2222499/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=g783hrTQ;\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=\"g783hrTQ\";\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 4ftpB122LCz1yCx\n\tfor <incoming@patchwork.ozlabs.org>; Sun, 12 Apr 2026 21:25:29 +1000 (AEST)","from h2850616.stratoserver.net (localhost [IPv6:::1])\n\tby phobos.denx.de (Postfix) with ESMTP id 9672D84119;\n\tSun, 12 Apr 2026 13:24:37 +0200 (CEST)","by phobos.denx.de (Postfix, from userid 109)\n id B8BC88421E; Sun, 12 Apr 2026 13:24:36 +0200 (CEST)","from mail-oo1-xc2f.google.com (mail-oo1-xc2f.google.com\n [IPv6:2607:f8b0:4864:20::c2f])\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 326E984248\n for <u-boot@lists.denx.de>; Sun, 12 Apr 2026 13:24:34 +0200 (CEST)","by mail-oo1-xc2f.google.com with SMTP id\n 006d021491bc7-66f747175d8so1634986eaf.0\n for <u-boot@lists.denx.de>; Sun, 12 Apr 2026 04:24:34 -0700 (PDT)","from chromium.org ([73.34.74.121]) by smtp.gmail.com with ESMTPSA id\n 586e51a60fabf-423dd395606sm6622071fac.1.2026.04.12.04.24.29\n (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n Sun, 12 Apr 2026 04:24:30 -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=1775993072; x=1776597872; 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=LVsX94WfBNFZ9dfeOCiJ3LsiwBs8OAFcDzLzrYwOCjA=;\n b=g783hrTQEMx2JVfPVVRPP/KsSCf5JSHNBikg3kh7Gq2emNkVUgED7TBf6ZtgfzUOLr\n BjXVMN6e6binsvbX6/izo5pcuZzZNXovyLwDGZibfHja28ftyA+AXQpXHwD+RCTbotpD\n KqIL19ZOY0PWb/LWaubo4qXr/2jxdfgF+87ek=","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20251104; t=1775993072; x=1776597872;\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=LVsX94WfBNFZ9dfeOCiJ3LsiwBs8OAFcDzLzrYwOCjA=;\n b=LmyEgrGk9v4j7oqV6FOspL3sn+J9iF5HO4Yzpwh/8aiY2a2qBuU+xTtL1mP7lcrIDM\n teBWrV2jQelM8S9Vc35XLGS/fcRH/5W/yr46EtaIKbZ2z8LX7M4BhcwRxTKyyu2zotF0\n A6JkrPd91Q3NFmOmMFDtv9FH5MSK7qlWazPHrl5v6gBjo9W6YLd2Nkt8IvP2A8yaMoZQ\n ABLIhth2PXO3+GryQ+k8pPYh/FxXx7gUj0knMosMDZHttDlL7bOUAD4UXgbue4ODo9xO\n zp8DR91WVMrStKeuXJ1dy+eAwtP9jCHfS3yyUJ3QSfpJUPyGaT2BuB1XjJCiLKebSzZF\n 7k6g==","X-Gm-Message-State":"AOJu0YzgJLQBilCJSGduKTDlUfWLkXmvWcpXSCQOSATBLShhQQR03e16\n UqnEfy+IhD3i+/fvM++zt8mSxvTaGRf+Ld7LbBNnA9OGNLXBICJcjsCvPXS2i5rZd8Eb8QzhLVs\n pOeLKRg==","X-Gm-Gg":"AeBDievxb5Igxz9wxlKZTId5/J6B4l+Pb5r7ASIY5bad+G10j7b1qUnN5Y82gVX1Cwy\n ZMy3wZsJKhTCl0/jevmqjs8pgowP+PVwziIbWkGBC6rjkc5+xjb3wFJsLLVCJL9XV917QvrLDFl\n 6omaccRdH8Y7OglPT4bPIvdPh/0qBMJM1Dkd8xK3yT9QqEuGPki9tXdGChi3hQhml5TzPDcG18+\n 1hNjRBdXzTozGUbdk1b6BDrnhDqaCs64J/gySNrCtfY+7JC6wgaj9nqIM7t4gs7chDwnYUOr4w0\n bGXCMXW+POaZvvQOBUEzPBs/VSfDFTgCqGCdLjV2YHRohuOg/Et9nq7CW+6rSSBWa31dJ59x+b5\n EUWVAKyvLUr5PGfeHAnMWwDnYqQHeNPvNpPyjYLy0xzImgqTnpyhwU0phvFCYjfmsGSrdGWbK1Z\n 6HIFsiP2CoK9wcm/Ogrg==","X-Received":"by 2002:a05:6820:134c:b0:67e:29a8:7fd0 with SMTP id\n 006d021491bc7-68be8fd0346mr4511743eaf.63.1775993072179;\n Sun, 12 Apr 2026 04:24:32 -0700 (PDT)","From":"Simon Glass <sjg@chromium.org>","To":"u-boot@lists.denx.de","Cc":"Tom Rini <trini@konsulko.com>, Heinrich Schuchardt <xypron.glpk@gmx.de>,\n Simon Glass <sjg@chromium.org>,\n Ilias Apalodimas <ilias.apalodimas@linaro.org>","Subject":"[PATCH v2 11/12] test: fs: add C-based filesystem tests","Date":"Sun, 12 Apr 2026 05:19:48 -0600","Message-ID":"<20260412111958.943933-12-sjg@chromium.org>","X-Mailer":"git-send-email 2.43.0","In-Reply-To":"<20260412111958.943933-1-sjg@chromium.org>","References":"<20260412111958.943933-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":"Add C implementations of filesystem tests that can be called via\nthe 'ut fs' command. These tests use UTF_MANUAL flag since they require\nexternal setup, i.e. creation of filesystem images.\n\nThis covers the existing TestFsBasic tests.\n\nThe tests use typed arguments (fs_type, fs_image, md5 values) passed\nvia the command line.\n\nAdd a few helpers to make the code easier to read.\n\nSigned-off-by: Simon Glass <sjg@chromium.org>\n---\n\n(no changes since v1)\n\n include/test/fs.h  |  39 +++++\n test/Makefile      |   1 +\n test/cmd_ut.c      |   2 +\n test/fs/Makefile   |   3 +\n test/fs/fs_basic.c | 407 +++++++++++++++++++++++++++++++++++++++++++++\n 5 files changed, 452 insertions(+)\n create mode 100644 include/test/fs.h\n create mode 100644 test/fs/Makefile\n create mode 100644 test/fs/fs_basic.c","diff":"diff --git a/include/test/fs.h b/include/test/fs.h\nnew file mode 100644\nindex 00000000000..7fdb8d70451\n--- /dev/null\n+++ b/include/test/fs.h\n@@ -0,0 +1,39 @@\n+/* SPDX-License-Identifier: GPL-2.0+ */\n+/*\n+ * Copyright 2026 Canonical Ltd\n+ */\n+\n+#ifndef __TEST_FS_H\n+#define __TEST_FS_H\n+\n+#include <test/test.h>\n+#include <test/ut.h>\n+\n+/**\n+ * FS_TEST() - Define a new filesystem test\n+ *\n+ * @name:\tName of test function\n+ * @flags:\tFlags for the test (see enum ut_flags)\n+ */\n+#define FS_TEST(_name, _flags)\tUNIT_TEST(_name, UTF_DM | (_flags), fs)\n+\n+/**\n+ * FS_TEST_ARGS() - Define a filesystem test with inline arguments\n+ *\n+ * Like FS_TEST() but for tests that take arguments.\n+ * The test can access arguments via uts->args[].\n+ * The NULL terminator is added automatically.\n+ *\n+ * Example:\n+ *   FS_TEST_ARGS(my_test, UTF_MANUAL,\n+ *       { \"fs_type\", UT_ARG_STR },\n+ *       { \"fs_image\", UT_ARG_STR });\n+ *\n+ * @name:\tName of test function\n+ * @flags:\tFlags for the test (see enum ut_flags)\n+ * @...:\tArgument definitions (struct ut_arg_def initializers)\n+ */\n+#define FS_TEST_ARGS(_name, _flags, ...) \\\n+\tUNIT_TEST_ARGS(_name, UTF_DM | (_flags), fs, __VA_ARGS__)\n+\n+#endif /* __TEST_FS_H */\ndiff --git a/test/Makefile b/test/Makefile\nindex 5676bd35963..02ded045995 100644\n--- a/test/Makefile\n+++ b/test/Makefile\n@@ -22,6 +22,7 @@ obj-y += boot/\n obj-y += common/\n obj-$(CONFIG_UT_ENV) += env/\n obj-$(CONFIG_UT_FDT_OVERLAY) += fdt_overlay/\n+obj-$(CONFIG_SANDBOX) += fs/\n obj-y += log/\n else\n obj-$(CONFIG_SPL_UT_LOAD) += image/\ndiff --git a/test/cmd_ut.c b/test/cmd_ut.c\nindex 9d36bd5dc87..827fcbc9fcb 100644\n--- a/test/cmd_ut.c\n+++ b/test/cmd_ut.c\n@@ -60,6 +60,7 @@ SUITE_DECL(exit);\n SUITE_DECL(fdt);\n SUITE_DECL(fdt_overlay);\n SUITE_DECL(font);\n+SUITE_DECL(fs);\n SUITE_DECL(hush);\n SUITE_DECL(lib);\n SUITE_DECL(loadm);\n@@ -87,6 +88,7 @@ static struct suite suites[] = {\n \tSUITE(fdt, \"fdt command\"),\n \tSUITE(fdt_overlay, \"device tree overlays\"),\n \tSUITE(font, \"font command\"),\n+\tSUITE(fs, \"filesystem tests\"),\n \tSUITE(hush, \"hush behaviour\"),\n \tSUITE(lib, \"library functions\"),\n \tSUITE(loadm, \"loadm command parameters and loading memory blob\"),\ndiff --git a/test/fs/Makefile b/test/fs/Makefile\nnew file mode 100644\nindex 00000000000..5899be8e667\n--- /dev/null\n+++ b/test/fs/Makefile\n@@ -0,0 +1,3 @@\n+# SPDX-License-Identifier: GPL-2.0+\n+\n+obj-y += fs_basic.o\ndiff --git a/test/fs/fs_basic.c b/test/fs/fs_basic.c\nnew file mode 100644\nindex 00000000000..a6f1e056f5b\n--- /dev/null\n+++ b/test/fs/fs_basic.c\n@@ -0,0 +1,407 @@\n+// SPDX-License-Identifier: GPL-2.0+\n+/*\n+ * Basic filesystem tests - C implementation for Python wrapper\n+ *\n+ * These tests are marked UTF_MANUAL and are intended to be called from\n+ * test_basic.py which sets up the filesystem image and expected values.\n+ *\n+ * Copyright 2026 Canonical Ltd\n+ */\n+\n+#include <command.h>\n+#include <dm.h>\n+#include <env.h>\n+#include <fs.h>\n+#include <hexdump.h>\n+#include <image.h>\n+#include <linux/sizes.h>\n+#include <mapmem.h>\n+#include <test/fs.h>\n+#include <test/test.h>\n+#include <test/ut.h>\n+#include <u-boot/md5.h>\n+\n+/* Test constants matching fstest_defs.py */\n+#define ADDR\t0x01000008\n+\n+/*\n+ * Common argument indices. Each test declares only the arguments it needs,\n+ * so indices 2+ vary per test - see comments in each test.\n+ */\n+#define FS_ARG_TYPE\t0\t/* fs_type: ext4, fat, exfat, fs_generic */\n+#define FS_ARG_IMAGE\t1\t/* fs_image: path to filesystem image */\n+\n+/* Common arguments for all filesystem tests (indices 0 and 1) */\n+#define COMMON_ARGS \\\n+\t{ \"fs_type\", UT_ARG_STR }, \\\n+\t{ \"fs_image\", UT_ARG_STR }\n+\n+/**\n+ * get_fs_type(uts) - Get filesystem type enum from test argument\n+ *\n+ * Reads the fs_type argument and returns the appropriate FS_TYPE_* enum value.\n+ *\n+ * Return: filesystem type enum\n+ */\n+static int get_fs_type(struct unit_test_state *uts)\n+{\n+\tconst char *fs_type = ut_str(FS_ARG_TYPE);\n+\n+\tif (!fs_type)\n+\t\treturn FS_TYPE_ANY;\n+\n+\tif (!strcmp(fs_type, \"ext4\"))\n+\t\treturn FS_TYPE_EXT;\n+\tif (!strcmp(fs_type, \"fat\"))\n+\t\treturn FS_TYPE_FAT;\n+\tif (!strcmp(fs_type, \"exfat\"))\n+\t\treturn FS_TYPE_EXFAT;\n+\n+\t/* fs_generic uses FS_TYPE_ANY */\n+\treturn FS_TYPE_ANY;\n+}\n+\n+/* Set up the host filesystem block device */\n+static int set_fs(struct unit_test_state *uts)\n+{\n+\treturn fs_set_blk_dev(\"host\", \"0:0\", get_fs_type(uts));\n+}\n+\n+/* Build a path by prepending \"/\" to the leaf filename, with optional suffix */\n+static const char *getpath(struct unit_test_state *uts, const char *leaf,\n+\t\t\t   const char *suffix)\n+{\n+\tsnprintf(uts->priv, sizeof(uts->priv), \"/%s%s\", leaf, suffix ?: \"\");\n+\n+\treturn uts->priv;\n+}\n+\n+/**\n+ * prep_fs() - Prepare filesystem for testing\n+ *\n+ * Binds the fs_image argument as host device 0, sets up the block device,\n+ * and optionally returns a zeroed buffer.\n+ *\n+ * @uts: Unit test state\n+ * @len: Length of buffer to allocate and zero, or 0 for none\n+ * @bufp: Returns pointer to zeroed buffer, or NULL if @len is 0\n+ * Return: 0 on success, negative on error\n+ */\n+static int prep_fs(struct unit_test_state *uts, uint len, void **bufp)\n+{\n+\tconst char *fs_image = ut_str(FS_ARG_IMAGE);\n+\n+\tut_assertnonnull(fs_image);\n+\tut_assertok(run_commandf(\"host bind 0 %s\", fs_image));\n+\tut_assertok(set_fs(uts));\n+\n+\tif (len) {\n+\t\t*bufp = map_sysmem(ADDR, len);\n+\t\tmemset(*bufp, '\\0', len);\n+\t}\n+\n+\treturn 0;\n+}\n+\n+/**\n+ * fs_write_supported(uts) - Check if write is supported for current fs type\n+ *\n+ * Reads the fs_type argument and checks if write support is enabled\n+ * for that filesystem type.\n+ *\n+ * Return: true if write is supported, false otherwise\n+ */\n+static bool fs_write_supported(struct unit_test_state *uts)\n+{\n+\tconst char *fs_type = ut_str(FS_ARG_TYPE);\n+\n+\tif (!fs_type)\n+\t\treturn false;\n+\n+\tif (!strcmp(fs_type, \"ext4\"))\n+\t\treturn IS_ENABLED(CONFIG_EXT4_WRITE);\n+\tif (!strcmp(fs_type, \"fat\"))\n+\t\treturn IS_ENABLED(CONFIG_CMD_FAT_WRITE);\n+\n+\t/* fs_generic and exfat use generic write which is always available */\n+\treturn true;\n+}\n+\n+/**\n+ * verify_md5() - Calculate MD5 of buffer and verify against expected\n+ *\n+ * Uses arg 3 (md5val) as the expected MD5 hex string.\n+ *\n+ * @uts: Unit test state\n+ * @buf: Buffer to calculate MD5 of\n+ * @len: Length of buffer\n+ *\n+ * Return: 0 if MD5 matches, -EINVAL otherwise\n+ */\n+static int verify_md5(struct unit_test_state *uts, const void *buf, size_t len)\n+{\n+\tu8 digest[MD5_SUM_LEN], expected[MD5_SUM_LEN];\n+\tconst char *expected_hex = ut_str(3);\n+\n+\tut_assertok(hex2bin(expected, expected_hex, MD5_SUM_LEN));\n+\n+\tmd5_wd(buf, len, digest, CHUNKSZ_MD5);\n+\tut_asserteq_mem(expected, digest, MD5_SUM_LEN);\n+\n+\treturn 0;\n+}\n+\n+/* Test Case 1 - ls command, listing root directory and invalid directory */\n+static int fs_test_ls_norun(struct unit_test_state *uts)\n+{\n+\tconst char *small = ut_str(2);\n+\tconst char *big = ut_str(3);\n+\tstruct fs_dir_stream *dirs;\n+\tstruct fs_dirent *dent;\n+\tbool found_big = false, found_small = false, found_subdir = false;\n+\n+\tut_assertok(prep_fs(uts, 0, NULL));\n+\n+\t/* Test listing root directory */\n+\tdirs = fs_opendir(\"/\");\n+\tut_assertnonnull(dirs);\n+\n+\twhile ((dent = fs_readdir(dirs))) {\n+\t\tif (!strcmp(dent->name, big)) {\n+\t\t\tfound_big = true;\n+\t\t\tut_asserteq(FS_DT_REG, dent->type);\n+\t\t} else if (!strcmp(dent->name, small)) {\n+\t\t\tfound_small = true;\n+\t\t\tut_asserteq(FS_DT_REG, dent->type);\n+\t\t} else if (!strcmp(dent->name, \"SUBDIR\")) {\n+\t\t\tfound_subdir = true;\n+\t\t\tut_asserteq(FS_DT_DIR, dent->type);\n+\t\t}\n+\t}\n+\tfs_closedir(dirs);\n+\n+\tut_assert(found_big);\n+\tut_assert(found_small);\n+\tut_assert(found_subdir);\n+\n+\t/* Test invalid directory returns error */\n+\tut_assertok(set_fs(uts));\n+\tdirs = fs_opendir(\"/invalid_d\");\n+\tut_assertnull(dirs);\n+\n+\t/* Test file exists */\n+\tut_assertok(set_fs(uts));\n+\tut_assert(fs_exists(small));\n+\n+\t/* Test non-existent file */\n+\tut_assertok(set_fs(uts));\n+\tut_assert(!fs_exists(\"nonexistent.file\"));\n+\n+\treturn 0;\n+}\n+FS_TEST_ARGS(fs_test_ls_norun, UTF_SCAN_FDT | UTF_CONSOLE | UTF_MANUAL,\n+\t     COMMON_ARGS, { \"small\", UT_ARG_STR }, { \"big\", UT_ARG_STR });\n+\n+/* Test Case 2 - size command for small file (1MB) */\n+static int fs_test_size_small_norun(struct unit_test_state *uts)\n+{\n+\tconst char *small = ut_str(2);\n+\tloff_t size;\n+\n+\tut_assertok(prep_fs(uts, 0, NULL));\n+\tut_assertok(fs_size(getpath(uts, small, NULL), &size));\n+\tut_asserteq(SZ_1M, size);\n+\n+\t/* Test size via path with '..' */\n+\tut_assertok(set_fs(uts));\n+\tsnprintf(uts->priv, sizeof(uts->priv), \"/SUBDIR/../%s\", small);\n+\tut_assertok(fs_size(uts->priv, &size));\n+\tut_asserteq(SZ_1M, size);\n+\n+\treturn 0;\n+}\n+FS_TEST_ARGS(fs_test_size_small_norun, UTF_SCAN_FDT | UTF_MANUAL,\n+\t     COMMON_ARGS, { \"small\", UT_ARG_STR });\n+\n+/* Test Case 3 - size command for large file (2500 MiB) */\n+static int fs_test_size_big_norun(struct unit_test_state *uts)\n+{\n+\tconst char *big = ut_str(2);\n+\tloff_t size;\n+\n+\tut_assertok(prep_fs(uts, 0, NULL));\n+\tut_assertok(fs_size(getpath(uts, big, NULL), &size));\n+\tut_asserteq_64((loff_t)SZ_1M * 2500, size);  /* 2500 MiB = 0x9c400000 */\n+\n+\treturn 0;\n+}\n+FS_TEST_ARGS(fs_test_size_big_norun, UTF_SCAN_FDT | UTF_MANUAL,\n+\t     COMMON_ARGS, { \"big\", UT_ARG_STR });\n+\n+/* Load a file at a given offset and verify the size and MD5 */\n+static int check_load(struct unit_test_state *uts, const char *fname,\n+\t\t      ulong offset, ulong read_len, ulong expect_len,\n+\t\t      bool check_md5)\n+{\n+\tloff_t actual;\n+\tvoid *buf;\n+\n+\tut_assertok(prep_fs(uts, expect_len, &buf));\n+\tut_assertok(fs_read(getpath(uts, fname, NULL), ADDR, offset, read_len,\n+\t\t\t    &actual));\n+\tut_asserteq(expect_len, actual);\n+\tif (check_md5)\n+\t\tut_assertok(verify_md5(uts, buf, expect_len));\n+\n+\treturn 0;\n+}\n+\n+/* Test Case 4 - load small file, verify MD5 */\n+static int fs_test_load_small_norun(struct unit_test_state *uts)\n+{\n+\treturn check_load(uts, ut_str(2), 0, 0, SZ_1M, true);\n+}\n+FS_TEST_ARGS(fs_test_load_small_norun, UTF_SCAN_FDT | UTF_MANUAL,\n+\t     COMMON_ARGS, { \"small\", UT_ARG_STR }, { \"md5val\", UT_ARG_STR });\n+\n+/* Test Case 5 - load first 1MB of big file */\n+static int fs_test_load_big_first_norun(struct unit_test_state *uts)\n+{\n+\treturn check_load(uts, ut_str(2), 0, SZ_1M, SZ_1M, true);\n+}\n+FS_TEST_ARGS(fs_test_load_big_first_norun, UTF_SCAN_FDT | UTF_MANUAL,\n+\t     COMMON_ARGS, { \"big\", UT_ARG_STR }, { \"md5val\", UT_ARG_STR });\n+\n+/* Test Case 6 - load last 1MB of big file (offset 0x9c300000) */\n+static int fs_test_load_big_last_norun(struct unit_test_state *uts)\n+{\n+\treturn check_load(uts, ut_str(2), 0x9c300000, SZ_1M, SZ_1M, true);\n+}\n+FS_TEST_ARGS(fs_test_load_big_last_norun, UTF_SCAN_FDT | UTF_MANUAL,\n+\t     COMMON_ARGS, { \"big\", UT_ARG_STR }, { \"md5val\", UT_ARG_STR });\n+\n+/* Test Case 7 - load 1MB from last 1MB chunk of 2GB (offset 0x7ff00000) */\n+static int fs_test_load_big_2g_last_norun(struct unit_test_state *uts)\n+{\n+\treturn check_load(uts, ut_str(2), 0x7ff00000, SZ_1M, SZ_1M, true);\n+}\n+FS_TEST_ARGS(fs_test_load_big_2g_last_norun, UTF_SCAN_FDT | UTF_MANUAL,\n+\t     COMMON_ARGS, { \"big\", UT_ARG_STR }, { \"md5val\", UT_ARG_STR });\n+\n+/* Test Case 8 - load first 1MB in 2GB region (offset 0x80000000) */\n+static int fs_test_load_big_2g_first_norun(struct unit_test_state *uts)\n+{\n+\treturn check_load(uts, ut_str(2), 0x80000000, SZ_1M, SZ_1M, true);\n+}\n+FS_TEST_ARGS(fs_test_load_big_2g_first_norun, UTF_SCAN_FDT | UTF_MANUAL,\n+\t     COMMON_ARGS, { \"big\", UT_ARG_STR }, { \"md5val\", UT_ARG_STR });\n+\n+/* Test Case 9 - load 1MB crossing 2GB boundary (offset 0x7ff80000) */\n+static int fs_test_load_big_2g_cross_norun(struct unit_test_state *uts)\n+{\n+\treturn check_load(uts, ut_str(2), 0x7ff80000, SZ_1M, SZ_1M, true);\n+}\n+FS_TEST_ARGS(fs_test_load_big_2g_cross_norun, UTF_SCAN_FDT | UTF_MANUAL,\n+\t     COMMON_ARGS, { \"big\", UT_ARG_STR }, { \"md5val\", UT_ARG_STR });\n+\n+/* Test Case 10 - load beyond file end (2MB from offset, only 1MB remains) */\n+static int fs_test_load_beyond_norun(struct unit_test_state *uts)\n+{\n+\treturn check_load(uts, ut_str(2), 0x9c300000, SZ_2M, SZ_1M, false);\n+}\n+FS_TEST_ARGS(fs_test_load_beyond_norun, UTF_SCAN_FDT | UTF_MANUAL,\n+\t     COMMON_ARGS, { \"big\", UT_ARG_STR });\n+\n+/* Test Case 11 - write file */\n+static int fs_test_write_norun(struct unit_test_state *uts)\n+{\n+\tconst char *small = ut_str(2);\n+\tloff_t actread, actwrite;\n+\tvoid *buf;\n+\n+\tif (!fs_write_supported(uts))\n+\t\treturn -EAGAIN;\n+\n+\tut_assertok(prep_fs(uts, SZ_1M, &buf));\n+\n+\t/* Read small file */\n+\tut_assertok(fs_read(getpath(uts, small, NULL), ADDR, 0, 0, &actread));\n+\tut_asserteq(SZ_1M, actread);\n+\n+\t/* Write it back with new name */\n+\tut_assertok(set_fs(uts));\n+\tut_assertok(fs_write(getpath(uts, small, \".w\"), ADDR, 0, SZ_1M,\n+\t\t\t     &actwrite));\n+\tut_asserteq(SZ_1M, actwrite);\n+\n+\t/* Read back and verify MD5 */\n+\tut_assertok(set_fs(uts));\n+\tmemset(buf, '\\0', SZ_1M);\n+\tut_assertok(fs_read(getpath(uts, small, \".w\"), ADDR, 0, 0, &actread));\n+\tut_asserteq(SZ_1M, actread);\n+\n+\tut_assertok(verify_md5(uts, buf, SZ_1M));\n+\n+\treturn 0;\n+}\n+FS_TEST_ARGS(fs_test_write_norun, UTF_SCAN_FDT | UTF_MANUAL,\n+\t     COMMON_ARGS, { \"small\", UT_ARG_STR }, { \"md5val\", UT_ARG_STR });\n+\n+/* Test Case 12 - write to \".\" directory (should fail) */\n+static int fs_test_write_dot_norun(struct unit_test_state *uts)\n+{\n+\tloff_t actwrite;\n+\n+\tif (!fs_write_supported(uts))\n+\t\treturn -EAGAIN;\n+\n+\tut_assertok(prep_fs(uts, 0, NULL));\n+\n+\t/* Writing to \".\" should fail */\n+\tut_assert(fs_write(\"/.\", ADDR, 0, 0x10, &actwrite));\n+\n+\treturn 0;\n+}\n+FS_TEST_ARGS(fs_test_write_dot_norun, UTF_SCAN_FDT | UTF_MANUAL,\n+\t     COMMON_ARGS);\n+\n+/* Test Case 13 - write via \"./\" path */\n+static int fs_test_write_dotpath_norun(struct unit_test_state *uts)\n+{\n+\tconst char *small = ut_str(2);\n+\tloff_t actread, actwrite;\n+\tvoid *buf;\n+\n+\tif (!fs_write_supported(uts))\n+\t\treturn -EAGAIN;\n+\n+\tut_assertok(prep_fs(uts, SZ_1M, &buf));\n+\n+\t/* Read small file */\n+\tut_assertok(fs_read(getpath(uts, small, NULL), ADDR, 0, 0, &actread));\n+\tut_asserteq(SZ_1M, actread);\n+\n+\t/* Write via \"./\" path */\n+\tut_assertok(set_fs(uts));\n+\tsnprintf(uts->priv, sizeof(uts->priv), \"/./%s2\", small);\n+\tut_assertok(fs_write(uts->priv, ADDR, 0, SZ_1M, &actwrite));\n+\tut_asserteq(SZ_1M, actwrite);\n+\n+\t/* Read back via \"./\" path and verify */\n+\tut_assertok(set_fs(uts));\n+\tmemset(buf, '\\0', SZ_1M);\n+\tut_assertok(fs_read(uts->priv, ADDR, 0, 0, &actread));\n+\tut_asserteq(SZ_1M, actread);\n+\tut_assertok(verify_md5(uts, buf, SZ_1M));\n+\n+\t/* Also verify via normal path */\n+\tut_assertok(set_fs(uts));\n+\tmemset(buf, '\\0', SZ_1M);\n+\tut_assertok(fs_read(getpath(uts, small, \"2\"), ADDR, 0, 0, &actread));\n+\tut_asserteq(SZ_1M, actread);\n+\tut_assertok(verify_md5(uts, buf, SZ_1M));\n+\n+\treturn 0;\n+}\n+FS_TEST_ARGS(fs_test_write_dotpath_norun, UTF_SCAN_FDT | UTF_MANUAL,\n+\t     COMMON_ARGS, { \"small\", UT_ARG_STR }, { \"md5val\", UT_ARG_STR });\n","prefixes":["v2","11/12"]}