From: Kuan-Wei Chiu <visitorckw@gmail.com>
To: trini@konsulko.com, tuomas.tynkkynen@iki.fi, bmeng.cn@gmail.com,
sjg@chromium.org, jerome.forissier@arm.com
Cc: jserv@ccns.ncku.edu.tw, eleanor15x@gmail.com,
marscheng@google.com, u-boot@lists.u-boot-project.org,
Kuan-Wei Chiu <visitorckw@gmail.com>
Subject: [PATCH v2 5/6] test: 9p: Add test for 9P filesystem
Date: Sat, 29 Aug 2026 19:21:18 +0000 [thread overview]
Message-ID: <20260829192119.2658328-6-visitorckw@gmail.com> (raw)
In-Reply-To: <20260829192119.2658328-1-visitorckw@gmail.com>
Add automated pytest for the 9P filesystem testing directory listing
(ls) and file loading (load) over virtio-9p in QEMU ARM64. Also enable
the relevant configurations in qemu_arm64_defconfig.
Signed-off-by: Kuan-Wei Chiu <visitorckw@gmail.com>
---
configs/qemu_arm64_defconfig | 3 ++
test/py/tests/test_9p.py | 82 ++++++++++++++++++++++++++++++++++++
2 files changed, 85 insertions(+)
create mode 100644 test/py/tests/test_9p.py
diff --git a/configs/qemu_arm64_defconfig b/configs/qemu_arm64_defconfig
index ae6dd770f3e..75b50eeb5ea 100644
--- a/configs/qemu_arm64_defconfig
+++ b/configs/qemu_arm64_defconfig
@@ -40,6 +40,7 @@ CONFIG_CMD_TPM=y
CONFIG_CMD_MTDPARTS=y
CONFIG_CMD_SPAWN=y
CONFIG_ENV_IS_IN_FLASH=y
+CONFIG_NET_9P=y
CONFIG_AHCI=y
CONFIG_SCSI_AHCI=y
CONFIG_AHCI_PCI=y
@@ -73,6 +74,8 @@ CONFIG_SYSRESET_PSCI=y
CONFIG_TPM2_MMIO=y
CONFIG_USB_EHCI_HCD=y
CONFIG_USB_EHCI_PCI=y
+CONFIG_VIRTIO_9P=y
+CONFIG_FS_9P=y
CONFIG_MBEDTLS_LIB=y
CONFIG_TPM=y
CONFIG_TPM_PCR_ALLOCATE=y
diff --git a/test/py/tests/test_9p.py b/test/py/tests/test_9p.py
new file mode 100644
index 00000000000..7b3b17c8366
--- /dev/null
+++ b/test/py/tests/test_9p.py
@@ -0,0 +1,82 @@
+# SPDX-License-Identifier: GPL-2.0-or-later
+# Copyright (c) 2026, Kuan-Wei Chiu <visitorckw@gmail.com>
+
+import os
+import pytest
+import utils
+import zlib
+
+@pytest.mark.buildconfigspec("fs_9p")
+@pytest.mark.buildconfigspec("cmd_virtio")
+def test_fs_9p(ubman):
+ """Test the 9P filesystem commands."""
+
+ test_file_name = "9p_test_small.txt"
+ test_file_content = b"9PFS_AUTOMATED_TEST_CONTENT_1234567890\n" * 10
+ test_file_size = len(test_file_content)
+ test_file_crc = zlib.crc32(test_file_content) & 0xffffffff
+ test_file_path = os.path.join(ubman.config.build_dir, test_file_name)
+
+ with open(test_file_path, "wb") as f:
+ f.write(test_file_content)
+
+ large_file_name = "9p_test_large.bin"
+ large_file_content = b"".join(bytes([i % 256]) for i in range(128 * 1024))
+ large_file_size = len(large_file_content)
+ large_file_crc = zlib.crc32(large_file_content) & 0xffffffff
+ large_file_path = os.path.join(ubman.config.build_dir, large_file_name)
+
+ with open(large_file_path, "wb") as f:
+ f.write(large_file_content)
+
+ sub_dir_name = "9p_subdir"
+ sub_dir_path = os.path.join(ubman.config.build_dir, sub_dir_name)
+ os.makedirs(sub_dir_path, exist_ok=True)
+ nested_file_name = "nested.txt"
+ nested_file_content = b"NESTED_FILE_DATA_OK\n"
+ nested_file_path = os.path.join(sub_dir_path, nested_file_name)
+
+ with open(nested_file_path, "wb") as f:
+ f.write(nested_file_content)
+
+ ubman.run_command("virtio scan")
+ addr = utils.find_ram_base(ubman)
+
+ output = ubman.run_command("ls 9p - /")
+ assert test_file_name in output
+ assert sub_dir_name in output
+
+ output = ubman.run_command("ls 9p rootfs /")
+ assert test_file_name in output
+ assert large_file_name in output
+
+ output = ubman.run_command("ls 9p 0 /")
+ assert test_file_name in output
+
+ output = ubman.run_command(f"ls 9p rootfs /{sub_dir_name}")
+ assert nested_file_name in output
+
+ output = ubman.run_command(f"size 9p rootfs /{test_file_name}")
+ output = ubman.run_command("printenv filesize")
+ assert f"filesize={test_file_size:x}" in output
+
+ output = ubman.run_command(f"load 9p rootfs {addr:x} /{test_file_name}")
+ assert f"{test_file_size} bytes read" in output
+
+ output = ubman.run_command(f"crc32 {addr:x} $filesize")
+ assert f"{test_file_crc:08x}" in output
+
+ output = ubman.run_command(f"load 9p rootfs {addr:x} /{large_file_name}")
+ assert f"{large_file_size} bytes read" in output
+
+ output = ubman.run_command(f"crc32 {addr:x} $filesize")
+ assert f"{large_file_crc:08x}" in output
+
+ output = ubman.run_command(f"load 9p rootfs {addr:x} /{sub_dir_name}/{nested_file_name}")
+ assert f"{len(nested_file_content)} bytes read" in output
+
+ output = ubman.run_command(f"load 9p rootfs {addr:x} /non_existent_file_9p.txt")
+ assert "bytes read" not in output
+
+ output = ubman.run_command("ls 9p invalid_tag /")
+ assert test_file_name not in output
--
2.55.0.897.gb25b4bd76c-goog
next prev parent reply other threads:[~2026-08-29 19:21 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-29 19:21 [PATCH v2 0/6] fs: Add 9P filesystem support over virtio Kuan-Wei Chiu
2026-08-29 19:21 ` [PATCH v2 1/6] net: 9p: Add 9P2000.L protocol support Kuan-Wei Chiu
2026-09-11 11:43 ` Simon Glass
2026-08-29 19:21 ` [PATCH v2 2/6] fs: 9p: Add 9P filesystem support Kuan-Wei Chiu
2026-09-11 11:43 ` Simon Glass
2026-08-29 19:21 ` [PATCH v2 3/6] virtio: 9p: Add 9P transport driver Kuan-Wei Chiu
2026-09-11 11:43 ` Simon Glass
2026-08-29 19:21 ` [PATCH v2 4/6] doc: 9p: Add 9P filesystem documentation Kuan-Wei Chiu
2026-09-11 11:43 ` Simon Glass
2026-08-29 19:21 ` Kuan-Wei Chiu [this message]
2026-09-11 11:44 ` [PATCH v2 5/6] test: 9p: Add test for 9P filesystem Simon Glass
2026-08-29 19:21 ` [PATCH v2 6/6] MAINTAINERS: Add entry for 9PFS Kuan-Wei Chiu
2026-08-30 10:41 ` [PATCH v2 0/6] fs: Add 9P filesystem support over virtio Peter Robinson
2026-09-02 1:51 ` Kuan-Wei Chiu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260829192119.2658328-6-visitorckw@gmail.com \
--to=visitorckw@gmail.com \
--cc=bmeng.cn@gmail.com \
--cc=eleanor15x@gmail.com \
--cc=jerome.forissier@arm.com \
--cc=jserv@ccns.ncku.edu.tw \
--cc=marscheng@google.com \
--cc=sjg@chromium.org \
--cc=trini@konsulko.com \
--cc=tuomas.tynkkynen@iki.fi \
--cc=u-boot@lists.u-boot-project.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.