From patchwork Tue May 30 11:03:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhangjin Wu X-Patchwork-Id: 100755 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp2099598vqr; Tue, 30 May 2023 04:15:01 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5cC9cGMiE7iKdiNvRSP2Hjt7gsj7MlK6OnEXSUnu6CMgSfLaOqZUhAD0OwgQxpzOQTCRiY X-Received: by 2002:a05:6a20:1611:b0:110:390f:6806 with SMTP id l17-20020a056a20161100b00110390f6806mr2215263pzj.57.1685445301088; Tue, 30 May 2023 04:15:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685445301; cv=none; d=google.com; s=arc-20160816; b=EDHxzO3eDgP5uWCG8tvAJhXLl/3jW959VC/asHsrhAFmxrw431Y8vahBlqwuYboSTr /PpOSLu1Bhh5T3eq7SdIq5XTUOqWuxXmu3F3QVk68PDcaDvoyZIr4E+ZL1FyLsUvYNBE +bfr+BEPQgwii2SSxubL2Q9nF8kGlMiN+IALxVPxnu6i42TOePrE2Qa4wp0rFs9r3ZZW kioDTN3m7pNKTHF4rLjcJYQryWJ4B/R7gQmMuwmjr/ZwUmHIb1LqLmE+rP2GxPkbg/3m 1cjFqlqsQymhodVM2ZYWeJfR6WEq6gk4g3EYzRgPNY9ideROPvrz0KSCTLKy9E//4zmV rZpQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:feedback-id:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from; bh=o4MzGiVumF+GHC28YeyNDCSmWjLSsJipRem8JBPPVMY=; b=xDdXEwdMdPnZQs94cjstIarLY0w3OzzkaO+JrOIUnKNYieSHD53SiJunARqLFiu+wf 0bUYNzYSctqYj8dTmKBwKuLGBelNjDicsX3/TibO0MS8i78CMkgfpAby5Q/fyf2LE8yW wcvmm+q6XJ8/c7qOI/x3yPhH6d93kvQiwKkOlNnyq1h3RteIj3gKlVLg46vfjDFt03lc KnRTe89+ofWHVMomWJ1pqg4K/EYp0WAaybCNaGNGj8bbKt7FSIdwxkO14Ekk/g4kCGKL EwIhbDdlKPCgegawRL+aSPZB6plgEkCc9+PL1dTZtZOz70VlclwlJVp++6rXeoqOTxAJ PODQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y7-20020aa793c7000000b0064d32440768si1533028pff.138.2023.05.30.04.14.46; Tue, 30 May 2023 04:15:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231770AbjE3LDm (ORCPT + 99 others); Tue, 30 May 2023 07:03:42 -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 X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:tinylab.org:qybglogicsvrsz:qybglogicsvrsz3a-3 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1767317491791177776?= X-GMAIL-MSGID: =?utf-8?q?1767317491791177776?= The global 'run' setting is added to allow specify the running iterations, for example: NOLIBC_TEST=run: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/selftests/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 = 0; int max = INT_MAX; + int run = 1; + int selected = 0; int ret = 0; int err; int idx; + int i; char *test; environ = 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 = argv[1]; if (!test) @@ -992,14 +995,27 @@ int main(int argc, char **argv, char **envp) if (colon) *(colon++) = '\0'; - for (idx = 0; test_names[idx].name; idx++) { - if (strcmp(test, test_names[idx].name) == 0) + if (strcmp(test, "run") != 0) { + for (idx = 0; test_names[idx].name; idx++) { + if (strcmp(test, test_names[idx].name) == 0) + break; + } + } else { + value = colon; + if (value && *value) + run = atoi(value); + + test = comma; + if (test && *test) + continue; + else break; } if (!test_names[idx].name) { printf("Ignoring unknown test name '%s'\n", test); } else { + selected++; test_names[idx].run = 1; /* 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); /* disable the left tests */ - for (idx = 0; test_names[idx].name; idx++) { - if (test_names[idx].run != 1) - test_names[idx].run = 0; + if (selected != 0) { + for (idx = 0; test_names[idx].name; idx++) { + if (test_names[idx].run != 1) + test_names[idx].run = 0; + } } } /* run everything or the test mentioned */ - for (idx = 0; test_names[idx].name; idx++) { - if (test_names[idx].run != 0) { - printf("Running test '%s', from %d to %d\n", test_names[idx].name, test_names[idx].min, test_names[idx].max); - err = test_names[idx].func(test_names[idx].min, test_names[idx].max); - ret += err; - printf("Errors during this test: %d\n\n", err); - } - } + printf("Running iteration(s): %d\n\n", run); + for (i = 0; i < run; i++) { + printf("Current iteration: %d\n\n", i + 1); + ret = 0; + for (idx = 0; test_names[idx].name; idx++) { + if (test_names[idx].run != 0) { + printf("Running test '%s', from %d to %d\n", test_names[idx].name, test_names[idx].min, test_names[idx].max); + err = test_names[idx].func(test_names[idx].min, test_names[idx].max); + ret += err; + printf("Errors during this test: %d\n\n", err); + } + } - printf("Total number of errors: %d\n", ret); + printf("Total number of errors in the %d iteration(s): %d\n\n", i + 1, ret); + } if (getpid() == 1) { /* we're running as init, there's no other process on the