From patchwork Tue May 30 10:56:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhangjin Wu X-Patchwork-Id: 100752 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp2093700vqr; Tue, 30 May 2023 04:04:53 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5p+FUM7xXaWjBHYttmCfzKMwXhY9N1RQBsRqBSh1iQceFx9F1Gyvu0TxGDAkIX5cz7DmI1 X-Received: by 2002:a05:6a20:1450:b0:10a:ba3a:42dd with SMTP id a16-20020a056a20145000b0010aba3a42ddmr2130081pzi.44.1685444693136; Tue, 30 May 2023 04:04:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685444693; cv=none; d=google.com; s=arc-20160816; b=pejoF1oMTNn5BTe4cvO0s1D+EN0+QsAjKRzJHXq0YpMmiaG3VNeminrvF6EXoctmhR M/N0+X0rX/ppdrMLAbainw4eqbWNdnvCp/pvnBSvtEbfg0L9npG0/aj/SNFdj0u2NciB mNxWZcELGIxwj+ZsYPKGzeB9LPB/90TaNzNYrvOwJcGQaVgoNMIg4AqwC4ScZAw5UtZB LN97BkzD59Wo0H7vE1sRVWXbUktNaDBagZupZfFsW7wGtked4/N+R9a6evC5Pk12yD3U 6J53BH8bjtVr7eXiroJWOeM64EOyVHxpThj+vUAcD9zbr4MkZr58+FvdQpRRUom6cE7u KGbg== 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=g12FJ5ZYTLzc3CPir9WNEzp9sko8pQzQva70aFdxjNc=; b=SvgjdijVmxVO9LfIEG1h+Mxi2VnVVr5Sev34S9g2/Rw9q5+s+aMvfqOyjHCkawANfH /h+ZeEUhWW3YO0Eoxzs1KI2p5s8Zs/nO6tyjg7TqWMbjJEU3Y9GYDAVhvWHQjUHNHGs+ 6lQfC8AsDu2pUBJ9Quyx7VgaxrmymESbKpAV+5p5zS5AFLaj+XRMvGTg6NwW1kTi45Ql m34Sx8nbOEIjX4fd6t0U7ROhLpc5yHpMFdR9ey+dD7CIkp45qjpFdkSmfQgDxsg8aNrM LToj+y4fsnLQpgxPuIk3tb9PsG+NCiYEmOublXS9GIWQyKkC7LaA/3abRYf4pcVwSpfn j+eA== 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 24-20020a631258000000b00520603e8e25si7803854pgs.67.2023.05.30.04.04.30; Tue, 30 May 2023 04:04:52 -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 S229739AbjE3K4Y (ORCPT + 99 others); Tue, 30 May 2023 06:56:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44664 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231361AbjE3K4V (ORCPT ); Tue, 30 May 2023 06:56:21 -0400 Received: from bg4.exmail.qq.com (bg4.exmail.qq.com [43.154.221.58]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E598AF7; Tue, 30 May 2023 03:56:17 -0700 (PDT) X-QQ-mid: bizesmtp72t1685444172tvjqxqzn Received: from linux-lab-host.localdomain ( [119.123.130.226]) by bizesmtp.qq.com (ESMTP) with id ; Tue, 30 May 2023 18:56:11 +0800 (CST) X-QQ-SSF: 01200000000000D0V000000A0000000 X-QQ-FEAT: IV30oiqrgAYLeAVOtqPY/w4sV51ufOZgvH9veDK9Ln5rvQZwJVqfvQebBNkb0 rWdg0XWxELEr+D+JJDpmJRKXEGbTrqUmljotAwMSeKgbivwAh8Yc83kjym3D0j3G2Y/rfbT rmDMziIaF1RHSZ0VHwappE4cH+2ibJvPOUXuZeZixvII0+kcxU/CNsIAfWDAPnGiPA/X4Ry uhcwpAPuHw//KlJZuq0nj2KBV/mhrO1z6IjLwWZl6tEPenU5NHMlwsxmdxFUZgT39wwGWzW zUWW0R3DR8s36VqJKPbbMYeeSntiCd0UAIcDVkGpuo+W1S9x5EyFdJl4W5eKH6bam/lftYQ 9/imcDdRSqPSe6FQ4g46x2VQalG7yfX6OA+ka7s9XC8huDYjbWd2rJlVOqjkRRquGnxwI1c X-QQ-GoodBg: 0 X-BIZMAIL-ID: 16230640011585094560 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 1/4] selftests/nolibc: allow rerun with the same settings Date: Tue, 30 May 2023 18:56:10 +0800 Message-Id: <32d4ec1c3cabae5c1baabf85627b81d6ede01518.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?1767316854892564659?= X-GMAIL-MSGID: =?utf-8?q?1767316854892564659?= Record the user settings from NOLIBC_TEST and allow reuse them in another run iteration. This allows to rerun the test cases with the same setting. Signed-off-by: Zhangjin Wu --- tools/testing/selftests/nolibc/nolibc-test.c | 46 ++++++++++++-------- 1 file changed, 29 insertions(+), 17 deletions(-) diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/selftests/nolibc/nolibc-test.c index fd7515f6b1d2..be718fa5dc86 100644 --- a/tools/testing/selftests/nolibc/nolibc-test.c +++ b/tools/testing/selftests/nolibc/nolibc-test.c @@ -46,6 +46,9 @@ char **environ; /* definition of a series of tests */ struct test { const char *name; /* test name */ + int min; + int max; + int run; int (*func)(int min, int max); /* handler */ }; @@ -940,12 +943,12 @@ int prepare(void) } /* This is the definition of known test names, with their functions */ -static const struct test test_names[] = { +static struct test test_names[] = { /* add new tests here */ - { .name = "syscall", .func = run_syscall }, - { .name = "stdlib", .func = run_stdlib }, - { .name = "vfprintf", .func = run_vfprintf }, - { .name = "protection", .func = run_protection }, + { .name = "syscall", .min = 0, .max = INT_MAX, .run = -1, .func = run_syscall }, + { .name = "stdlib", .min = 0, .max = INT_MAX, .run = -1, .func = run_stdlib }, + { .name = "vfprintf", .min = 0, .max = INT_MAX, .run = -1, .func = run_vfprintf }, + { .name = "protection", .min = 0, .max = INT_MAX, .run = -1, .func = run_protection }, { 0 } }; @@ -994,7 +997,11 @@ int main(int argc, char **argv, char **envp) break; } - if (test_names[idx].name) { + if (!test_names[idx].name) { + printf("Ignoring unknown test name '%s'\n", test); + } else { + test_names[idx].run = 1; + /* The test was named, it will be called at least * once. We may have an optional range at * here, which defaults to the full range. @@ -1022,27 +1029,32 @@ int main(int argc, char **argv, char **envp) value = colon; } - /* now's time to call the test */ - printf("Running test '%s'\n", test_names[idx].name); - err = test_names[idx].func(min, max); - ret += err; - printf("Errors during this test: %d\n\n", err); + test_names[idx].min = min; + test_names[idx].max = max; } while (colon && *colon); - } else - printf("Ignoring unknown test name '%s'\n", test); + } test = comma; } while (test && *test); - } else { - /* no test mentioned, run everything */ + + /* disable the left tests */ for (idx = 0; test_names[idx].name; idx++) { - printf("Running test '%s'\n", test_names[idx].name); - err = test_names[idx].func(min, max); + 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("Total number of errors: %d\n", ret); if (getpid() == 1) {