From patchwork Mon Dec 29 16:06:01 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1101 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=1767024398; bh=eolqTrP5X3VrX3m4ch6f8C1OzLfwL3MSQF2F7wrXb/Y=; 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=Vfu/ensnfUqNOecO/xXrc/wbP9IrgZM70TB0ufbGIlkswsaxDd/s2kyuTjJTNoNAP sBZJOc7NruNIUtGZYI9D3u77y/buM/QXSgDUYZZVB7FwHjyxP5qhrggF9/9HBsKxZP 8wdy4nFkO70n5CbB9Auapf54JGke8Ieqz+6YYcv0Tllw7WDLUgijeqoLvrOBi0Nfky TRetxn06EYRWjPQHL6poRmrwqKYAnrrQGLuCrabBTrVbAODJKakhqV7nWdeLkx1gbH Q6daNkTsEW9TNmCsu5W/83ZIkieXDj/NAoOcBDYv3z8pnPvzc+uJxXqj1CbiZQFeyb VPH5zLWUIrzFw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 2253568F2D for ; Mon, 29 Dec 2025 09:06:38 -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 Oe36--V4AuI5 for ; Mon, 29 Dec 2025 09:06:38 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767024398; bh=eolqTrP5X3VrX3m4ch6f8C1OzLfwL3MSQF2F7wrXb/Y=; 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=Vfu/ensnfUqNOecO/xXrc/wbP9IrgZM70TB0ufbGIlkswsaxDd/s2kyuTjJTNoNAP sBZJOc7NruNIUtGZYI9D3u77y/buM/QXSgDUYZZVB7FwHjyxP5qhrggF9/9HBsKxZP 8wdy4nFkO70n5CbB9Auapf54JGke8Ieqz+6YYcv0Tllw7WDLUgijeqoLvrOBi0Nfky TRetxn06EYRWjPQHL6poRmrwqKYAnrrQGLuCrabBTrVbAODJKakhqV7nWdeLkx1gbH Q6daNkTsEW9TNmCsu5W/83ZIkieXDj/NAoOcBDYv3z8pnPvzc+uJxXqj1CbiZQFeyb VPH5zLWUIrzFw== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 113AA68CAD for ; Mon, 29 Dec 2025 09:06:38 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767024396; bh=c/mQbyd4nEBrddMss4NUF0Yeew5DTSXBBNVACX7XZ98=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LvvFMmTW687x3soSg8GvPbmM8mGa7TQMRbaC21jBZw0LG1EaiLviaLcQruGkRpMAr 0rhsxfIKDptWP7vN5K3lNsz+MCupSCqz7eBm6mcstIFEkvqgfs8ybb/W9aAhNyiKmB s7Vx+hJr/UgzykhFBJByqhKCfEURTv245ZAegMQQZKDCp4v1ngBhAUGegaSHL/psuT tsw9cGTUajVndm2DxBtlj0W4JkJqvgFU+9Xfqk/uQQkDZBImZBgzQSG7CxthLSmPz1 0V4LNYKUESP4pZDQL29juE7uzK3Wqjm87WhOG1mkkACFdheoYCwIsfg+F5sHuM9sLW WGXg4wU8Jducg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 4B3DB68CAD; Mon, 29 Dec 2025 09:06:36 -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 kCn8egA3Pfgm; Mon, 29 Dec 2025 09:06:36 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767024391; bh=bky0fu9+Z51/F7GmU7S8T9niYCJvZ/0rHX1AeBpe6gs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=C6t+IfZZ7oMRM/GKVmRUBEj89hPXJ4bDuje4Hw18wzchipAL4+gFS8bDWl45WFBuy 0F4o+ZpWbEb7twkAYlGH/RZRCu53yhypT232bSqun+X9eAb0/VPaKo7yG2LeIOzulc wkvIt0M4srbD0NDuPeZvPhP9A8zTgLNldnCMb7ynq1yXkyyitexrCUg4ECdnJsAyA7 LZg5H5rkce5XyQHirru3fKYMstJTgCSSDoazcilncRBrSr/CQKullIuAfPn/i/0b/+ mWFxNSB0qAerszxNL6ulsog7i1QkADKOfHeglBRUQ28Av0pXzFr7+9M/EfKPlKHiFs QrA1WHxCzSQog== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 3F8BF64E2A; Mon, 29 Dec 2025 09:06:31 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Mon, 29 Dec 2025 09:06:01 -0700 Message-ID: <20251229160611.3899708-4-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251229160611.3899708-1-sjg@u-boot.org> References: <20251229160611.3899708-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: 7TRR46XJDHBJNDNYS4LCQ26HWSRLNMNI X-Message-ID-Hash: 7TRR46XJDHBJNDNYS4LCQ26HWSRLNMNI 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 , "Claude Opus 4 . 5" X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 3/9] test: py: Add --persist flag to keep test artefacts 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 When iterating on C test code, the Python fixtures that create disk images run each time, even though the images have not changed. This slows down the development cycle unnecessarily. Add a -P/--persist option to prevent cleanup of test-generated files like disk images. This allows re-running C tests directly, without re-running the Python fixture each time. Update the ext4l test to respect the persist flag. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- doc/develop/py_testing.rst | 7 +++++++ test/py/conftest.py | 3 +++ test/py/tests/test_fs/test_ext4l.py | 4 ++-- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/doc/develop/py_testing.rst b/doc/develop/py_testing.rst index c65de27369b..303c07040b3 100644 --- a/doc/develop/py_testing.rst +++ b/doc/develop/py_testing.rst @@ -246,6 +246,13 @@ Command-line options sets the directory used to store persistent test data. This is test data that may be re-used across test runs, such as file-system images. +-P, --persist + prevents cleanup of test-generated files like disk images after the test run + completes. This is useful when iterating on C test code, allowing you to + re-run the C tests without re-running the Python fixture that creates the + test images. Note that this must be individually supported by each test, e.g. + with a check against u_boot_config.persist before removing images. + --timing shows a histogram of test duration, at the end of the run. The columns are: diff --git a/test/py/conftest.py b/test/py/conftest.py index 247d4e19094..b79080af961 100644 --- a/test/py/conftest.py +++ b/test/py/conftest.py @@ -100,6 +100,8 @@ def pytest_addoption(parser): help="Assume that U-Boot is ready and don't wait for a prompt") parser.addoption('--timing', default=False, action='store_true', help='Show info on test timing') + parser.addoption('-P', '--persist', default=False, action='store_true', + help='Persist test artifacts (do not clean up after tests)') def run_build(config, source_dir, build_dir, board_type, log): @@ -346,6 +348,7 @@ def pytest_configure(config): ubconfig.dtb = build_dir + '/arch/sandbox/dts/test.dtb' ubconfig.connection_ok = True ubconfig.timing = config.getoption('timing') + ubconfig.persist = config.getoption('persist') ubconfig.role = config.getoption('role') ubconfig.allow_exceptions = config.getoption('allow_exceptions') diff --git a/test/py/tests/test_fs/test_ext4l.py b/test/py/tests/test_fs/test_ext4l.py index 754c2cc69c4..3287f59fbe5 100644 --- a/test/py/tests/test_fs/test_ext4l.py +++ b/test/py/tests/test_fs/test_ext4l.py @@ -65,8 +65,8 @@ class TestExt4l: yield image_path - # Cleanup - if os.path.exists(image_path): + # Cleanup (skip if --persist flag is set) + if not u_boot_config.persist and os.path.exists(image_path): os.remove(image_path) def test_probe(self, ubman, ext4_image):