aboutsummaryrefslogtreecommitdiff
path: root/string
diff options
context:
space:
mode:
authorSunil K Pandey <skpgkp2@gmail.com>2021-05-31 11:08:12 -0700
committerH.J. Lu <hjl.tools@gmail.com>2021-06-02 05:37:43 -0700
commitc9ff9cf66a7ae0617a2f39e752ca19c88c58f5b6 (patch)
treebb19669fc072f960016da4472e8a74b3f49e21f3 /string
parent5295172e20330d2147b0580770c69a1bad32828d (diff)
downloadglibc-c9ff9cf66a7ae0617a2f39e752ca19c88c58f5b6.zip
glibc-c9ff9cf66a7ae0617a2f39e752ca19c88c58f5b6.tar.gz
glibc-c9ff9cf66a7ae0617a2f39e752ca19c88c58f5b6.tar.bz2
Improve test coverage of strlen function
This patch covers the following conditions: - Strings start with different alignments and end at the page boundary with less than 64 byte length. - Strings starts with different alignments and cross page boundary with fixed length. Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
Diffstat (limited to 'string')
-rw-r--r--string/test-strlen.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/string/test-strlen.c b/string/test-strlen.c
index 6e67d1f..c9a7afb 100644
--- a/string/test-strlen.c
+++ b/string/test-strlen.c
@@ -79,7 +79,7 @@ do_test (size_t align, size_t len)
{
size_t i;
- align &= 63;
+ align &= (getpagesize () / sizeof (CHAR)) - 1;
if (align + sizeof (CHAR) * len >= page_size)
return;
@@ -160,6 +160,19 @@ test_main (void)
do_test (sizeof (CHAR) * i, (size_t)((1 << i) / 1.5));
}
+ /* Test strings near page boundary */
+
+ size_t maxlength = 64 / sizeof (CHAR) - 1;
+ size_t pagesize = getpagesize () / sizeof (CHAR);
+
+ for (i = maxlength ; i > 1; --i)
+ {
+ /* String stays on the same page. */
+ do_test (pagesize - i, i - 1);
+ /* String crosses page boundary. */
+ do_test (pagesize - i, maxlength);
+ }
+
do_random_tests ();
return ret;
}