From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2206) id 792123858C55; Wed, 6 Apr 2022 07:27:50 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 792123858C55 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Siddhesh Poyarekar To: glibc-cvs@sourceware.org Subject: [glibc] test-memcpy: Actually reverse source and destination X-Act-Checkin: glibc X-Git-Author: Siddhesh Poyarekar X-Git-Refname: refs/heads/master X-Git-Oldrev: cbc2c56bab4ca6210b299d5457359bf64cd6abb2 X-Git-Newrev: dfc7bf8a24f63532da167cc7131227c1c4027ffb Message-Id: <20220406072750.792123858C55@sourceware.org> Date: Wed, 6 Apr 2022 07:27:50 +0000 (GMT) X-BeenThere: glibc-cvs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Glibc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 06 Apr 2022 07:27:50 -0000 https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=dfc7bf8a24f63532da167cc7131227c1c4027ffb commit dfc7bf8a24f63532da167cc7131227c1c4027ffb Author: Siddhesh Poyarekar 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 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; }