public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [committed] test-memcpy: Actually reverse source and destination
@ 2022-04-06  7:26 Siddhesh Poyarekar
  0 siblings, 0 replies; only message in thread
From: Siddhesh Poyarekar @ 2022-04-06  7:26 UTC (permalink / raw)
  To: libc-alpha

Looks like an oversight in memcpy tests resulted in s2 and s1 not being
swapped for the second iteration of the memcpy test.  Fix it.  Also fix
a formatting nit.

Signed-off-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
---
 string/test-memcpy-support.h | 46 +++++++++++++++++++-----------------
 1 file changed, 24 insertions(+), 22 deletions(-)

diff --git a/string/test-memcpy-support.h b/string/test-memcpy-support.h
index f1763da895..699c00ce4c 100644
--- a/string/test-memcpy-support.h
+++ b/string/test-memcpy-support.h
@@ -84,7 +84,7 @@ do_one_test (impl_t *impl, char *dst, const char *src, size_t len)
 static void
 do_test (size_t align1, size_t align2, size_t len)
 {
-  size_t i, j, repeats;
+  size_t i, j;
   char *s1, *s2;
 
   align1 &= 4095;
@@ -97,13 +97,16 @@ do_test (size_t align1, size_t align2, size_t len)
 
   s1 = (char *)(buf1 + align1);
   s2 = (char *)(buf2 + align2);
-  for (repeats = 0; repeats < 2; ++repeats)
+  for (size_t repeats = 0; repeats < 2; ++repeats)
     {
       for (i = 0, j = 1; i < len; i++, j += 23)
         s1[i] = j;
 
       FOR_EACH_IMPL (impl, 0)
       do_one_test (impl, s2, s1, len);
+
+      s1 = (char *) (buf2 + align1);
+      s2 = (char *) (buf1 + align2);
     }
 }
 
@@ -138,30 +141,29 @@ do_test1 (size_t align1, size_t align2, size_t size)
   unaligned_uint32_t *dest = large_buf + align1;
   unaligned_uint32_t *src = large_buf + region_size + 2 * page_size + align2;
   size_t i;
-  size_t repeats;
-  for (repeats = 0; repeats < 2; repeats++)
+  for (size_t repeats = 0; repeats < 2; repeats++)
     {
       for (i = 0; i < array_size; i++)
         src[i] = (uint32_t)i;
       FOR_EACH_IMPL (impl, 0)
-      {
-        memset (dest, -1, size);
-        CALL (impl, (char *)dest, (char *)src, size);
-        if (memcmp (src, dest, size))
-          {
-            for (i = 0; i < array_size; i++)
-              if (dest[i] != src[i])
-                {
-                  error (0, 0,
-                         "Wrong result in function %s dst \"%p\" src \"%p\" "
-                         "offset \"%zd\"",
-                         impl->name, dest, src, i);
-                  ret = 1;
-                  munmap ((void *)large_buf, mmap_size);
-                  return;
-                }
-          }
-      }
+	{
+	  memset (dest, -1, size);
+	  CALL (impl, (char *)dest, (char *)src, size);
+	  if (memcmp (src, dest, size))
+	    {
+	      for (i = 0; i < array_size; i++)
+		if (dest[i] != src[i])
+		  {
+		    error (0, 0,
+			   "Wrong result in function %s dst \"%p\" src \"%p\" "
+			   "offset \"%zd\"",
+			   impl->name, dest, src, i);
+		    ret = 1;
+		    munmap ((void *)large_buf, mmap_size);
+		    return;
+		  }
+	    }
+	}
       dest = large_buf + region_size + 2 * page_size + align1;
       src = large_buf + align2;
     }
-- 
2.35.1


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-04-06  7:27 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-06  7:26 [committed] test-memcpy: Actually reverse source and destination Siddhesh Poyarekar

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).