{"id":2222493,"url":"http://patchwork.ozlabs.org/api/1.2/patches/2222493/?format=json","web_url":"http://patchwork.ozlabs.org/project/uboot/patch/20260412111958.943933-6-sjg@chromium.org/","project":{"id":18,"url":"http://patchwork.ozlabs.org/api/1.2/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,"list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<20260412111958.943933-6-sjg@chromium.org>","list_archive_url":null,"date":"2026-04-12T11:19:42","name":"[v2,05/12] test: Add a macro to declare unit tests with arguments","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"cee417bb71ad61983cb28d9581056d7982626835","submitter":{"id":6170,"url":"http://patchwork.ozlabs.org/api/1.2/people/6170/?format=json","name":"Simon Glass","email":"sjg@chromium.org"},"delegate":{"id":3651,"url":"http://patchwork.ozlabs.org/api/1.2/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-6-sjg@chromium.org/mbox/","series":[{"id":499596,"url":"http://patchwork.ozlabs.org/api/1.2/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/2222493/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2222493/checks/","tags":{},"related":[],"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=OHz/4XDe;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de\n (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; 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=\"OHz/4XDe\";\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\n [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01])\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 4ftp900XtZz1xtJ\n\tfor <incoming@patchwork.ozlabs.org>; Sun, 12 Apr 2026 21:24:36 +1000 (AEST)","from h2850616.stratoserver.net (localhost [IPv6:::1])\n\tby phobos.denx.de (Postfix) with ESMTP id 1FDAD841D5;\n\tSun, 12 Apr 2026 13:24:20 +0200 (CEST)","by phobos.denx.de (Postfix, from userid 109)\n id 5369F841CD; Sun, 12 Apr 2026 13:24:18 +0200 (CEST)","from mail-oi1-x244.google.com (mail-oi1-x244.google.com\n [IPv6:2607:f8b0:4864:20::244])\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 6DE99841E6\n for <u-boot@lists.denx.de>; Sun, 12 Apr 2026 13:24:15 +0200 (CEST)","by mail-oi1-x244.google.com with SMTP id\n 5614622812f47-466ec4c6846so1054460b6e.3\n for <u-boot@lists.denx.de>; Sun, 12 Apr 2026 04:24:15 -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.10\n (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n Sun, 12 Apr 2026 04:24:12 -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=1775993053; x=1776597853; 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=WnSMkKC6qnOXyoKVeTbvTUywTWvh6cT6Eaa85wQ6D0U=;\n b=OHz/4XDehllIy3tk5Zfjl6VAKjx1nGq6ySddBGFg4pb6NpHJftMPonHnE0QXRoXrJL\n Qi18XLcZMnc/+DQymfl6KfAB4aFosAxvvYk2dCX6/CrhmM+WudYyLq6Oc8HUK6CA6Vde\n lOX/8+kPoEHqVonjcAdZPHMGJoMfn+g1a0Qns=","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20251104; t=1775993053; x=1776597853;\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=WnSMkKC6qnOXyoKVeTbvTUywTWvh6cT6Eaa85wQ6D0U=;\n b=jQS5/QRGGFOGhYu+zX65o1kjPE/yAFFDipYyEXVhLUd8G5QgoJ+eF2CDeXH5Ah74AJ\n VUaxglHKjOOwEA1K405tWJ04b4v3obNQdj3WSwUKpNCL22TSpNoL7SY+fD1HCb7BETGQ\n E5oJaxKm8V4Q851gWv3ctoA2OPxTvl3ESDv+iVC8gbOviNvnCXL8Zi4plmS36hCXGMmp\n 3MTJxImN2FARVvEnYN+5BhK5tKtPfapLnKERFcF99LmapFt77U29rfAjJycEUBKyfpc7\n xmg6j2Es/s6IuostOXzjpduX0r6GEoGGr5tKMn/fbRFSJoI23fYagJ/Ecyg9G50tEtQC\n 8Qcw==","X-Gm-Message-State":"AOJu0YyUgroJwqn0Izcss7QqnUYxdnvXdYooT8uTpTwwSQ8zUiyfvnO5\n IrPG9maHsk6hRPowK9dfkUzVgl1omBP3EJteeYnXtFKJVTIqj6B9BrvYThENh379vDD8l7ghk08\n kaIAS2H+X","X-Gm-Gg":"AeBDietv5KY9K2k3Yt7COUi/opOBSnzGT3SbP67ZI0ArJyB6eF31k6RBAfQiMpIFKaN\n KpbZ1bTSPb2Q6PGw85V0b7d9jZW3nQrgp52iz9scr51GBiENaUlJStXGF4xRD2i4TLlGnNJA0vO\n s0Em/kne7W3PdAGsJkRG0ybPQgjUZS5EhFmAHd1ejKhmhKxWnmWdlH1KKigaeJHcGI5Qkwk5Wg8\n fTujHiLrTm/n8rQS5rxdlefstlUB63IB1fvHbUgtAN4Ozmnz8fniK3gGHaWm/5FbqOOHwcpt9Z4\n rpVvBcO5nFkplxCOcTheNKWkzeKTIcJH+MtTQdGVoXbxodRGUUUoh2qyu05CimnoFgfXp3Jwyf1\n UhFb10WSKNnyQSfPy3h7vWU2WkiWhG5E07C2tq8m57HENVgzmYfBCjHogz1ac4+BTQIEBwcLll3\n aG7wff7u8KEZ+CIrHLzg==","X-Received":"by 2002:a05:6820:986:b0:67e:21c9:ab55 with SMTP id\n 006d021491bc7-68be5a6225dmr5075466eaf.3.1775993053591;\n Sun, 12 Apr 2026 04:24:13 -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 05/12] test: Add a macro to declare unit tests with\n arguments","Date":"Sun, 12 Apr 2026 05:19:42 -0600","Message-ID":"<20260412111958.943933-6-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":"Add a UNIT_TEST_ARGS() macro to declare and register a test with inline\nargument definitions. The variadic arguments use struct ut_arg_def and\na NULL terminator is added automatically to the list.\n\nExample usage:\n  static int my_test(struct unit_test_state *uts) { ... }\n  UNIT_TEST_ARGS(my_test, UTF_CONSOLE, my_suite,\n      { \"path\", UT_ARG_STR },\n      { \"count\", UT_ARG_INT, UT_ARGF_OPTIONAL, { .vint = 10 } });\n\nSigned-off-by: Simon Glass <sjg@chromium.org>\n---\n\n(no changes since v1)\n\n include/test/test.h | 31 +++++++++++++++++++++++++++++++\n 1 file changed, 31 insertions(+)","diff":"diff --git a/include/test/test.h b/include/test/test.h\nindex c9b56c66eae..cdd19392844 100644\n--- a/include/test/test.h\n+++ b/include/test/test.h\n@@ -49,6 +49,7 @@ enum ut_arg_type {\n  *\n  * @name: Name of the argument (points to ut_arg_def.name)\n  * @type: Type of the argument\n+ * @provided: true if value was provided on command line\n  * @vint: Integer value (when type is UT_ARG_INT)\n  * @vbool: Boolean value (when type is UT_ARG_BOOL)\n  * @vstr: String value (when type is UT_ARG_STR, points into argv)\n@@ -56,6 +57,7 @@ enum ut_arg_type {\n struct ut_arg {\n \tconst char *name;\n \tenum ut_arg_type type;\n+\tbool provided;\n \tunion {\n \t\tlong vint;\n \t\tbool vbool;\n@@ -179,12 +181,14 @@ struct ut_arg_def {\n  * @name: Name of test\n  * @func: Function to call to perform test\n  * @flags: Flags indicated pre-conditions for test\n+ * @arg_defs: Argument definitions (NULL-terminated array), or NULL\n  */\n struct unit_test {\n \tconst char *file;\n \tconst char *name;\n \tint (*func)(struct unit_test_state *state);\n \tint flags;\n+\tconst struct ut_arg_def *arg_defs;\n };\n \n /**\n@@ -236,6 +240,33 @@ struct unit_test {\n \t\t.func = _name,\t\t\t\t\t\t\\\n \t}\n \n+/**\n+ * UNIT_TEST_ARGS() - create unit test entry with inline argument definitions\n+ *\n+ * Like UNIT_TEST() but allows specifying argument definitions inline.\n+ * The variadic arguments are struct ut_arg_def initializers. The NULL\n+ * terminator is added automatically by the macro.\n+ *\n+ * Example:\n+ *   UNIT_TEST_ARGS(my_test, UTF_CONSOLE, my_suite,\n+ *       { \"path\", UT_ARG_STR },\n+ *       { \"count\", UT_ARG_INT, UT_ARGF_OPTIONAL, { .vint = 10 } });\n+ *\n+ * @_name:\tTest function name\n+ * @_flags:\tTest flags (see enum ut_flags)\n+ * @_suite:\tTest suite name\n+ * @...:\tArgument definitions (struct ut_arg_def initializers)\n+ */\n+#define UNIT_TEST_ARGS(_name, _flags, _suite, ...)\t\t\t\\\n+\tstatic const struct ut_arg_def _name##_args[] = { __VA_ARGS__, { NULL } }; \\\n+\tll_entry_declare(struct unit_test, _name, ut_ ## _suite) = {\t\\\n+\t\t.file = __FILE__,\t\t\t\t\t\\\n+\t\t.name = #_name,\t\t\t\t\t\t\\\n+\t\t.flags = _flags,\t\t\t\t\t\\\n+\t\t.func = _name,\t\t\t\t\t\t\\\n+\t\t.arg_defs = _name##_args,\t\t\t\t\\\n+\t}\n+\n /* Get the start of a list of unit tests for a particular suite */\n #define UNIT_TEST_SUITE_START(_suite) \\\n \tll_entry_start(struct unit_test, ut_ ## _suite)\n","prefixes":["v2","05/12"]}