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 v3 5/6] test: 9p: Add test for 9P filesystem
Date: Wed, 23 Sep 2026 21:30:01 +0000 [thread overview]
Message-ID: <20260923213002.1070404-6-visitorckw@gmail.com> (raw)
In-Reply-To: <20260923213002.1070404-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>
---
Changes in v3:
- Assert expected error strings in negative test cases.
- Add doc/develop/pytest/test_9p.rst.
---
configs/qemu_arm64_defconfig | 3 ++
doc/develop/pytest/test_9p.rst | 10 +++++
test/py/tests/test_9p.py | 82 ++++++++++++++++++++++++++++++++++
3 files changed, 95 insertions(+)
create mode 100644 doc/develop/pytest/test_9p.rst
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/doc/develop/pytest/test_9p.rst b/doc/develop/pytest/test_9p.rst
new file mode 100644
index 00000000000..9c4d18e66fd
--- /dev/null
+++ b/doc/develop/pytest/test_9p.rst
@@ -0,0 +1,10 @@
+.. SPDX-License-Identifier: GPL-2.0+
+
+test_9p
+=======
+
+.. automodule:: test_9p
+ :synopsis:
+ :member-order: bysource
+ :members:
+ :undoc-members:
diff --git a/test/py/tests/test_9p.py b/test/py/tests/test_9p.py
new file mode 100644
index 00000000000..a2c32d6e694
--- /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 "Failed to load" in output
+
+ output = ubman.run_command("ls 9p invalid_tag /")
+ assert "No matching 9P transport device found" in output
--
2.56.0.rc1.310.g51773c2048-goog
next prev parent reply other threads:[~2026-09-23 21:31 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-23 21:29 [PATCH v3 0/6] fs: Add 9P filesystem support over virtio Kuan-Wei Chiu
2026-09-23 21:29 ` [PATCH v3 1/6] net: 9p: Add 9P2000.L protocol support Kuan-Wei Chiu
2026-09-23 21:29 ` [PATCH v3 2/6] fs: 9p: Add 9P filesystem support Kuan-Wei Chiu
2026-09-23 21:29 ` [PATCH v3 3/6] virtio: 9p: Add 9P transport driver Kuan-Wei Chiu
2026-09-27 15:40 ` Simon Glass
2026-09-23 21:30 ` [PATCH v3 4/6] doc: 9p: Add 9P filesystem documentation Kuan-Wei Chiu
2026-09-27 15:40 ` Simon Glass
2026-09-23 21:30 ` Kuan-Wei Chiu [this message]
2026-09-27 15:40 ` [PATCH v3 5/6] test: 9p: Add test for 9P filesystem Simon Glass
2026-09-23 21:30 ` [PATCH v3 6/6] MAINTAINERS: Add entry for 9PFS Kuan-Wei Chiu
2026-10-07 18:42 ` [PATCH v3 0/6] fs: Add 9P filesystem support over virtio Tom Rini
2026-10-07 19:59 ` Tom Rini
2026-10-07 20:13 ` Kuan-Wei Chiu
2026-10-07 20:30 ` Kuan-Wei Chiu
2026-10-07 20:31 ` Tom Rini
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=20260923213002.1070404-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox