Re: [PATCH] t5411: consistent result for proc-receive broken test
- From
Jiang Xin <worldhello.net@gmail.com>
- Date
- Nov 9, 2020, 07:29 UTC
- Message-ID
- <CANYiYbHQKshFg=1xAv8MFfSjmFfQ0uJRm3mQBnZMsTd1n7R-Ow@mail.gmail.com>
- In-Reply-To
- <20201107025746.13064-1-worldhello.net@gmail.com>
Jiang Xin <worldhello.net@gmail.com> 于2020年11月7日周六 上午10:57写道:
Show 21 quoted lines
> @@ -75,13 +78,18 @@ static void proc_receive_read_commands(struct packet_reader *reader,
> if (packet_reader_read(reader) != PACKET_READ_NORMAL)
> break;
>
> + if (die_readline)
> + die("die with the --die-readline option");
> +
> if (parse_oid_hex(reader->line, &old_oid, &p) ||
> *p++ != ' ' ||
> parse_oid_hex(p, &new_oid, &p) ||
> - *p++ != ' ' ||
> - die_readline)
> + *p++ != ' ') {
> + while (packet_reader_read(reader) != PACKET_READ_EOF)
> + ; /* do nothing */
> die("protocol error: expected 'old new ref', got '%s'",
> reader->line);
> + }
> refname = p;
> FLEX_ALLOC_STR(cmd, ref_name, refname);
> oidcpy(&cmd->old_oid, &old_oid);Still have problems under the stress test. Today I figured out how to run stress test by setting proper environment variable GIT_TEST_STRESS_LOAD without consuming too many resources and leading to random strange errors. E.g.:
$ GIT_TEST_STRESS_LOAD=11 sh t5411-proc-receive-hook.sh -v --stress
Will send patch v2 later with the following changes:
-- snip --
diff --git a/t/helper/test-proc-receive.c b/t/helper/test-proc-receive.c index ee5717ba0a..9f7fbc5b7a 100644 --- a/t/helper/test-proc-receive.c +++ b/t/helper/test-proc-receive.c @@ -78,17 +78,18 @@ static void proc_receive_read_commands(struct packet_reader *reader, if (packet_reader_read(reader) != PACKET_READ_NORMAL) break; - if (die_readline) - die("die with the --die-readline option"); - if (parse_oid_hex(reader->line, &old_oid, &p) || *p++ != ' ' || parse_oid_hex(p, &new_oid, &p) || - *p++ != ' ') { + *p++ != ' ' || + die_readline) { + char *bad_line = xstrdup(reader->line); while (packet_reader_read(reader) != PACKET_READ_EOF) ; /* do nothing */ + if (die_readline) + die("die with the --die-readline option"); die("protocol error: expected 'old new ref', got '%s'", - reader->line); + bad_line); } refname = p; FLEX_ALLOC_STR(cmd, ref_name, refname); -- snap --