Skip to content

Commit 55953c7

Browse files
committed
quote-stress-test: accept arguments to test via the command-line
When the stress test reported a problem with quoting certain arguments, it is helpful to have a facility to play with those arguments in order to find out whether variations of those arguments are affected, too. Let's allow `test-run-command quote-stress-test -- <args>` to be used for that purpose. Signed-off-by: Johannes Schindelin <[email protected]>
1 parent ad15592 commit 55953c7

File tree

1 file changed

+22
-13
lines changed

1 file changed

+22
-13
lines changed

t/helper/test-run-command.c

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -83,25 +83,34 @@ static int quote_stress_test(int argc, const char **argv)
8383

8484
for (i = 0; i < trials; i++) {
8585
struct child_process cp = CHILD_PROCESS_INIT;
86-
size_t arg_count = 1 + (my_random() % 5), arg_offset;
86+
size_t arg_count, arg_offset;
8787
int ret = 0;
8888

8989
argv_array_clear(&args);
9090
argv_array_pushl(&args, "test-run-command",
9191
"quote-echo", NULL);
9292
arg_offset = args.argc;
93-
for (j = 0; j < arg_count; j++) {
94-
char buf[20];
95-
size_t min_len = 1;
96-
size_t arg_len = min_len +
97-
(my_random() % (ARRAY_SIZE(buf) - min_len));
98-
99-
for (k = 0; k < arg_len; k++)
100-
buf[k] = special[my_random() %
101-
ARRAY_SIZE(special)];
102-
buf[arg_len] = '\0';
103-
104-
argv_array_push(&args, buf);
93+
94+
if (argc > 0) {
95+
trials = 1;
96+
arg_count = argc;
97+
for (j = 0; j < arg_count; j++)
98+
argv_array_push(&args, argv[j]);
99+
} else {
100+
arg_count = 1 + (my_random() % 5);
101+
for (j = 0; j < arg_count; j++) {
102+
char buf[20];
103+
size_t min_len = 1;
104+
size_t arg_len = min_len +
105+
(my_random() % (ARRAY_SIZE(buf) - min_len));
106+
107+
for (k = 0; k < arg_len; k++)
108+
buf[k] = special[my_random() %
109+
ARRAY_SIZE(special)];
110+
buf[arg_len] = '\0';
111+
112+
argv_array_push(&args, buf);
113+
}
105114
}
106115

107116
cp.argv = args.argv;

0 commit comments

Comments
 (0)