From: Zhangjin Wu <falcon@tinylab.org>
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 [thread overview]
Message-ID: <247d4d69a5e229446fc43efa49cc4fa36ccd600a.1685443199.git.falcon@tinylab.org> (raw)
In-Reply-To: <cover.1685443199.git.falcon@tinylab.org>
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 <falcon@tinylab.org>
---
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
--
2.25.1
next prev parent reply other threads:[~2023-05-30 11:03 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-30 10:47 [PATCH 0/4] selftests/nolibc: add user-space 'efault' handler Zhangjin Wu
2023-05-30 10:56 ` [PATCH 1/4] selftests/nolibc: allow rerun with the same settings Zhangjin Wu
2023-05-30 11:03 ` Zhangjin Wu [this message]
2023-05-30 11:05 ` [PATCH 3/4] selftests/nolibc: add user space efault handler Zhangjin Wu
2023-05-30 11:08 ` [PATCH 4/4] selftests/nolibc: add user-space efault restore test case Zhangjin Wu
2023-06-04 11:05 ` [PATCH 0/4] selftests/nolibc: add user-space 'efault' handler Willy Tarreau
2023-06-04 19:07 ` Thomas Weißschuh
2023-06-04 19:14 ` Willy Tarreau
2023-06-06 4:04 ` Zhangjin Wu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=247d4d69a5e229446fc43efa49cc4fa36ccd600a.1685443199.git.falcon@tinylab.org \
--to=falcon@tinylab.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=thomas@t-8ch.de \
--cc=w@1wt.eu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®