Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/2222463/?format=api
{ "id": 2222463, "url": "http://patchwork.ozlabs.org/api/patches/2222463/?format=api", "web_url": "http://patchwork.ozlabs.org/project/uboot/patch/20260412013451.2929001-10-sjg@chromium.org/", "project": { "id": 18, "url": "http://patchwork.ozlabs.org/api/projects/18/?format=api", "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": "<20260412013451.2929001-10-sjg@chromium.org>", "list_archive_url": null, "date": "2026-04-12T01:34:37", "name": "[09/12] test: Add tests for unit-test arguments", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "b7c1ec51c7701357eee7c910dacb0f39ec17a04e", "submitter": { "id": 6170, "url": "http://patchwork.ozlabs.org/api/people/6170/?format=api", "name": "Simon Glass", "email": "sjg@chromium.org" }, "delegate": { "id": 3184, "url": "http://patchwork.ozlabs.org/api/users/3184/?format=api", "username": "sjg", "first_name": "Simon", "last_name": "Glass", "email": "sjg@chromium.org" }, "mbox": "http://patchwork.ozlabs.org/project/uboot/patch/20260412013451.2929001-10-sjg@chromium.org/mbox/", "series": [ { "id": 499582, "url": "http://patchwork.ozlabs.org/api/series/499582/?format=api", "web_url": "http://patchwork.ozlabs.org/project/uboot/list/?series=499582", "date": "2026-04-12T01:34:28", "name": "test: Add support for passing arguments to C unit tests", "version": 1, "mbox": "http://patchwork.ozlabs.org/series/499582/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/2222463/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/2222463/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=GS1usiIK;\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=\"GS1usiIK\";\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 4ftY6S3HhNz1xtJ\n\tfor <incoming@patchwork.ozlabs.org>; Sun, 12 Apr 2026 11:36:32 +1000 (AEST)", "from h2850616.stratoserver.net (localhost [IPv6:::1])\n\tby phobos.denx.de (Postfix) with ESMTP id 9698984119;\n\tSun, 12 Apr 2026 03:35:49 +0200 (CEST)", "by phobos.denx.de (Postfix, from userid 109)\n id 91C1384227; Sun, 12 Apr 2026 03:35:47 +0200 (CEST)", "from mail-ot1-x32c.google.com (mail-ot1-x32c.google.com\n [IPv6:2607:f8b0:4864:20::32c])\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 2A22883B99\n for <u-boot@lists.denx.de>; Sun, 12 Apr 2026 03:35:43 +0200 (CEST)", "by mail-ot1-x32c.google.com with SMTP id\n 46e09a7af769-7dbcf927395so1933656a34.0\n for <u-boot@lists.denx.de>; Sat, 11 Apr 2026 18:35:43 -0700 (PDT)", "from chromium.org ([73.34.74.121]) by smtp.gmail.com with ESMTPSA id\n 46e09a7af769-7dc2d1aca3asm4242826a34.6.2026.04.11.18.35.37\n (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n Sat, 11 Apr 2026 18:35:38 -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=1775957741; x=1776562541; 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=qHDFXpsecY+51G+59y+hrjJVT8+G9UPWq6cZ1wiGz5M=;\n b=GS1usiIK8Vvj7WPsa/WHjHoQpEWtcF9Y4n6w7MQ1XciGUfCVjj7U5oiO/3yiqC3q7R\n acYjHj1iHVt8TASd8lZ0suArlroDZUHCazvcM0Idf4NE7NSd12NW2cJHYcndDQf4hXEu\n o1i3DOkkDbXXdn0Tq9BZxlCRA/VLbJIC4VvkU=", "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20251104; t=1775957741; x=1776562541;\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=qHDFXpsecY+51G+59y+hrjJVT8+G9UPWq6cZ1wiGz5M=;\n b=gM49Ss6NsiJ3JnIBg4QrOyJzAar1Mr2GhvdEnHgdD1R+8UBk/8/0xUXNfyWtpFage4\n vrMs40RPF5s1HuSmnpanszEgKuFVCux+8EqUrFJfZHYmI5AbZm7qwtjqVl0lDoke74yF\n MVlj4l8hAiNriO3boxRqWx6qskFXu80hLyTjhpkISDCF0DIEKJeENw7ZHLXYy4Rfwuz6\n 1sJJ+mRDllhHBa3t+baB+Dvhxf67KTN6kD/aJE+149AbHCsKnX3RUb2LJSQPEFrt1EDY\n 9vhDAxLJDaT01uLCps0iV3eOoFdo5j4yqWKEBl6Ym9azjLbHPPXHWJCHwJpTYKg9cmMg\n oo/w==", "X-Gm-Message-State": "AOJu0YwS/C3iSW4Ph1xeKBRALsvMTkK6bpqiK0lav0xuSUv14maMS/It\n b6SeNsqEZOmk0m/tA4HsRMJbtoZEqj4OMsNjgHIszaR4rT7A/1OIMOotU9gonImpg89NcDObzGo\n b6P1u4Q==", "X-Gm-Gg": "AeBDies2AxWOsWRw8l1KUdcXyrsjoiMuFNDfuZVR3y/WzdJfFfOL02AyMlhuJm6ASwA\n lgz2hNsf/59w3HNS65LnWxPHN97FaC4LaBvyB1VFRnSaGf5UfOgaO97icWDNSnAEQOv3KMIz5oN\n ezuOBV62gxlg34mlefWLmmQi3YXxoHW59anhr4J0AByj9EMLBNHyEgwyjORZR0GGScx7naXTArw\n ZRQoz3gcZUZbQcuyztB3RGc+gnZLe6nRjKiCguawbB1ioxo7Cd9ePTnOwYpDuQewa9jkiq7x+6y\n cXHh/8r+BsqH4bO23/2IRvzun/+oycdSpQVD0O2LlD+dRcsZNDLqTWe064Jail9beaidXTCMMiu\n msHxPfJ4y1j9qmnUlDL3lQgJwFWODk4onwSzkFbgiXUYTUODT3O10RiSHt4fKTk3rhbj2OSoOcq\n 6CuA5PnYt8rHucwS+PUg==", "X-Received": "by 2002:a05:6830:b83:b0:7d7:faad:e35d with SMTP id\n 46e09a7af769-7dc27db33acmr5813645a34.14.1775957740700;\n Sat, 11 Apr 2026 18:35:40 -0700 (PDT)", "From": "Simon Glass <sjg@chromium.org>", "To": "u-boot@lists.denx.de", "Cc": "Heinrich Schuchardt <xypron.glpk@gmx.de>, Tom Rini <trini@konsulko.com>,\n Simon Glass <simon.glass@canonical.com>, Simon Glass <sjg@chromium.org>", "Subject": "[PATCH 09/12] test: Add tests for unit-test arguments", "Date": "Sat, 11 Apr 2026 19:34:37 -0600", "Message-ID": "<20260412013451.2929001-10-sjg@chromium.org>", "X-Mailer": "git-send-email 2.43.0", "In-Reply-To": "<20260412013451.2929001-1-sjg@chromium.org>", "References": "<20260412013451.2929001-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": "From: Simon Glass <simon.glass@canonical.com>\n\nAdd a set of tests to check the behaviour of test arguments and the ut\ncommand. This includes failure cases, where the wrong type or a\nnon-existent argument is requested.\n\nSigned-off-by: Simon Glass <simon.glass@canonical.com>\nSigned-off-by: Simon Glass <sjg@chromium.org>\n---\n\n test/common/Makefile | 1 +\n test/common/test_args.c | 176 ++++++++++++++++++++++++++++++++++++++++\n 2 files changed, 177 insertions(+)\n create mode 100644 test/common/test_args.c", "diff": "diff --git a/test/common/Makefile b/test/common/Makefile\nindex baefc7b3622..bfeb29346f5 100644\n--- a/test/common/Makefile\n+++ b/test/common/Makefile\n@@ -11,3 +11,4 @@ obj-$(CONFIG_CYCLIC) += cyclic.o\n obj-$(CONFIG_EVENT_DYNAMIC) += event.o\n obj-y += cread.o\n obj-$(CONFIG_$(PHASE_)CMDLINE) += print.o\n+obj-$(CONFIG_$(PHASE_)CMDLINE) += test_args.o\ndiff --git a/test/common/test_args.c b/test/common/test_args.c\nnew file mode 100644\nindex 00000000000..d81039e75ac\n--- /dev/null\n+++ b/test/common/test_args.c\n@@ -0,0 +1,176 @@\n+// SPDX-License-Identifier: GPL-2.0+\n+/*\n+ * Test for unit test arguments\n+ *\n+ * Copyright 2026 Canonical Ltd\n+ * Written by Simon Glass <simon.glass@canonical.com>\n+ */\n+\n+#include <string.h>\n+#include <test/common.h>\n+#include <test/test.h>\n+#include <test/ut.h>\n+\n+/* Test that string arguments work correctly */\n+static int test_args_str_norun(struct unit_test_state *uts)\n+{\n+\tut_asserteq_str(\"hello\", ut_str(0));\n+\n+\treturn 0;\n+}\n+UNIT_TEST_ARGS(test_args_str_norun, UTF_CONSOLE | UTF_MANUAL, common,\n+\t { \"strval\", UT_ARG_STR });\n+\n+/* Test that integer arguments work correctly */\n+static int test_args_int_norun(struct unit_test_state *uts)\n+{\n+\tut_asserteq(1234, ut_int(0));\n+\n+\treturn 0;\n+}\n+UNIT_TEST_ARGS(test_args_int_norun, UTF_CONSOLE | UTF_MANUAL, common,\n+\t { \"intval\", UT_ARG_INT });\n+\n+/* Test that boolean arguments work correctly */\n+static int test_args_bool_norun(struct unit_test_state *uts)\n+{\n+\tut_asserteq(true, ut_bool(0));\n+\n+\treturn 0;\n+}\n+UNIT_TEST_ARGS(test_args_bool_norun, UTF_CONSOLE | UTF_MANUAL, common,\n+\t { \"boolval\", UT_ARG_BOOL });\n+\n+/* Test multiple arguments of different types */\n+static int test_args_multi_norun(struct unit_test_state *uts)\n+{\n+\tut_asserteq_str(\"test\", ut_str(0));\n+\tut_asserteq(42, ut_int(1));\n+\tut_asserteq(true, ut_bool(2));\n+\n+\treturn 0;\n+}\n+UNIT_TEST_ARGS(test_args_multi_norun, UTF_CONSOLE | UTF_MANUAL, common,\n+\t { \"str\", UT_ARG_STR },\n+\t { \"num\", UT_ARG_INT },\n+\t { \"flag\", UT_ARG_BOOL });\n+\n+/* Test optional arguments with defaults */\n+static int test_args_optional_norun(struct unit_test_state *uts)\n+{\n+\t/* Required arg should match what was passed */\n+\tut_asserteq_str(\"required\", ut_str(0));\n+\n+\t/* Optional args should have default values if not provided */\n+\tut_asserteq(99, ut_int(1));\n+\tut_asserteq(false, ut_bool(2));\n+\n+\treturn 0;\n+}\n+UNIT_TEST_ARGS(test_args_optional_norun, UTF_CONSOLE | UTF_MANUAL, common,\n+\t { \"req\", UT_ARG_STR },\n+\t { \"opt_int\", UT_ARG_INT, UT_ARGF_OPTIONAL, { .vint = 99 } },\n+\t { \"opt_bool\", UT_ARG_BOOL, UT_ARGF_OPTIONAL, { .vbool = false } });\n+\n+/* Test requesting wrong type - ut_int() on a string arg should fail */\n+static int test_args_wrongtype_norun(struct unit_test_state *uts)\n+{\n+\t/* This should fail - asking for int but arg is string */\n+\tut_asserteq(0, ut_int(0));\n+\tut_asserteq(true, uts->arg_error);\n+\n+\treturn 0;\n+}\n+UNIT_TEST_ARGS(test_args_wrongtype_norun, UTF_MANUAL, common,\n+\t { \"strval\", UT_ARG_STR });\n+\n+/* Test requesting invalid arg number - ut_str(1) when only arg 0 exists */\n+static int test_args_badnum_norun(struct unit_test_state *uts)\n+{\n+\t/* This should fail - asking for arg 1 but only arg 0 exists */\n+\tut_asserteq_ptr(NULL, ut_str(1));\n+\tut_asserteq(true, uts->arg_error);\n+\n+\treturn 0;\n+}\n+UNIT_TEST_ARGS(test_args_badnum_norun, UTF_MANUAL, common,\n+\t { \"strval\", UT_ARG_STR });\n+\n+/* Wrapper test that runs the manual tests with proper arguments */\n+static int test_args(struct unit_test_state *uts)\n+{\n+\tut_assertok(run_command(\"ut -f common test_args_str_norun strval=hello\",\n+\t\t\t\t0));\n+\tut_assertok(run_command(\"ut -f common test_args_int_norun intval=1234\",\n+\t\t\t\t0));\n+\tut_assertok(run_command(\"ut -f common test_args_bool_norun boolval=1\",\n+\t\t\t\t0));\n+\tut_assertok(run_command(\"ut -f common test_args_multi_norun str=test num=42 flag=1\",\n+\t\t\t\t0));\n+\tut_assertok(run_command(\"ut -f common test_args_optional_norun req=required\",\n+\t\t\t\t0));\n+\n+\treturn 0;\n+}\n+COMMON_TEST(test_args, UTF_CONSOLE);\n+\n+/* Test argument-parsing failure cases - these should all fail */\n+static int test_args_fail(struct unit_test_state *uts)\n+{\n+\t/* Missing required argument - should fail */\n+\tut_asserteq(1, run_command(\"ut -f common test_args_str_norun\", 0));\n+\tut_assert_nextline(\"Missing required argument 'strval' for test 'test_args_str_norun'\");\n+\tut_assert_nextline_regex(\"Tests run: 1,.*failures: 1\");\n+\tut_assert_console_end();\n+\n+\t/* Unknown argument name - should fail */\n+\tut_asserteq(1, run_command(\"ut -f common test_args_str_norun badarg=x\",\n+\t\t\t\t 0));\n+\tut_assert_nextline(\"Unknown argument 'badarg' for test 'test_args_str_norun'\");\n+\tut_assert_nextline_regex(\"Tests run: 1,.*failures: 1\");\n+\tut_assert_console_end();\n+\n+\t/* Invalid format (no = sign) - should fail */\n+\tut_asserteq(1, run_command(\"ut -f common test_args_str_norun strval\",\n+\t\t\t\t 0));\n+\tut_assert_nextline(\"Invalid argument 'strval' (expected key=value)\");\n+\tut_assert_nextline_regex(\"Tests run: 1,.*failures: 1\");\n+\tut_assert_console_end();\n+\n+\treturn 0;\n+}\n+COMMON_TEST(test_args_fail, UTF_CONSOLE);\n+\n+/* Test that requesting wrong type fails - ut_int() on string arg */\n+static int test_args_wrongtype(struct unit_test_state *uts)\n+{\n+\tut_asserteq(1,\n+\t\t run_command(\"ut -R -f common test_args_wrongtype_norun strval=hello\",\n+\t\t\t\t0));\n+\tut_assert_nextline(\"Test: test_args_wrongtype_norun: test_args.c\");\n+\tut_assert_nextline_regex(\n+\t\t\"test/common/test_args.c:.*, test_args_wrongtype_norun\\\\(\\\\): ut_int\\\\(\\\\) type check: arg 0 is not an int\");\n+\tut_assert_nextline(\"Test 'test_args_wrongtype_norun' failed 1 times\");\n+\tut_assert_nextline_regex(\"Tests run: 1,.*failures: 1\");\n+\tut_assert_console_end();\n+\n+\treturn 0;\n+}\n+COMMON_TEST(test_args_wrongtype, UTF_CONSOLE);\n+\n+/* Test that requesting invalid arg number fails */\n+static int test_args_badnum(struct unit_test_state *uts)\n+{\n+\tut_asserteq(1,\n+\t\t run_command(\"ut -R -f common test_args_badnum_norun strval=hello\",\n+\t\t\t\t0));\n+\tut_assert_nextline(\"Test: test_args_badnum_norun: test_args.c\");\n+\tut_assert_nextline_regex(\n+\t\t\"test/common/test_args.c:.*, test_args_badnum_norun\\\\(\\\\): ut_str\\\\(\\\\) arg check: arg 1 is invalid \\\\(arg_count=1\\\\)\");\n+\tut_assert_nextline(\"Test 'test_args_badnum_norun' failed 1 times\");\n+\tut_assert_nextline_regex(\"Tests run: 1,.*failures: 1\");\n+\tut_assert_console_end();\n+\n+\treturn 0;\n+}\n+COMMON_TEST(test_args_badnum, UTF_CONSOLE);\n", "prefixes": [ "09/12" ] }