aboutsummaryrefslogtreecommitdiff
path: root/string
diff options
context:
space:
mode:
authorSunil K Pandey <skpgkp2@gmail.com>2021-05-31 10:44:46 -0700
committerSunil K Pandey <skpgkp2@gmail.com>2021-06-03 11:16:51 -0700
commit642213e043040b2e3b5aad936986195491107e34 (patch)
tree88694d5be411bd83c54bc1d3a217880c0bb7e361 /string
parentdlfcn: Rework static dlopen hooks (diff)
downloadglibc-642213e043040b2e3b5aad936986195491107e34.tar.gz
glibc-642213e043040b2e3b5aad936986195491107e34.tar.bz2
glibc-642213e043040b2e3b5aad936986195491107e34.zip
Improve test coverage of strnlen function
This patch covers the following condition: Strings start with different alignments and end with length less than or equal to 512 byte. Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
Diffstat (limited to 'string')
-rw-r--r--string/test-strnlen.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/string/test-strnlen.c b/string/test-strnlen.c
index d70faa26ab..920f58e97b 100644
--- a/string/test-strnlen.c
+++ b/string/test-strnlen.c
@@ -230,7 +230,7 @@ do_page_2_tests (void)
int
test_main (void)
{
- size_t i;
+ size_t i, length, char_per_page;
test_init ();
@@ -271,6 +271,15 @@ test_main (void)
do_test (1, 1 << i, 5000, BIG_CHAR);
}
+ char_per_page = getpagesize () / sizeof (CHAR);
+
+ for (i = 0; i <= 127; i++)
+ for (length = i; length <= 512; length++)
+ {
+ do_test (i, length, 512, BIG_CHAR);
+ do_test (char_per_page - i, length, 512, BIG_CHAR);
+ }
+
do_random_tests ();
do_page_tests ();
do_page_2_tests ();