[v1,19/23] string: Expand page cross test cases in test-strcmp.c

Message ID 20220323215734.3927131-19-goldstein.w.n@gmail.com
State Accepted, archived
Headers
Series [v1,01/23] benchtests: Use json-lib in bench-strchr.c |

Checks

Context Check Description
dj/TryBot-apply_patch success Patch applied to master at the time it was sent

Commit Message

Noah Goldstein March 23, 2022, 9:57 p.m. UTC
  Test cases for when both `s1` and `s2` are near the end of a page
where previously missing.
---
 string/test-strcmp.c | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)
  

Comments

H.J. Lu March 24, 2022, 7:02 p.m. UTC | #1
On Wed, Mar 23, 2022 at 3:02 PM Noah Goldstein <goldstein.w.n@gmail.com> wrote:
>
> Test cases for when both `s1` and `s2` are near the end of a page
> where previously missing.
> ---
>  string/test-strcmp.c | 15 ++++++++++++++-
>  1 file changed, 14 insertions(+), 1 deletion(-)
>
> diff --git a/string/test-strcmp.c b/string/test-strcmp.c
> index 0abce769d0..ece03c6d0b 100644
> --- a/string/test-strcmp.c
> +++ b/string/test-strcmp.c
> @@ -392,7 +392,7 @@ check3 (void)
>  int
>  test_main (void)
>  {
> -  size_t i, j;
> +  size_t i, j, k;
>    const size_t test_len = MIN(TEST_LEN, 3 * 4096);
>    test_init ();
>    check();
> @@ -453,6 +453,19 @@ test_main (void)
>            do_test (j, getpagesize () - j - 1, i, 127, 1);
>            do_test (j, getpagesize () - j - 1, i, 127, -1);
>
> +          for (k = 2; k <= 128; k += k)
> +            {
> +              do_test (getpagesize () - k, getpagesize () - j - 1, i, 127, 0);
> +              do_test (getpagesize () - k - 1, getpagesize () - j - 1, i, 127,
> +                       0);
> +              do_test (getpagesize () - k, getpagesize () - j - 1, i, 127, 1);
> +              do_test (getpagesize () - k - 1, getpagesize () - j - 1, i, 127,
> +                       1);
> +              do_test (getpagesize () - k, getpagesize () - j - 1, i, 127, -1);
> +              do_test (getpagesize () - k - 1, getpagesize () - j - 1, i, 127,
> +                       -1);
> +            }
> +
>            if (i < 32)
>              {
>                i += 1;
> --
> 2.25.1
>

LGTM.

Reviewed-by: H.J. Lu <hjl.tools@gmail.com>

Thanks.
  

Patch

diff --git a/string/test-strcmp.c b/string/test-strcmp.c
index 0abce769d0..ece03c6d0b 100644
--- a/string/test-strcmp.c
+++ b/string/test-strcmp.c
@@ -392,7 +392,7 @@  check3 (void)
 int
 test_main (void)
 {
-  size_t i, j;
+  size_t i, j, k;
   const size_t test_len = MIN(TEST_LEN, 3 * 4096);
   test_init ();
   check();
@@ -453,6 +453,19 @@  test_main (void)
           do_test (j, getpagesize () - j - 1, i, 127, 1);
           do_test (j, getpagesize () - j - 1, i, 127, -1);
 
+          for (k = 2; k <= 128; k += k)
+            {
+              do_test (getpagesize () - k, getpagesize () - j - 1, i, 127, 0);
+              do_test (getpagesize () - k - 1, getpagesize () - j - 1, i, 127,
+                       0);
+              do_test (getpagesize () - k, getpagesize () - j - 1, i, 127, 1);
+              do_test (getpagesize () - k - 1, getpagesize () - j - 1, i, 127,
+                       1);
+              do_test (getpagesize () - k, getpagesize () - j - 1, i, 127, -1);
+              do_test (getpagesize () - k - 1, getpagesize () - j - 1, i, 127,
+                       -1);
+            }
+
           if (i < 32)
             {
               i += 1;