From patchwork Sun Dec 14 17:54:22 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 61 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=1765734903; bh=eysZBCrkU1fwbddbyAFZzg5ipGJQXHc5rKaMFti96nY=; h=From:To:Date:CC:Subject:List-Id:List-Archive:List-Help:List-Owner: List-Post:List-Subscribe:List-Unsubscribe:From; b=hYL1CXjlNthjBTSUSHcu7wjd80xjQQiFo/NsEkTKNEqHuA8mJm6HuW7yFc8jm1UJL NSDt6HsSWSSM1g4fSOMWcxx2Jh5EubAPNDoAhMHIK+Uz549V9za0v2bv8zgWeqqfYL IfnvGgRfovuf0cJvUMarr6T2x2QFzm8memoLzoJxr2iE1WRap54ue/kUnBNZneWjUN yZg1y3EIyTM6nUg4DkcMpcmt0bH5Y3g7njMTfwgpFZcticUuC2jdvcHwySvovJIiTO 1CuBkBnPmV2+5+IkSEfDMoggEkh+/xZhH6ZxeJwJQVLPTOmuKdSIKV1wuUcH6zm286 k7Lszn0adQItw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 36D1C68AE8 for ; Sun, 14 Dec 2025 10:55:03 -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 baD-kFfbG70J for ; Sun, 14 Dec 2025 10:55:03 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1765734903; bh=eysZBCrkU1fwbddbyAFZzg5ipGJQXHc5rKaMFti96nY=; h=From:To:Date:CC:Subject:List-Id:List-Archive:List-Help:List-Owner: List-Post:List-Subscribe:List-Unsubscribe:From; b=hYL1CXjlNthjBTSUSHcu7wjd80xjQQiFo/NsEkTKNEqHuA8mJm6HuW7yFc8jm1UJL NSDt6HsSWSSM1g4fSOMWcxx2Jh5EubAPNDoAhMHIK+Uz549V9za0v2bv8zgWeqqfYL IfnvGgRfovuf0cJvUMarr6T2x2QFzm8memoLzoJxr2iE1WRap54ue/kUnBNZneWjUN yZg1y3EIyTM6nUg4DkcMpcmt0bH5Y3g7njMTfwgpFZcticUuC2jdvcHwySvovJIiTO 1CuBkBnPmV2+5+IkSEfDMoggEkh+/xZhH6ZxeJwJQVLPTOmuKdSIKV1wuUcH6zm286 k7Lszn0adQItw== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 267EC68ADC for ; Sun, 14 Dec 2025 10:55:03 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1765734900; bh=Rlig3FASoLD/hIjbbrUOD3I0GDCaf1vo/h0lEo/y9ak=; h=From:To:Cc:Subject:Date:From; b=Jq5whWeoJUmjVc/IUdqxG/MaXvCCGPEl5xlGSu1tpkuud1NY+dEyFZh2NvgTvPwUS ttm1dbqw5fWIy3i7yew7ESf9CxBcD2UggT0A48fvfbDEpe33TVCVTLEk20A7WmXWbq AIHEzRplCEzxK92aKSNxnmopKg9nzQUOQFe8nSb3NvEeVErpY6O4Y+JlFx5xilSxAs xIBUec+xsSBDnRaEbaUiwsjhW/oCuKNNB/T6bVBl8vBQ7l7TaEDM02Z7pVagAXw+f4 BOg9QS43nqM1vfONeUaX2FE/adWlR/CtrbK2JPWilLIVhcU3kpF0wZBiVBYQP63zue PbpweYwuvKJKA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id F126168A84; Sun, 14 Dec 2025 10:55:00 -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 OB_uE17XUpXz; Sun, 14 Dec 2025 10:55:00 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1765734896; bh=bicrIKvPHtffm7rqtcOEjFQ4g3LxGQ2JJbwdOyGDU4g=; h=From:To:Cc:Subject:Date:From; b=wTI0XgZUWXycFUQwE6g61q6/7h/jwK7z9txwMrpQ2AH3FszOtTOyjnTQgrT9z4nzf LTFfomsASF9cvuhfw6FeeNZlqeEtWhrr9BbD8XUo2+7st7W4OylTRKxnbuptjexcT5 S6yN2VotjNzeAMfvQ6B64uI9Jg9e38aOBFXcU99m035jZxiF9GoSvSkloABOk0EXTK kGgTWBU3iZ2wzjUpHLmKhla6ITOmEKwjtboo5GiLGmWewIN+M8sWm7GRnhGmlQJ6bf X7buomqOFbUq2XL9ay4YfCbc/jyXGo2JWBfYnI20HPXjwSkWNnA39ICi+wQ+KqPrJc B24o0kqbO7jVQ== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 61D0668A91; Sun, 14 Dec 2025 10:54:56 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Sun, 14 Dec 2025 10:54:22 -0700 Message-ID: <20251214175449.3799539-1-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 Message-ID-Hash: VP3DC4CIO43W2TELZN7USL3IX4T5IQEO X-Message-ID-Hash: VP3DC4CIO43W2TELZN7USL3IX4T5IQEO 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: Heinrich Schuchardt , Simon Glass X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 00/21] test: Add support for passing arguments to C unit 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 This series adds infrastructure for passing runtime arguments from Python tests to C unit tests. This makes it easier to support a hybrid testing approach where Python handles complex setup (filesystem images, environment configuration) while C handles the actual test logic with better debuggability. A few other things are included to make this work: - A fix for linker list alignment that was causing garbage values like "Running -858993444 bloblist tests" due to GCC's magic-number division optimization failing when padding breaks exact multiples - A fix fix for serial output with sandbox, since it sometimes misses output at the end when running tests with gnome terminal - Improvements to the linker-list script to detect padding and pointer-arithmetic bugs - A new UNIT_TEST_ARGS() macro for declaring tests with typed arguments, along with argument parsing in the ut command (name=value format) - Argument-accessor macros ut_str(), ut_int(), and ut_bool() with type-checking and bounds validation - A private buffer (uts->priv) for test-local temporary data, which makes it a little easier to write shorter tests - Tests for the argument feature (test_args) covering type checking, bounds checking, and argument-parsing failures As an example, the basic filesystem tests are converted from pure Python to C with Python wrappers. Some improved printf documentation and support for Linux's %pV format are provided. The slight increase in size causes qemu-riscv64_spl to fail, so this series also includes a patch to increase the SPL-malloc() space. Heinrich Schuchardt (1): configs: raise SPL_SYS_MALLOC_SIZE to 8 MiB on RISC-V Simon Glass (20): serial: Retry output if it fails sandbox: serial: Report output failurs doc: Expand printf documentation doc: Document tiny printf for SPL vsprintf: Add support for the %pV format-specifier check_linker_lists: Enhance detection of alignment problems linker_lists: Fix end-marker alignment to prevent padding test: vbe: Fix the ut-flag order in vbe_test_fixup_norun() test: Add a helper to check the next line against a regex test: Add argument-type definitions test: Add a macro to declare unit tests with arguments test: Add support for passing arguments to C tests test: Enhance the ut command to pass test arguments test: Add type-checked argument accessor functions test: Add a private buffer for tests test: Allow preserving console recording on failure test: Add tests for unit-test arguments test: fs: add C-based filesystem tests test: fs: Update Python tests to call C implementations test: Add documentation for test parameters arch/sandbox/cpu/spl.c | 3 +- common/spl/Kconfig | 1 + doc/develop/printf.rst | 174 +++++++++- doc/develop/tests_writing.rst | 58 ++++ doc/usage/cmd/ut.rst | 18 +- drivers/serial/sandbox.c | 7 +- drivers/serial/serial-uclass.c | 2 + include/linker_lists.h | 22 +- include/linux/printk.h | 5 + include/test/fs.h | 39 +++ include/test/test.h | 109 ++++++ include/test/ut.h | 83 ++++- lib/vsprintf.c | 12 + scripts/check_linker_lists.py | 206 ++++++++---- test/Makefile | 1 + test/cmd_ut.c | 38 ++- test/common/Makefile | 1 + test/common/print.c | 48 +++ test/common/test_args.c | 186 +++++++++++ test/fs/Makefile | 3 + test/fs/fs_basic.c | 492 ++++++++++++++++++++++++++++ test/py/tests/test_fs/conftest.py | 4 +- test/py/tests/test_fs/test_basic.py | 346 ++++++------------- test/py/tests/test_vbe.py | 2 +- test/test-main.c | 170 +++++++++- test/ut.c | 94 +++++- 26 files changed, 1776 insertions(+), 348 deletions(-) create mode 100644 include/test/fs.h create mode 100644 test/common/test_args.c create mode 100644 test/fs/Makefile create mode 100644 test/fs/fs_basic.c