diff mbox

[testsuite] SEQUENCE_LENGTH in memcpy-2.c

Message ID 000101cc76d6$46b9ea90$d42dbfb0$@Yorsh@arm.com
State New
Headers show

Commit Message

Greta Yorsh Sept. 19, 2011, 2:13 p.m. UTC
This patch improves an existing test case for memcpy. The test case
memcpy-2.c checks that memory outside the destination is not corrupted. The
check fails if SEQUENCE_LENGTH < MAX_OFFSET, although it does not happen
with the default values of these macros. This patch fixes the check to work
for small values of SEQUENCE_LENGTH. The patch also allows SEQUENCE_LENGTH
to be redefined without a compiler warning. 

The patched test case passes on arm-none-eabi --with-cpu cortex-a9 on qemu.


2011-09-19  Greta Yorsh  <Greta.Yorsh@arm.com>

	* gcc.c-torture/execute/memcpy-2.c (main): Fix validation of memcpy 
	to work for small values of SEQUENCE_LENGTH.
diff mbox

Patch

diff --git a/gcc/testsuite/gcc.c-torture/execute/memcpy-2.c b/gcc/testsuite/gcc.c-torture/execute/memcpy-2.c
index f328b64..0182fe6 100644
--- a/gcc/testsuite/gcc.c-torture/execute/memcpy-2.c
+++ b/gcc/testsuite/gcc.c-torture/execute/memcpy-2.c
@@ -24,7 +24,9 @@ 
 
 /* Use a sequence length that is not divisible by two, to make it more
    likely to detect when words are mixed up.  */
+#ifndef SEQUENCE_LENGTH
 #define SEQUENCE_LENGTH 31
+#endif
 
 static union {
   char buf[MAX_LENGTH];
@@ -58,7 +60,7 @@  main ()
 	    if (*q != 'a')
 	      abort ();
 
-	  for (i = 0, c = 'A' + off2; i < len; i++, q++, c++)
+	  for (i = 0, c = 'A' + (off2 % SEQUENCE_LENGTH); i < len; i++, q++, c++)
 	    {
 	      if (c >= 'A' + SEQUENCE_LENGTH)
 		c = 'A';