mirror of
https://sourceware.org/git/glibc.git
synced 2025-07-29 11:41:21 +03:00
Add strchrnul performance test
This commit is contained in:
@ -1,5 +1,9 @@
|
|||||||
2011-10-29 Ulrich Drepper <drepper@gmail.com>
|
2011-10-29 Ulrich Drepper <drepper@gmail.com>
|
||||||
|
|
||||||
|
* string/test-strchr.c: Make usable for strchrnul testing.
|
||||||
|
* string/test-strchrnul.c: New file.
|
||||||
|
* string/Makefile (strop-tests): Add strchrnul.
|
||||||
|
|
||||||
* po/it.po: Update from translation team.
|
* po/it.po: Update from translation team.
|
||||||
* po/es.po: Likewise.
|
* po/es.po: Likewise.
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ strop-tests := memchr memcmp memcpy memmove mempcpy memset memccpy \
|
|||||||
stpcpy stpncpy strcat strchr strcmp strcpy strcspn \
|
stpcpy stpncpy strcat strchr strcmp strcpy strcspn \
|
||||||
strlen strncmp strncpy strpbrk strrchr strspn memmem \
|
strlen strncmp strncpy strpbrk strrchr strspn memmem \
|
||||||
strstr strcasestr strnlen strcasecmp strncasecmp \
|
strstr strcasestr strnlen strcasecmp strncasecmp \
|
||||||
strncat rawmemchr
|
strncat rawmemchr strchrnul
|
||||||
tests := tester inl-tester noinl-tester testcopy test-ffs \
|
tests := tester inl-tester noinl-tester testcopy test-ffs \
|
||||||
tst-strlen stratcliff tst-svc tst-inlcall \
|
tst-strlen stratcliff tst-svc tst-inlcall \
|
||||||
bug-strncat1 bug-strspn1 bug-strpbrk1 tst-bswap \
|
bug-strncat1 bug-strspn1 bug-strpbrk1 tst-bswap \
|
||||||
|
@ -23,7 +23,13 @@
|
|||||||
#include "test-string.h"
|
#include "test-string.h"
|
||||||
|
|
||||||
#ifndef WIDE
|
#ifndef WIDE
|
||||||
# define STRCHR strchr
|
# ifdef USE_FOR_STRCHRNUL
|
||||||
|
# define STRCHR strchrnul
|
||||||
|
# define stupid_STRCHR stupid_STRCHRNUL
|
||||||
|
# define simple_STRCHR simple_STRCHRNUL
|
||||||
|
# else
|
||||||
|
# define STRCHR strchr
|
||||||
|
# endif
|
||||||
# define STRLEN strlen
|
# define STRLEN strlen
|
||||||
# define CHAR char
|
# define CHAR char
|
||||||
# define BIG_CHAR CHAR_MAX
|
# define BIG_CHAR CHAR_MAX
|
||||||
@ -41,6 +47,13 @@
|
|||||||
# define UCHAR wchar_t
|
# define UCHAR wchar_t
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef USE_FOR_STRCHRNUL
|
||||||
|
# define NULLRET(endptr) endptr
|
||||||
|
#else
|
||||||
|
# define NULLRET(endptr) NULL
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
typedef CHAR *(*proto_t) (const CHAR *, int);
|
typedef CHAR *(*proto_t) (const CHAR *, int);
|
||||||
|
|
||||||
CHAR *
|
CHAR *
|
||||||
@ -48,7 +61,7 @@ simple_STRCHR (const CHAR *s, int c)
|
|||||||
{
|
{
|
||||||
for (; *s != (CHAR) c; ++s)
|
for (; *s != (CHAR) c; ++s)
|
||||||
if (*s == '\0')
|
if (*s == '\0')
|
||||||
return NULL;
|
return NULLRET ((CHAR *) s);
|
||||||
return (CHAR *) s;
|
return (CHAR *) s;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -60,7 +73,7 @@ stupid_STRCHR (const CHAR *s, int c)
|
|||||||
while (n--)
|
while (n--)
|
||||||
if (*s++ == (CHAR) c)
|
if (*s++ == (CHAR) c)
|
||||||
return (CHAR *) s - 1;
|
return (CHAR *) s - 1;
|
||||||
return NULL;
|
return NULLRET ((CHAR *) s - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
IMPL (stupid_STRCHR, 0)
|
IMPL (stupid_STRCHR, 0)
|
||||||
@ -73,8 +86,8 @@ do_one_test (impl_t *impl, const CHAR *s, int c, const CHAR *exp_res)
|
|||||||
CHAR *res = CALL (impl, s, c);
|
CHAR *res = CALL (impl, s, c);
|
||||||
if (res != exp_res)
|
if (res != exp_res)
|
||||||
{
|
{
|
||||||
error (0, 0, "Wrong result in function %s %p %p", impl->name,
|
error (0, 0, "Wrong result in function %s %#x %p %p", impl->name,
|
||||||
res, exp_res);
|
c, res, exp_res);
|
||||||
ret = 1;
|
ret = 1;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -129,7 +142,7 @@ do_test (size_t align, size_t pos, size_t len, int seek_char, int max_char)
|
|||||||
else if (seek_char == 0)
|
else if (seek_char == 0)
|
||||||
result = buf + align + len;
|
result = buf + align + len;
|
||||||
else
|
else
|
||||||
result = NULL;
|
result = NULLRET (buf + align + len);
|
||||||
|
|
||||||
if (HP_TIMING_AVAIL)
|
if (HP_TIMING_AVAIL)
|
||||||
printf ("Length %4zd, alignment in bytes %2zd:",
|
printf ("Length %4zd, alignment in bytes %2zd:",
|
||||||
@ -198,7 +211,7 @@ do_random_tests (void)
|
|||||||
else if (seek_char == 0)
|
else if (seek_char == 0)
|
||||||
result = (CHAR *) (p + len + align);
|
result = (CHAR *) (p + len + align);
|
||||||
else
|
else
|
||||||
result = NULL;
|
result = NULLRET ((CHAR *) (p + len + align));
|
||||||
|
|
||||||
FOR_EACH_IMPL (impl, 1)
|
FOR_EACH_IMPL (impl, 1)
|
||||||
if (CALL (impl, (CHAR *) (p + align), seek_char) != result)
|
if (CALL (impl, (CHAR *) (p + align), seek_char) != result)
|
||||||
|
2
string/test-strchrnul.c
Normal file
2
string/test-strchrnul.c
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
#define USE_FOR_STRCHRNUL 1
|
||||||
|
#include "test-strchr.c"
|
Reference in New Issue
Block a user