public inbox for glibc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Siddhesh Poyarekar <siddhesh@sourceware.org>
To: glibc-cvs@sourceware.org
Subject: [glibc] test-memcpy: Actually reverse source and destination
Date: Wed,  6 Apr 2022 07:27:50 +0000 (GMT)	[thread overview]
Message-ID: <20220406072750.792123858C55@sourceware.org> (raw)

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=dfc7bf8a24f63532da167cc7131227c1c4027ffb

commit dfc7bf8a24f63532da167cc7131227c1c4027ffb
Author: Siddhesh Poyarekar <siddhesh@sourceware.org>
Date:   Wed Apr 6 12:45:39 2022 +0530

    test-memcpy: Actually reverse source and destination
    
    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>

Diff:
---
 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;
     }


                 reply	other threads:[~2022-04-06  7:27 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220406072750.792123858C55@sourceware.org \
    --to=siddhesh@sourceware.org \
    --cc=glibc-cvs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).