This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
[PATCH] improved test-strncmp for 64-bit
- From: Steven Munroe <munroesj at us dot ibm dot com>
- To: libc-alpha at sources dot redhat dot com
- Date: Thu, 17 Nov 2005 17:42:56 -0600
- Subject: [PATCH] improved test-strncmp for 64-bit
The previous submission did not properly set up the end of page limit
cases for 64-bit systems (i.e as the loop index starts with 1 the;
double word aligned, strings equal, case did not ocurr). The attached
patch fixes the loop range to test 64-bit and adds some explicit tests
for zero length and where only one string is at end of page.
2005-11-17 Steven Munroe <sjmunroe@us.ibm.com>
[BZ #1877]
* string/test-strncmp.c (do_test_limit): Handle zero length and
non-zero align values.
(test_main) Correct do_test_limit tests for 64-bit.
diff -urN ./dummy-cpu/string/test-strncmp.c ./libc24/string/test-strncmp.c
--- ./dummy-cpu/string/test-strncmp.c 2005-11-17 16:43:24.629111248 -0600
+++ ./libc24/string/test-strncmp.c 2005-11-17 17:24:31.324010472 -0600
@@ -89,19 +89,38 @@
do_test_limit (size_t align1, size_t align2, size_t len, size_t n, int max_char,
int exp_result)
{
- size_t i;
+ size_t i, align_n;
char *s1, *s2;
if (n == 0)
- return;
-
- align1 &= 7;
+ {
+ s1 = (char*)(buf1 + page_size);
+ s2 = (char*)(buf2 + page_size);
+ if (HP_TIMING_AVAIL)
+ printf ("Length %4zd/%4zd:", len, n);
+
+ FOR_EACH_IMPL (impl, 0)
+ do_one_test (impl, s1, s2, n, 0);
+
+ if (HP_TIMING_AVAIL)
+ putchar ('\n');
+
+ return;
+ }
- align2 &= 7;
+ align1 &= 15;
+ align2 &= 15;
+ align_n = (page_size - n) & 15;
s1 = (char*)(buf1 + page_size - n);
s2 = (char*)(buf2 + page_size - n);
-
+
+ if (align1 < align_n)
+ s1 -= (align_n - align1);
+
+ if (align2 < align_n)
+ s2 -= (align_n - align2);
+
for (i = 0; i < n; i++)
s1[i] = s2[i] = 1 + 23 * i % max_char;
@@ -311,8 +330,14 @@
do_test (2 * i, i, 8 << i, 16 << i, 255, 0);
do_test (2 * i, i, 8 << i, 16 << i, 255, 1);
}
+
+ do_test_limit (0, 0, 0, 0, 127, 0);
+ do_test_limit (4, 0, 21, 20, 127, 0);
+ do_test_limit (0, 4, 21, 20, 127, 0);
+ do_test_limit (8, 0, 25, 24, 127, 0);
+ do_test_limit (0, 8, 25, 24, 127, 0);
- for (i = 1; i < 8; ++i)
+ for (i = 0; i < 8; ++i)
{
do_test_limit (0, 0, 17 - i, 16 - i, 127, 0);
do_test_limit (0, 0, 17 - i, 16 - i, 255, 0);