public inbox for glibc-cvs@sourceware.org
help / color / mirror / Atom feed
* [glibc] Update string/test-memmove.c to cover 16KB copy
@ 2021-08-20 16:15 H.J. Lu
  0 siblings, 0 replies; only message in thread
From: H.J. Lu @ 2021-08-20 16:15 UTC (permalink / raw)
  To: glibc-cvs

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

commit c333dcf8d8f9e6e46475d9eff24bd5394b5d3d9e
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Mon Feb 1 17:23:12 2021 -0800

    Update string/test-memmove.c to cover 16KB copy

Diff:
---
 string/test-memmove.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 48 insertions(+)

diff --git a/string/test-memmove.c b/string/test-memmove.c
index b271248b1d..670094c9dc 100644
--- a/string/test-memmove.c
+++ b/string/test-memmove.c
@@ -312,6 +312,50 @@ do_test2 (size_t offset)
   munmap ((void *) large_buf, size);
 }
 
+static void
+do_test3 (size_t bytes_move, size_t offset)
+{
+  size_t size = bytes_move * 3;
+  uint32_t *buf;
+
+  buf = mmap (NULL, size, PROT_READ | PROT_WRITE,
+	      MAP_PRIVATE | MAP_ANON, -1, 0);
+
+  if (buf == MAP_FAILED)
+    error (EXIT_UNSUPPORTED, errno, "mmap failed");
+
+  size_t arr_size = bytes_move / sizeof (uint32_t);
+  size_t i;
+
+  FOR_EACH_IMPL (impl, 0)
+    {
+      for (i = 0; i < arr_size; i++)
+        buf[i] = (uint32_t) i;
+
+      uint32_t *dst = &buf[arr_size + offset];
+
+#ifdef TEST_BCOPY
+      CALL (impl, (char *) buf, (char *) dst, bytes_move);
+#else
+      CALL (impl, (char *) dst, (char *) buf, bytes_move);
+#endif
+
+      for (i = 0; i < arr_size; i++)
+	{
+	  if (dst[i] != (uint32_t) i)
+	    {
+	      error (0, 0,
+		     "Wrong result in function %s dst \"%p\" src \"%p\" offset \"%zd\"",
+		     impl->name, dst, buf, i);
+	      ret = 1;
+	      break;
+	    }
+	}
+    }
+
+  munmap ((void *) buf, size);
+}
+
 int
 test_main (void)
 {
@@ -356,6 +400,10 @@ test_main (void)
   do_test2 (0x200000);
   do_test2 (0x4000000 - 1);
   do_test2 (0x4000000);
+
+  /* Copy 16KB data.  */
+  do_test3 (16384, 3);
+
   return ret;
 }


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

only message in thread, other threads:[~2021-08-20 16:15 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-20 16:15 [glibc] Update string/test-memmove.c to cover 16KB copy H.J. Lu

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