From patchwork Mon Dec 29 16:06:04 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1104 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=1767024409; bh=iN4pgl81ktR49OVjQCNAzF6Q66V2HtR2wWriaZ06TIg=; 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=Z4Yh8OzaKjir/NkyvZ9abWIlLE4wghaSrTgexZbmJWLHrA+ijNgW9f9nR4XACmE5r py9l6t5Vq/KPlOo9iS72KoaEAayo+enHz5LeAPgi6IgWMCjSs8t6Nz2EHav2N9j6W7 uH4oZMV3ElSJ0UXVITpVvEqiZNdQCq9FLbaQSYf0t+CPSv60lQBCVpxEIyJbEcf/25 AFx0T2fBa0qR+eny7VrGypKBFzYjmNwuKnIUNQosEczYVBqdoz+/bBcPuzH87u8Afv kLg02Tst2zNj9iyW4O4XO07hWrbYtl1ShX32xMXcbFO2O/w/q3b+aTtAruyk25VMbN dBaIIi43et9dw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 3EF5968F2C for ; Mon, 29 Dec 2025 09:06:49 -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 ndOX21oXKT2S for ; Mon, 29 Dec 2025 09:06:49 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767024409; bh=iN4pgl81ktR49OVjQCNAzF6Q66V2HtR2wWriaZ06TIg=; 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=Z4Yh8OzaKjir/NkyvZ9abWIlLE4wghaSrTgexZbmJWLHrA+ijNgW9f9nR4XACmE5r py9l6t5Vq/KPlOo9iS72KoaEAayo+enHz5LeAPgi6IgWMCjSs8t6Nz2EHav2N9j6W7 uH4oZMV3ElSJ0UXVITpVvEqiZNdQCq9FLbaQSYf0t+CPSv60lQBCVpxEIyJbEcf/25 AFx0T2fBa0qR+eny7VrGypKBFzYjmNwuKnIUNQosEczYVBqdoz+/bBcPuzH87u8Afv kLg02Tst2zNj9iyW4O4XO07hWrbYtl1ShX32xMXcbFO2O/w/q3b+aTtAruyk25VMbN dBaIIi43et9dw== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 2E52768CAC for ; Mon, 29 Dec 2025 09:06:49 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767024406; bh=ArJIKOEWbdITvqWal4ScFayvOoD1q72b17nE/NApgr0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CV1kbX2yYgEfmp2N4VHt/7/vkG97epK+PJYUgHsexL11sPiwxDMO1bJVu+5uLDduz 5o2rRRva+KNKzEOshCxTjo4v1SgiqfsN1s/exlItnhuDcJFnM5JPW3ExrXP6h1JgWh tdy0Iv6Xq9mmpIzooedrdNvB64feSstEkAzlK5NtWafDaJgS9Ccfe15ptvbSDFMGOB knjbgN15OGsKCgcFGvkSn8LuZ6+6/a6yZpmTnIlh72sVbf7nLLbfRge3SoZUbD7acg 8SfQAAF+o7KXckGCv3zVFsLRB6joKyK27iKJtB5DsWCrMc4XF5bDcd0wAAmDc/jUJM uobpeyZjHwGNg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 6F8FF68CAC; Mon, 29 Dec 2025 09:06:46 -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 m-SNVYFoO__x; Mon, 29 Dec 2025 09:06:46 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767024402; bh=ffbmLaCsROtGJXJ+WxseFeziI54SBMPT6NMG+YicSic=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MzLKq5iIomCuBt1p7uHf0nkXeHCo2CLm8vB2oEUG8arDDxGpI1PMxfL9KLgrgby4B 8q3UUUKivTpKNcisjO7U84iZoqgEj7SqYR8BNEbA3d6CQ3A/QyYQr2NbxXBssycp+W za0o7Nc8qOzarbMAeKFzs/1B53h3a60fVXIEXGsGLuxo0BbIG6bUmnQnWRBFU+DAe8 UMgH+E9NjLnnoA0Gun2ZaNo5Hcf9/AR4r+RrGCbihqzvYtrUtBNdjEW6ir7aICo2bd dOKF6ou2fI1yER/2eIUzfXUFYMPfwLWcg/w2IEjW9uHR5VvCodEScD7bQPQPYqdNIL zx9zxJK6ZiT3w== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id B765E68B78; Mon, 29 Dec 2025 09:06:41 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Mon, 29 Dec 2025 09:06:04 -0700 Message-ID: <20251229160611.3899708-7-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: BVO7P3FQPBNWF6AHWDWI3CTAB3K6QPP3 X-Message-ID-Hash: BVO7P3FQPBNWF6AHWDWI3CTAB3K6QPP3 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 6/9] test: ut: Refactor argument processing to use a loop 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 The current argument-parsing logic uses switch (str[1]) which only processes the second character of each argument. This prevents combining multiple single-character flags in one argument (e.g., -fm). Refactor the code to use a for loop that iterates through all characters in the argument. For flags that take a value (like -r and -I), use goto to skip the rest of the argument after processing. This allows combined flags like -fmR instead of requiring -f -m -R. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- test/cmd_ut.c | 41 ++++++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/test/cmd_ut.c b/test/cmd_ut.c index 050f7ee6caf..37144242099 100644 --- a/test/cmd_ut.c +++ b/test/cmd_ut.c @@ -267,26 +267,29 @@ static int do_ut(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) while (argc > 0 && *argv[0] == '-') { const char *str = argv[0]; - switch (str[1]) { - case 'r': - runs_per_text = dectoul(str + 2, NULL); - break; - case 'f': - case 'm': - force_run = true; - break; - case 'I': - test_insert = str + 2; - if (!strchr(test_insert, ':')) - return CMD_RET_USAGE; - break; - case 'R': - keep_record = true; - break; - case 's': - show_suites = true; - break; + for (str++; *str; str++) { + switch (*str) { + case 'r': + runs_per_text = dectoul(str + 1, NULL); + goto next_arg; + case 'f': + case 'm': + force_run = true; + break; + case 'I': + test_insert = str + 1; + if (!strchr(test_insert, ':')) + return CMD_RET_USAGE; + goto next_arg; + case 'R': + keep_record = true; + break; + case 's': + show_suites = true; + break; + } } +next_arg: argv++; argc--; }