@matheusbsbs / matheus-bagliano / commits / 55953c77c0
Fork 0

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 <johannes.schindelin@gmx.de>

Johannes Schindelin committed Sep 20, 2019 at 19:09 UTC 55953c77c0bfcb727ffd7e293e4661b7a24b791b
1 file changed +22 -13
t/helper/test-run-command.c
+22 -13
@@ -83,25 +83,34 @@ static int quote_stress_test(int argc, const char **argv)
83
84 for (i = 0; i < trials; i++) {
85 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;
87 int ret = 0;
88
89 argv_array_clear(&args);
90 argv_array_pushl(&args, "test-run-command",
91 "quote-echo", NULL);
92 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 + }
114 }
115
116 cp.argv = args.argv;