Ralf Wildenhues <Ralf.Wildenhues <at> gmx.de> writes: > > I suggest that either the testsuite test use some time limit (alarm?), > or the configure test tries to expose the quadratic complexity, or the > configure test assume `no' on systems where we know libc's memmem to be > insufficient.
I'm still planning on asking the Austin group whether strstr must be async-safe or must have linear complexity, or whether this tradeoff between the two competing ideals should be left as a QoI issue for various implementations. Once I get an answer for that, we can extrapolate the same answer for memmem. In the meantime, I'm checking this in; test-memmem now fails instead of passing on glibc systems, but at least the failure is after 10 seconds rather than taking many minutes before passing. Since the cross-compilation test already pessimistically assumes memmem has bad complexity, it is not that hard to alter the runtime test in memmem.m4 to use the same approach as test-memmem.c to flush out glibc and other systems with poor complexity. However, I'm reluctant to change the actual memmem.m4 test to try to expose the quadratic speed until we get more feedback on whether we want to blindly favor complexity over async-safety, or whether people want two interfaces, such as memmem which guarantees async-safety, and memmem_fast which guarantees speed. From: Eric Blake <[EMAIL PROTECTED]> Date: Fri, 4 Jan 2008 15:19:34 -0700 Subject: [PATCH] Shorten duration of memmem test. * tests/test-memmem.c (main): Use alarm to declare failure if test is taking too long. Reported by Ralf Wildenhues. Signed-off-by: Eric Blake <[EMAIL PROTECTED]> --- ChangeLog | 13 ++++++++++--- tests/test-memmem.c | 6 +++++- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1bba774..f4a48b7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2008-01-04 Eric Blake <[EMAIL PROTECTED]> + + Shorten duration of memmem test. + * tests/test-memmem.c (main): Use alarm to declare failure if test + is taking too long. + Reported by Ralf Wildenhues. + 2007-12-21 Simon Josefsson <[EMAIL PROTECTED]> * modules/relocatable-prog-wrapper (Depends-on): Add intprops and @@ -37242,6 +37249,6 @@ * m4/uintmax_t.m4: New file. * m4/Makefile.am (EXTRA_DIST): Add inttypes_h.m4 and uintmax_t.m4. -Copyright (C) 1997-2007 Free Software Foundation, Inc. +Copyright (C) 1997-2008 Free Software Foundation, Inc. Copying and distribution of this file, with or without modification, are permitted provided the copyright notice and this notice are preserved. diff --git a/tests/test-memmem.c b/tests/test-memmem.c index 50fdfb8..df3baef 100644 --- a/tests/test-memmem.c +++ b/tests/test-memmem.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004, 2007 Free Software Foundation + * Copyright (C) 2004, 2007, 2008 Free Software Foundation * Written by Bruno Haible and Eric Blake * * This program is free software: you can redistribute it and/or modify @@ -21,6 +21,7 @@ #include <stdio.h> #include <stdlib.h> +#include <unistd.h> #define ASSERT(expr) \ do \ @@ -36,6 +37,9 @@ int main (int argc, char *argv[]) { + /* Declare failure if test takes too long, by using default abort + caused by SIGALRM. */ + alarm (10); { const char input[] = "foo"; const char *result = memmem (input, strlen (input), "", 0); -- 1.5.3.5