diff mbox

Backport misalign tests to 4.9

Message ID 5444E5E1.2030708@samsung.com
State New
Headers show

Commit Message

Yury Gribov Oct. 20, 2014, 10:37 a.m. UTC
On Fri, Oct 17, 2014 at 06:15:11PM +0400, Yury Gribov wrote:
> On 10/17/2014 05:49 PM, Jakub Jelinek wrote:
 >> So, what about this?  Just checked that with
 >> make -k check-g{cc,++} 
RUNTESTFLAGS='--target_board=unix\{-m32,-m64\} asan.exp tsan.exp ubsan.exp'
 >> so far.  Plus if you add misalign tests...
>
> Sure, can do this on Monday.

Here are the said tests, passed (on x64) as expected. Ok to commit?

-Y

Comments

Jakub Jelinek Oct. 20, 2014, 10:44 a.m. UTC | #1
On Mon, Oct 20, 2014 at 02:37:21PM +0400, Yury Gribov wrote:
> On Fri, Oct 17, 2014 at 06:15:11PM +0400, Yury Gribov wrote:
> >On 10/17/2014 05:49 PM, Jakub Jelinek wrote:
> >> So, what about this?  Just checked that with
> >> make -k check-g{cc,++} RUNTESTFLAGS='--target_board=unix\{-m32,-m64\}
> asan.exp tsan.exp ubsan.exp'
> >> so far.  Plus if you add misalign tests...
> >
> >Sure, can do this on Monday.
> 
> Here are the said tests, passed (on x64) as expected. Ok to commit?
> 
> -Y

> commit f4007db6a5f90f71fe977c8232ea7fe2de1c6c28
> Author: jakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
> Date:   Fri May 30 18:37:59 2014 +0000
> 
>     2014-10-20  Yury Gribov  <y.gribov@samsung.com>
>     
>     	Backported from mainline
>     	2014-05-30  Jakub Jelinek  <jakub@redhat.com>
>     
>     	* c-c++-common/asan/misalign-1.c: New test.
>     	* c-c++-common/asan/misalign-2.c: New test.

Ok, thanks.

	Jakub
diff mbox

Patch

commit f4007db6a5f90f71fe977c8232ea7fe2de1c6c28
Author: jakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Date:   Fri May 30 18:37:59 2014 +0000

    2014-10-20  Yury Gribov  <y.gribov@samsung.com>
    
    	Backported from mainline
    	2014-05-30  Jakub Jelinek  <jakub@redhat.com>
    
    	* c-c++-common/asan/misalign-1.c: New test.
    	* c-c++-common/asan/misalign-2.c: New test.

diff --git a/gcc/testsuite/c-c++-common/asan/misalign-1.c b/gcc/testsuite/c-c++-common/asan/misalign-1.c
new file mode 100644
index 0000000..0c5b6e0
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/asan/misalign-1.c
@@ -0,0 +1,42 @@ 
+/* { dg-do run { target { ilp32 || lp64 } } } */
+/* { dg-options "-O2" } */
+/* { dg-shouldfail "asan" } */
+
+struct S { int i; } __attribute__ ((packed));
+
+__attribute__((noinline, noclone)) int
+foo (struct S *s)
+{
+  return s->i;
+}
+
+__attribute__((noinline, noclone)) int
+bar (int *s)
+{
+  return *s;
+}
+
+__attribute__((noinline, noclone)) struct S
+baz (struct S *s)
+{
+  return *s;
+}
+
+int
+main ()
+{
+  struct T { char a[3]; struct S b[3]; char c; } t;
+  int v = 5;
+  struct S *p = t.b;
+  asm volatile ("" : "+rm" (p));
+  p += 3;
+  if (bar (&v) != 5) __builtin_abort ();
+  volatile int w = foo (p);
+  return 0;
+}
+
+/* { dg-output "ERROR: AddressSanitizer:\[^\n\r]*on address\[^\n\r]*" } */
+/* { dg-output "0x\[0-9a-f\]+ at pc 0x\[0-9a-f\]+ bp 0x\[0-9a-f\]+ sp 0x\[0-9a-f\]+\[^\n\r]*(\n|\r\n|\r)" } */
+/* { dg-output "\[^\n\r]*READ of size 4 at 0x\[0-9a-f\]+ thread T0\[^\n\r]*(\n|\r\n|\r)" } */
+/* { dg-output "    #0 0x\[0-9a-f\]+ (in _*foo(\[^\n\r]*misalign-1.c:10|\[^\n\r]*:0)|\[(\])\[^\n\r]*(\n|\r\n|\r)" } */
+/* { dg-output "    #1 0x\[0-9a-f\]+ (in _*main (\[^\n\r]*misalign-1.c:34|\[^\n\r]*:0)|\[(\]).*(\n|\r\n|\r)" } */
diff --git a/gcc/testsuite/c-c++-common/asan/misalign-2.c b/gcc/testsuite/c-c++-common/asan/misalign-2.c
new file mode 100644
index 0000000..7fbe299
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/asan/misalign-2.c
@@ -0,0 +1,42 @@ 
+/* { dg-do run { target { ilp32 || lp64 } } } */
+/* { dg-options "-O2" } */
+/* { dg-shouldfail "asan" } */
+
+struct S { int i; } __attribute__ ((packed));
+
+__attribute__((noinline, noclone)) int
+foo (struct S *s)
+{
+  return s->i;
+}
+
+__attribute__((noinline, noclone)) int
+bar (int *s)
+{
+  return *s;
+}
+
+__attribute__((noinline, noclone)) struct S
+baz (struct S *s)
+{
+  return *s;
+}
+
+int
+main ()
+{
+  struct T { char a[3]; struct S b[3]; char c; } t;
+  int v = 5;
+  struct S *p = t.b;
+  asm volatile ("" : "+rm" (p));
+  p += 3;
+  if (bar (&v) != 5) __builtin_abort ();
+  volatile struct S w = baz (p);
+  return 0;
+}
+
+/* { dg-output "ERROR: AddressSanitizer:\[^\n\r]*on address\[^\n\r]*" } */
+/* { dg-output "0x\[0-9a-f\]+ at pc 0x\[0-9a-f\]+ bp 0x\[0-9a-f\]+ sp 0x\[0-9a-f\]+\[^\n\r]*(\n|\r\n|\r)" } */
+/* { dg-output "\[^\n\r]*READ of size 4 at 0x\[0-9a-f\]+ thread T0\[^\n\r]*(\n|\r\n|\r)" } */
+/* { dg-output "    #0 0x\[0-9a-f\]+ (in _*baz(\[^\n\r]*misalign-2.c:22|\[^\n\r]*:0)|\[(\])\[^\n\r]*(\n|\r\n|\r)" } */
+/* { dg-output "    #1 0x\[0-9a-f\]+ (in _*main (\[^\n\r]*misalign-2.c:34|\[^\n\r]*:0)|\[(\]).*(\n|\r\n|\r)" } */