mirror of
https://sourceware.org/git/glibc.git
synced 2025-07-30 22:43:12 +03:00
Add a testcase for BZ #14716
This commit is contained in:
@ -1,3 +1,11 @@
|
|||||||
|
2012-10-18 H.J. Lu <hongjiu.lu@intel.com>
|
||||||
|
|
||||||
|
[BZ #14716]
|
||||||
|
* string/test-memmem.c (check_result): New function.
|
||||||
|
(do_one_test): Use it.
|
||||||
|
(check1): New function.
|
||||||
|
(test_main): Use it.
|
||||||
|
|
||||||
2012-10-18 Markus Trippelsdorf <markus@trippelsdorf.de>
|
2012-10-18 Markus Trippelsdorf <markus@trippelsdorf.de>
|
||||||
|
|
||||||
* math/Makefile: Comment on slow compilation of test-tgmath2.c.
|
* math/Makefile: Comment on slow compilation of test-tgmath2.c.
|
||||||
|
@ -56,8 +56,8 @@ simple_memmem (const void *haystack, size_t haystack_len, const void *needle,
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static int
|
||||||
do_one_test (impl_t *impl, const void *haystack, size_t haystack_len,
|
check_result (impl_t *impl, const void *haystack, size_t haystack_len,
|
||||||
const void *needle, size_t needle_len, const void *expected)
|
const void *needle, size_t needle_len, const void *expected)
|
||||||
{
|
{
|
||||||
void *res;
|
void *res;
|
||||||
@ -68,9 +68,20 @@ do_one_test (impl_t *impl, const void *haystack, size_t haystack_len,
|
|||||||
error (0, 0, "Wrong result in function %s %p %p", impl->name,
|
error (0, 0, "Wrong result in function %s %p %p", impl->name,
|
||||||
res, expected);
|
res, expected);
|
||||||
ret = 1;
|
ret = 1;
|
||||||
return;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
do_one_test (impl_t *impl, const void *haystack, size_t haystack_len,
|
||||||
|
const void *needle, size_t needle_len, const void *expected)
|
||||||
|
{
|
||||||
|
if (check_result (impl, haystack, haystack_len, needle, needle_len,
|
||||||
|
expected) < 0)
|
||||||
|
return;
|
||||||
|
|
||||||
if (HP_TIMING_AVAIL)
|
if (HP_TIMING_AVAIL)
|
||||||
{
|
{
|
||||||
hp_timing_t start __attribute ((unused));
|
hp_timing_t start __attribute ((unused));
|
||||||
@ -145,6 +156,22 @@ do_random_tests (void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
check1 (void)
|
||||||
|
{
|
||||||
|
|
||||||
|
const char search_buf_data[5] = { 0x56, 0x34, 0x12, 0x78, 0x78 };
|
||||||
|
const char pattern[2] = { 0x78, 0x56 };
|
||||||
|
void *search_buf = (void *) buf1 + page_size - sizeof search_buf_data;
|
||||||
|
void *exp_result;
|
||||||
|
|
||||||
|
memcpy (search_buf, search_buf_data, sizeof search_buf_data);
|
||||||
|
exp_result = simple_memmem (search_buf, sizeof search_buf_data,
|
||||||
|
pattern, sizeof pattern);
|
||||||
|
FOR_EACH_IMPL (impl, 0)
|
||||||
|
check_result (impl, search_buf, sizeof search_buf_data,
|
||||||
|
pattern, sizeof pattern, exp_result);
|
||||||
|
}
|
||||||
|
|
||||||
static const char *const strs[] =
|
static const char *const strs[] =
|
||||||
{
|
{
|
||||||
@ -161,6 +188,8 @@ test_main (void)
|
|||||||
|
|
||||||
test_init ();
|
test_init ();
|
||||||
|
|
||||||
|
check1 ();
|
||||||
|
|
||||||
printf ("%23s", "");
|
printf ("%23s", "");
|
||||||
FOR_EACH_IMPL (impl, 0)
|
FOR_EACH_IMPL (impl, 0)
|
||||||
printf ("\t%s", impl->name);
|
printf ("\t%s", impl->name);
|
||||||
|
Reference in New Issue
Block a user