From nobody Sun Feb 8 21:29:22 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E141BC77B73 for ; Tue, 30 May 2023 11:03:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231772AbjE3LDn (ORCPT ); Tue, 30 May 2023 07:03:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49318 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231696AbjE3LDj (ORCPT ); Tue, 30 May 2023 07:03:39 -0400 Received: from bg4.exmail.qq.com (bg4.exmail.qq.com [43.155.67.158]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C8B05D9; Tue, 30 May 2023 04:03:37 -0700 (PDT) X-QQ-mid: bizesmtp67t1685444612t08p4xww Received: from linux-lab-host.localdomain ( [119.123.130.226]) by bizesmtp.qq.com (ESMTP) with id ; Tue, 30 May 2023 19:03:31 +0800 (CST) X-QQ-SSF: 01200000000000D0V000000A0000000 X-QQ-FEAT: C46Rb8GPIEc160nmUqFUHiFICVb8yJ5e11pqzLjXmS2/y5C6aYAhQb0+Cg9Tj G3ora3iXuOFD2kdO18FYoRZpzosUJ632Ckb/qSW3VPNCJimOOJtBcHY61W3wIe1KHd8Ku/m SNaBXZkq2EDAvjm3Z2XXHd9yz9p9K+IWKqic4/ShSxQLPa+MhRk+KsuDEZwgII7hmu9g0Hj OD4MUc56yMOVYx8jF1UmiV4xnslxBAOf8TydDIQUBAo1c/pZb2cTMLZhdKOyDiqzb5R5A3t sM7sjtpkHDsR1PkkNnf2L64rsCpz9zPGGU8rWiCfNGmSBMcaIdRNSmIkwsJ1IDxPvn6f6Lv /tN5H40PTJIIHyFAN1kYgY95zls1dyh5pu+erFw4eSHkrjvLHL//EpzyhXCHPv1LNHhyht+ X-QQ-GoodBg: 0 X-BIZMAIL-ID: 17642228944967858726 From: Zhangjin Wu To: w@1wt.eu Cc: falcon@tinylab.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-riscv@lists.infradead.org, thomas@t-8ch.de Subject: [PATCH 2/4] selftests/nolibc: add rerun support Date: Tue, 30 May 2023 19:03:30 +0800 Message-Id: <247d4d69a5e229446fc43efa49cc4fa36ccd600a.1685443199.git.falcon@tinylab.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:tinylab.org:qybglogicsvrsz:qybglogicsvrsz3a-3 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The global 'run' setting is added to allow specify the running iterations, for example: NOLIBC_TEST=3Drun:5,syscall:1 This setting allows to run the first syscall for 5 times. Signed-off-by: Zhangjin Wu --- tools/testing/selftests/nolibc/nolibc-test.c | 53 ++++++++++++++------ 1 file changed, 38 insertions(+), 15 deletions(-) diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/s= elftests/nolibc/nolibc-test.c index be718fa5dc86..b8fd7fcf56a6 100644 --- a/tools/testing/selftests/nolibc/nolibc-test.c +++ b/tools/testing/selftests/nolibc/nolibc-test.c @@ -956,9 +956,12 @@ int main(int argc, char **argv, char **envp) { int min =3D 0; int max =3D INT_MAX; + int run =3D 1; + int selected =3D 0; int ret =3D 0; int err; int idx; + int i; char *test; =20 environ =3D envp; @@ -974,7 +977,7 @@ int main(int argc, char **argv, char **envp) /* the definition of a series of tests comes from either argv[1] or the * "NOLIBC_TEST" environment variable. It's made of a comma-delimited * series of test names and optional ranges: - * syscall:5-15[:.*],stdlib:8-10 + * run:3,syscall:5-15[:.*],stdlib:8-10 */ test =3D argv[1]; if (!test) @@ -992,14 +995,27 @@ int main(int argc, char **argv, char **envp) if (colon) *(colon++) =3D '\0'; =20 - for (idx =3D 0; test_names[idx].name; idx++) { - if (strcmp(test, test_names[idx].name) =3D=3D 0) + if (strcmp(test, "run") !=3D 0) { + for (idx =3D 0; test_names[idx].name; idx++) { + if (strcmp(test, test_names[idx].name) =3D=3D 0) + break; + } + } else { + value =3D colon; + if (value && *value) + run =3D atoi(value); + + test =3D comma; + if (test && *test) + continue; + else break; } =20 if (!test_names[idx].name) { printf("Ignoring unknown test name '%s'\n", test); } else { + selected++; test_names[idx].run =3D 1; =20 /* The test was named, it will be called at least @@ -1038,24 +1054,31 @@ int main(int argc, char **argv, char **envp) } while (test && *test); =20 /* disable the left tests */ - for (idx =3D 0; test_names[idx].name; idx++) { - if (test_names[idx].run !=3D 1) - test_names[idx].run =3D 0; + if (selected !=3D 0) { + for (idx =3D 0; test_names[idx].name; idx++) { + if (test_names[idx].run !=3D 1) + test_names[idx].run =3D 0; + } } } =20 /* run everything or the test mentioned */ - for (idx =3D 0; test_names[idx].name; idx++) { - if (test_names[idx].run !=3D 0) { - printf("Running test '%s', from %d to %d\n", test_names[idx].name, test= _names[idx].min, test_names[idx].max); - err =3D test_names[idx].func(test_names[idx].min, test_names[idx].max); - ret +=3D err; - printf("Errors during this test: %d\n\n", err); - } - } + printf("Running iteration(s): %d\n\n", run); + for (i =3D 0; i < run; i++) { + printf("Current iteration: %d\n\n", i + 1); =20 + ret =3D 0; + for (idx =3D 0; test_names[idx].name; idx++) { + if (test_names[idx].run !=3D 0) { + printf("Running test '%s', from %d to %d\n", test_names[idx].name, tes= t_names[idx].min, test_names[idx].max); + err =3D test_names[idx].func(test_names[idx].min, test_names[idx].max); + ret +=3D err; + printf("Errors during this test: %d\n\n", err); + } + } =20 - printf("Total number of errors: %d\n", ret); + printf("Total number of errors in the %d iteration(s): %d\n\n", i + 1, r= et); + } =20 if (getpid() =3D=3D 1) { /* we're running as init, there's no other process on the --=20 2.25.1