[PATCH 1/4] selftests/nolibc: allow rerun with the same settings

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 <falcon@xxxxxxxxxxx>
---
 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 <colon>
 				 * 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) {
-- 
2.25.1




[Index of Archives]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux