git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Test failures in t4034

From
Junio C Hamano <gitster@pobox.com>
Date
Aug 21, 2012, 22:09 UTC
Message-ID
<7v1uizdhi7.fsf@alter.siamese.dyndns.org>
In-Reply-To
<5033D573.9030103@ramsay1.demon.co.uk>
Ramsay Jones <ramsay@ramsay1.demon.co.uk> writes:
Show 23 quoted lines
> I think that, after some testing, this (or something like it) is the
> best that we can do. What do you think?
>
> ATB,
> Ramsay Jones
>
> -- >8 --
> Subject: [PATCH] test-regex: Add a test to check for a bug in the regex routines
>
> Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
> ---
> diff --git a/t/t0070-fundamental.sh b/t/t0070-fundamental.sh
> index 9bee8bf..da2c504 100755
> --- a/t/t0070-fundamental.sh
> +++ b/t/t0070-fundamental.sh
> @@ -25,4 +25,9 @@ test_expect_success POSIXPERM 'mktemp to unwritable directory prints filename' '
>  	grep "cannotwrite/test" err
>  '
>  
> +test_expect_success 'check for a bug in the regex routines' '
> +	# if this test fails, re-build git with NO_REGEX=1
> +	test-regex
> +'
OK.
Show 23 quoted lines
>  test_done
> diff --git a/test-regex.c b/test-regex.c
> new file mode 100644
> index 0000000..9259985
> --- /dev/null
> +++ b/test-regex.c
> @@ -0,0 +1,35 @@
> +#include <stdlib.h>
> +#include <stdio.h>
> +#include <stdarg.h>
> +#include <sys/types.h>
> +#include <regex.h>
> +
> +static void die(const char *fmt, ...)
> +{
> +	va_list p;
> +
> +	va_start(p, fmt);
> +	vfprintf(stderr, fmt, p);
> +	va_end(p);
> +	fputc('\n', stderr);
> +	exit(128);
> +}

Looks like a bit of overkill for only two call sites, whose output we would never see because it is behind the test, but OK.

Show 15 quoted lines
> +int main(int argc, char **argv)
> +{
> +	char *pat = "[^={} \t]+";
> +	char *str = "={}\nfred";
> +	regex_t r;
> +	regmatch_t m[1];
> +
> +	if (regcomp(&r, pat, REG_EXTENDED | REG_NEWLINE))
> +		die("failed regcomp() for pattern '%s'", pat);
> +	if (regexec(&r, str, 1, m, 0))
> +		die("no match of pattern '%s' to string '%s'", pat, str);
> +
> +	/* http://sourceware.org/bugzilla/show_bug.cgi?id=3957  */
> +	if (m[0].rm_so == 3) /* matches '\n' when it should not */
> +		exit(1);

This could be the third call site of die() that tells the user to build with NO_REGEX=1. Then "cd t && sh t0070-fundamental.sh -i -v" would give that message directly to the user.

> +	exit(0);
> +}
Thanks.
Previous: Ramsay JonesNext: Ramsay Jones
Message 7 of 10 in “Test failures in t4034”
  1. Brian GernhardtAug 18, 2012
  2. Junio C HamanoAug 19, 2012
  3. Ramsay JonesAug 19, 2012
  4. Johannes SixtAug 19, 2012
  5. Junio C HamanoAug 20, 2012
  6. Ramsay JonesAug 21, 2012
  7. Junio C HamanoAug 21, 2012
  8. Ramsay JonesSep 1, 2012
  9. Junio C HamanoSep 3, 2012
  10. Junio C HamanoAug 19, 2012

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.