mirror of
https://sourceware.org/git/glibc.git
synced 2024-11-27 19:53:32 +08:00
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>
This commit is contained in:
parent
5295172e20
commit
c9ff9cf66a
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user