public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH v2] Improve test coverage of strnlen function
@ 2021-06-02 21:00 Sunil K Pandey
  2021-06-02 21:18 ` Noah Goldstein
  0 siblings, 1 reply; 2+ messages in thread
From: Sunil K Pandey @ 2021-06-02 21:00 UTC (permalink / raw)
  To: libc-alpha

This patch covers the following condition:

Strings start with different alignments and end with length less than or
equal to 512 byte.
---
 string/test-strnlen.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/string/test-strnlen.c b/string/test-strnlen.c
index d70faa26ab..fc2519614f 100644
--- a/string/test-strnlen.c
+++ b/string/test-strnlen.c
@@ -271,6 +271,15 @@ test_main (void)
       do_test (1, 1 << i, 5000, BIG_CHAR);
     }
 
+  size_t pagesize = getpagesize () / sizeof (CHAR);
+
+  for (i = 0; i <= 127; i++)
+    for (size_t length = i; length <= 512; length++)
+      {
+	do_test (i, length, 512, BIG_CHAR);
+	do_test (pagesize - i, length, 512, BIG_CHAR);
+      }
+
   do_random_tests ();
   do_page_tests ();
   do_page_2_tests ();
-- 
2.31.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH v2] Improve test coverage of strnlen function
  2021-06-02 21:00 [PATCH v2] Improve test coverage of strnlen function Sunil K Pandey
@ 2021-06-02 21:18 ` Noah Goldstein
  0 siblings, 0 replies; 2+ messages in thread
From: Noah Goldstein @ 2021-06-02 21:18 UTC (permalink / raw)
  To: Sunil K Pandey; +Cc: GNU C Library

On Wed, Jun 2, 2021 at 5:00 PM Sunil K Pandey via Libc-alpha
<libc-alpha@sourceware.org> wrote:
>
> This patch covers the following condition:
>
> Strings start with different alignments and end with length less than or
> equal to 512 byte.
> ---
>  string/test-strnlen.c | 9 +++++++++
>  1 file changed, 9 insertions(+)
>
> diff --git a/string/test-strnlen.c b/string/test-strnlen.c
> index d70faa26ab..fc2519614f 100644
> --- a/string/test-strnlen.c
> +++ b/string/test-strnlen.c
> @@ -271,6 +271,15 @@ test_main (void)
>        do_test (1, 1 << i, 5000, BIG_CHAR);
>      }
>
> +  size_t pagesize = getpagesize () / sizeof (CHAR);
Think style of the file is variables declared at start of their
scope. Also imo pagesize means something different than
char per page so maybe rename.

That being said I support the patch.

Thanks for test improvements!
> +
> +  for (i = 0; i <= 127; i++)
> +    for (size_t length = i; length <= 512; length++)
> +      {
> +       do_test (i, length, 512, BIG_CHAR);
> +       do_test (pagesize - i, length, 512, BIG_CHAR);
> +      }
> +
>    do_random_tests ();
>    do_page_tests ();
>    do_page_2_tests ();
> --
> 2.31.1
>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-06-02 21:18 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-02 21:00 [PATCH v2] Improve test coverage of strnlen function Sunil K Pandey
2021-06-02 21:18 ` Noah Goldstein

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).