|
|
786673 |
commit 659c0411880328ed341ca26b43d069ec5269a8b5
|
|
|
786673 |
Author: H.J. Lu <hjl.tools@gmail.com>
|
|
|
786673 |
Date: Thu Jun 11 09:03:56 2020 -0700
|
|
|
786673 |
|
|
|
786673 |
strcmp: Add a testcase for page boundary
|
|
|
786673 |
|
|
|
786673 |
Add a strcmp testcase to cover cases where both strings end on the page
|
|
|
786673 |
boundary.
|
|
|
786673 |
|
|
|
786673 |
diff --git a/string/test-strcmp.c b/string/test-strcmp.c
|
|
|
786673 |
index 8d4784de80..6a840fc04b 100644
|
|
|
786673 |
--- a/string/test-strcmp.c
|
|
|
786673 |
+++ b/string/test-strcmp.c
|
|
|
786673 |
@@ -359,6 +359,38 @@ check (void)
|
|
|
786673 |
}
|
|
|
786673 |
}
|
|
|
786673 |
|
|
|
786673 |
+static void
|
|
|
786673 |
+check2 (void)
|
|
|
786673 |
+{
|
|
|
786673 |
+ /* To trigger bug 25933, we need a size that is equal to the vector
|
|
|
786673 |
+ length times 4. In the case of AVX2 for Intel, we need 32 * 4. We
|
|
|
786673 |
+ make this test generic and run it for all architectures as additional
|
|
|
786673 |
+ boundary testing for such related algorithms. */
|
|
|
786673 |
+ size_t size = 32 * 4;
|
|
|
786673 |
+ CHAR *s1 = (CHAR *) (buf1 + (BUF1PAGES - 1) * page_size);
|
|
|
786673 |
+ CHAR *s2 = (CHAR *) (buf2 + (BUF1PAGES - 1) * page_size);
|
|
|
786673 |
+ int exp_result;
|
|
|
786673 |
+
|
|
|
786673 |
+ memset (s1, 'a', page_size);
|
|
|
786673 |
+ memset (s2, 'a', page_size);
|
|
|
786673 |
+ s1[(page_size / CHARBYTES) - 1] = (CHAR) 0;
|
|
|
786673 |
+ s2[(page_size / CHARBYTES) - 1] = (CHAR) 0;
|
|
|
786673 |
+
|
|
|
786673 |
+ /* Iterate over a size that is just below where we expect the bug to
|
|
|
786673 |
+ trigger up to the size we expect will trigger the bug e.g. [99-128].
|
|
|
786673 |
+ Likewise iterate the start of two strings between 30 and 31 bytes
|
|
|
786673 |
+ away from the boundary to simulate alignment changes. */
|
|
|
786673 |
+ for (size_t s = 99; s <= size; s++)
|
|
|
786673 |
+ for (size_t s1a = 30; s1a < 32; s1a++)
|
|
|
786673 |
+ for (size_t s2a = 30; s2a < 32; s2a++)
|
|
|
786673 |
+ {
|
|
|
786673 |
+ CHAR *s1p = s1 + (page_size / CHARBYTES - s) - s1a;
|
|
|
786673 |
+ CHAR *s2p = s2 + (page_size / CHARBYTES - s) - s2a;
|
|
|
786673 |
+ exp_result = SIMPLE_STRCMP (s1p, s2p);
|
|
|
786673 |
+ FOR_EACH_IMPL (impl, 0)
|
|
|
786673 |
+ check_result (impl, s1p, s2p, exp_result);
|
|
|
786673 |
+ }
|
|
|
786673 |
+}
|
|
|
786673 |
|
|
|
786673 |
int
|
|
|
786673 |
test_main (void)
|
|
|
786673 |
@@ -367,6 +399,7 @@ test_main (void)
|
|
|
786673 |
|
|
|
786673 |
test_init ();
|
|
|
786673 |
check();
|
|
|
786673 |
+ check2 ();
|
|
|
786673 |
|
|
|
786673 |
printf ("%23s", "");
|
|
|
786673 |
FOR_EACH_IMPL (impl, 0)
|