diff options
author | Siddhesh Poyarekar <siddhesh@sourceware.org> | 2022-04-06 12:45:39 +0530 |
---|---|---|
committer | Siddhesh Poyarekar <siddhesh@sourceware.org> | 2022-04-06 12:45:39 +0530 |
commit | dfc7bf8a24f63532da167cc7131227c1c4027ffb (patch) | |
tree | e08e04cabc5f30de856cd26c0bf3642b39c96ae3 /string | |
parent | cbc2c56bab4ca6210b299d5457359bf64cd6abb2 (diff) | |
download | glibc-dfc7bf8a24f63532da167cc7131227c1c4027ffb.zip glibc-dfc7bf8a24f63532da167cc7131227c1c4027ffb.tar.gz glibc-dfc7bf8a24f63532da167cc7131227c1c4027ffb.tar.bz2 |
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>
Diffstat (limited to 'string')
-rw-r--r-- | string/test-memcpy-support.h | 46 |
1 files changed, 24 insertions, 22 deletions
diff --git a/string/test-memcpy-support.h b/string/test-memcpy-support.h index f1763da..699c00c 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; } |