{"id":2222495,"url":"http://patchwork.ozlabs.org/api/1.1/patches/2222495/?format=json","web_url":"http://patchwork.ozlabs.org/project/uboot/patch/20260412111958.943933-8-sjg@chromium.org/","project":{"id":18,"url":"http://patchwork.ozlabs.org/api/1.1/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},"msgid":"<20260412111958.943933-8-sjg@chromium.org>","date":"2026-04-12T11:19:44","name":"[v2,07/12] test: Enhance the ut command to pass test arguments","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"428abe95ce337a0def99d7481e7e77cc4a0ea73d","submitter":{"id":6170,"url":"http://patchwork.ozlabs.org/api/1.1/people/6170/?format=json","name":"Simon Glass","email":"sjg@chromium.org"},"delegate":{"id":3651,"url":"http://patchwork.ozlabs.org/api/1.1/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-8-sjg@chromium.org/mbox/","series":[{"id":499596,"url":"http://patchwork.ozlabs.org/api/1.1/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/2222495/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2222495/checks/","tags":{},"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=NQvaymgT;\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=\"NQvaymgT\";\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 4ftp9K4tHXz1xtJ\n\tfor <incoming@patchwork.ozlabs.org>; Sun, 12 Apr 2026 21:24:53 +1000 (AEST)","from h2850616.stratoserver.net (localhost [IPv6:::1])\n\tby phobos.denx.de (Postfix) with ESMTP id 9CB118422D;\n\tSun, 12 Apr 2026 13:24:25 +0200 (CEST)","by phobos.denx.de (Postfix, from userid 109)\n id B09E984228; Sun, 12 Apr 2026 13:24:24 +0200 (CEST)","from mail-oi1-x235.google.com (mail-oi1-x235.google.com\n [IPv6:2607:f8b0:4864:20::235])\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 1B0D784214\n for <u-boot@lists.denx.de>; Sun, 12 Apr 2026 13:24:22 +0200 (CEST)","by mail-oi1-x235.google.com with SMTP id\n 5614622812f47-464bba3a9easo1805698b6e.0\n for <u-boot@lists.denx.de>; Sun, 12 Apr 2026 04:24:22 -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.18\n (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n Sun, 12 Apr 2026 04:24:19 -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=1775993060; x=1776597860; 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=6Z63gjZp9n81K5hzsJNahmRxfr5j060cy+fJAISrWL8=;\n b=NQvaymgT3oBJ7RYzM90tkX5/B7x7nwLhhCIN5GS5LULvtvSX/iNHCkG1D3RcaqO/h2\n lRNfsxWaKQxSHlhmtKyRWAXQ0cRxolas8Sxq6+5ROGDyJzDtXFyetIxwVy9Kp6bGjw5v\n ai0OeO6LqIxsrujbONrNFm5gTVEOLIyb6pu30=","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20251104; t=1775993060; x=1776597860;\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=6Z63gjZp9n81K5hzsJNahmRxfr5j060cy+fJAISrWL8=;\n b=EXtVjJnGgbqXofQH0bJaPoMin1U2XoF0jLg/8H9BszLgt+ZglYJJyzYMBCECxoZVDL\n oq123cX331g7H0FYZTHsmYaW3s1urMxSbqH+FcB5MODQShOghFNfeizVCWgHJpS+mE1s\n wdyuC+oXWbWkU8CIM2gxu2KL/NZt9URediOsq13C2H7iJPGEuLjSBriM0taaF15nYYQ0\n jlPmbMUrQhotDxaa0llIuDeOXLPM/snNG3xSgNunbmlu2jK3plWvdv6PhKLO1BwwOMlK\n xpzRNIOpq8g69kkfTiCHC66XlHLJ+R/ATEEAo7IqOS3R5vQcjlHTOs2nnJdb+JrBsrf4\n r1oQ==","X-Gm-Message-State":"AOJu0YxZDalVojasrVBFCqvbPRbcE9CSdM1VLpnQZd9Ghw7f8BLEWZVY\n OniT3vz3OErHY1baU/hJaAb9LexbgI07dm+RnMy+Hf6vY/oh90RNRxqxSWNkJYO6P/YgMa7c+hy\n BWibdhQ==","X-Gm-Gg":"AeBDieveafdvnUocmX6ku5t+yxBkycPWAWRzdOW9aly1DD+Axo7x9b842cRQWHWgwTc\n XaPs+M3h/wIeRAbIrctkd5gSVkYLWtscAzi1aAajnmNzgAkmI19xvFFTQXznod/3WiC2cMOTMGT\n mojBQ/M27afp/7NseK3BDvBTYpQSq5F1LEu0YHjs62JlzjcaolF5VRlYPCfL6xuoHgba8TFW8Bw\n JxZTr+rZ+Pu4HDoHqCJh/8na85O2bUIXLBrlN+aKh5laBCjXLGfnMjooavyK3gOqU63kT8o+dw9\n uKJT4+SJQNH+DBwKLSVXlUTmR5UcazmL/Uv5qI7hJJrZmiOD08gPlCVGOfINCZ/uEeD9UZhAR9k\n 1jEmfFbplZP/Vg9IuTMdzjiUqOAWweBumB1JLGTjk9sshFd5vx+MJnn+gOkXOhR0GVWCTfLCyvI\n qgvSkHsCUh0cRig4FQbw==","X-Received":"by 2002:a05:6808:180a:b0:467:e4b3:3bef with SMTP id\n 5614622812f47-478a080e17cmr4770501b6e.48.1775993060246;\n Sun, 12 Apr 2026 04:24:20 -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>","Subject":"[PATCH v2 07/12] test: Enhance the ut command to pass test arguments","Date":"Sun, 12 Apr 2026 05:19:44 -0600","Message-ID":"<20260412111958.943933-8-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":"Update the ut command to permit passing arguments to tests.\n\nUsage: ut -f fs test_name key1=value1 key2=value2\n\nSigned-off-by: Simon Glass <sjg@chromium.org>\n---\n\n(no changes since v1)\n\n doc/usage/cmd/ut.rst | 11 ++++++++++-\n test/cmd_ut.c        | 29 ++++++++++++++++++++---------\n 2 files changed, 30 insertions(+), 10 deletions(-)","diff":"diff --git a/doc/usage/cmd/ut.rst b/doc/usage/cmd/ut.rst\nindex 1acf3126680..d8c3cbf496c 100644\n--- a/doc/usage/cmd/ut.rst\n+++ b/doc/usage/cmd/ut.rst\n@@ -11,7 +11,7 @@ Synopsis\n \n ::\n \n-    ut [-r<runs>] [-f] [-I<n>:<one_test>] [-r<n>] [<suite> | 'all' [<test>]]\n+    ut [-r<runs>] [-f] [-I<n>:<one_test>] [<suite> | all [<test>]] [<args>...]\n     ut [-s] info\n \n Description\n@@ -37,6 +37,11 @@ test\n     causes another test to fail. If the one test fails, testing stops\n     immediately.\n \n+args\n+    Optional arguments to pass to the test, in `name=value` format. These are\n+    used by tests declared with `UNIT_TEST_ARGS()` which define expected\n+    argument names and types.\n+\n Typically the command is run on :ref:`arch/sandbox/sandbox:sandbox` since it\n includes a near-complete set of emulators, no code-size limits, many CONFIG\n options enabled and runs easily in CI without needing QEMU. It is also possible\n@@ -201,3 +206,7 @@ Run a selection of three suites::\n     Tests run: 10, 12 ms, average: 1 ms, failures: 0\n     Suites run: 3, total tests run: 37, 26 ms, average: 0 ms, failures: 0\n     Average test time: 0 ms, worst case 'mem' took 1 ms\n+\n+Run a test with arguments (used by tests declared with UNIT_TEST_ARGS)::\n+\n+    => ut -f fs fs_test_ls_norun fs_type=ext4 fs_image=/tmp/img small=1MB.file\ndiff --git a/test/cmd_ut.c b/test/cmd_ut.c\nindex 7304c32bec5..9d36bd5dc87 100644\n--- a/test/cmd_ut.c\n+++ b/test/cmd_ut.c\n@@ -30,7 +30,7 @@ struct suite {\n \n static int do_ut_all(struct unit_test_state *uts, const char *select_name,\n \t\t     int runs_per_test, bool force_run,\n-\t\t     const char *test_insert);\n+\t\t     const char *test_insert, int argc, char *const argv[]);\n \n static int do_ut_info(bool show_suites);\n \n@@ -120,7 +120,7 @@ static bool has_tests(struct suite *ste)\n /** run_suite() - Run a suite of tests */\n static int run_suite(struct unit_test_state *uts, struct suite *ste,\n \t\t     const char *select_name, int runs_per_test, bool force_run,\n-\t\t     const char *test_insert)\n+\t\t     const char *test_insert, int argc, char *const argv[])\n {\n \tint n_ents = ste->end - ste->start;\n \tchar prefix[30];\n@@ -131,7 +131,7 @@ static int run_suite(struct unit_test_state *uts, struct suite *ste,\n \n \tret = ut_run_list(uts, ste->name, prefix, ste->start, n_ents,\n \t\t\t  select_name, runs_per_test, force_run, test_insert,\n-\t\t\t  0, NULL);\n+\t\t\t  argc, argv);\n \n \treturn ret;\n }\n@@ -167,7 +167,8 @@ static void update_stats(struct unit_test_state *uts, const struct suite *ste)\n }\n \n static int do_ut_all(struct unit_test_state *uts, const char *select_name,\n-\t\t     int runs_per_test, bool force_run, const char *test_insert)\n+\t\t     int runs_per_test, bool force_run, const char *test_insert,\n+\t\t     int argc, char *const argv[])\n {\n \tint i;\n \tint retval;\n@@ -179,7 +180,7 @@ static int do_ut_all(struct unit_test_state *uts, const char *select_name,\n \t\tif (has_tests(ste)) {\n \t\t\tprintf(\"----Running %s tests----\\n\", ste->name);\n \t\t\tretval = run_suite(uts, ste, select_name, runs_per_test,\n-\t\t\t\t\t   force_run, test_insert);\n+\t\t\t\t\t   force_run, test_insert, argc, argv);\n \t\t\tif (!any_fail)\n \t\t\t\tany_fail = retval;\n \t\t\tupdate_stats(uts, ste);\n@@ -244,6 +245,8 @@ static struct suite *find_suite(const char *name)\n static int do_ut(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])\n {\n \tconst char *test_insert = NULL, *select_name;\n+\tint test_argc;\n+\tchar *const *test_argv;\n \tstruct unit_test_state uts;\n \tbool show_suites = false;\n \tbool force_run = false;\n@@ -285,9 +288,14 @@ static int do_ut(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])\n \tut_init_state(&uts);\n \tname = argv[0];\n \tselect_name = cmd_arg1(argc, argv);\n+\n+\t/* Test arguments are after suite name and test name */\n+\ttest_argc = argc > 2 ? argc - 2 : 0;\n+\ttest_argv = argc > 2 ? argv + 2 : NULL;\n+\n \tif (!strcmp(name, \"all\")) {\n \t\tret = do_ut_all(&uts, select_name, runs_per_text, force_run,\n-\t\t\t\ttest_insert);\n+\t\t\t\ttest_insert, test_argc, test_argv);\n \t} else if (!strcmp(name, \"info\")) {\n \t\tret = do_ut_info(show_suites);\n \t} else {\n@@ -306,7 +314,8 @@ static int do_ut(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])\n \t\t\t}\n \n \t\t\tret = run_suite(&uts, ste, select_name, runs_per_text,\n-\t\t\t\t\tforce_run, test_insert);\n+\t\t\t\t\tforce_run, test_insert, test_argc,\n+\t\t\t\t\ttest_argv);\n \t\t\tif (!any_fail)\n \t\t\t\tany_fail = ret;\n \t\t\tupdate_stats(&uts, ste);\n@@ -322,12 +331,14 @@ static int do_ut(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])\n }\n \n U_BOOT_LONGHELP(ut,\n-\t\"[-rs] [-f] [-I<n>:<one_test>][<suites>] - run unit tests\\n\"\n+\t\"[-rs] [-f] [-I<n>:<one_test>] <suite> [<test> [<args>...]] - run unit tests\\n\"\n \t\"   -r<runs>   Number of times to run each test\\n\"\n \t\"   -f         Force 'manual' tests to run as well\\n\"\n \t\"   -I         Test to run after <n> other tests have run\\n\"\n \t\"   -s         Show all suites with ut info\\n\"\n-\t\"   <suites>   Comma-separated list of suites to run\\n\"\n+\t\"   <suite>    Test suite to run (or comma-separated list)\\n\"\n+\t\"   <test>     Specific test to run (optional)\\n\"\n+\t\"   <args>     Test arguments as key=value pairs (optional)\\n\"\n \t\"\\n\"\n \t\"Options for <suite>:\\n\"\n \t\"all       - execute all enabled tests\\n\"\n","prefixes":["v2","07/12"]}