[v1,2/3] String: test-memset.c strenthen test coverage

Message ID 20210607071025.449866-2-goldstein.w.n@gmail.com
State New
Headers show
Series
  • [v1,1/3] String: tst-memset-overflow.c Add test for overflow case.
Related show

Commit Message

Adhemerval Zanella via Libc-alpha June 7, 2021, 7:10 a.m.
This commit adds some additional tests cases that
seemed lacking.

Signed-off-by: Noah Goldstein <goldstein.w.n@gmail.com>

---
 string/test-memset.c | 28 +++++++++++++++++++++-------
 1 file changed, 21 insertions(+), 7 deletions(-)

-- 
2.25.1

Patch

diff --git a/string/test-memset.c b/string/test-memset.c
index 82bfcd6ad4..473bf1d1f5 100644
--- a/string/test-memset.c
+++ b/string/test-memset.c
@@ -101,7 +101,7 @@  inhibit_loop_to_libcall
 SIMPLE_MEMSET (CHAR *s, int c, size_t n)
 {
   CHAR *r = s, *end = s + n;
-  while (r < end)
+  while (r != end)
     *r++ = c;
   return s;
 }
@@ -237,7 +237,7 @@  do_random_tests (void)
 int
 test_main (void)
 {
-  size_t i;
+  size_t i, j;
   int c = 0;
 
   test_init ();
@@ -252,15 +252,29 @@  test_main (void)
 #endif
     {
       for (i = 0; i < 18; ++i)
-	do_test (0, c, 1 << i);
-      for (i = 1; i < 64; ++i)
+        {
+          do_test (0, c, 1 << i);
+          do_test (i, c, 1 << i);
+          do_test (0, c, (1 << i) + 1);
+          do_test (i, c, (1 << i) + 1);
+          do_test (0, c, (1 << i) - 1);
+          do_test (i, c, (1 << i) - 1);
+        }
+      for (i = 1; i < 128; ++i)
 	{
-	  do_test (i, c, i);
-	  do_test (4096 - i, c, i);
-	  do_test (4095, c, i);
+        for (j = i; j <= 2500; j += 15)
+          {
+            do_test (i, c, j);
+            do_test (4096 - i, c, j);
+            do_test (4095, c, j); 
+          }
 	  if (i & (i - 1))
 	    do_test (0, c, i);
 	}
+      do_test (0, c, 257);
+      do_test (0, c, 383);
+      do_test (0, c, 384);
+      do_test (0, c, 385);
       do_test (1, c, 14);
       do_test (3, c, 1024);
       do_test (4, c, 64);