From patchwork Fri Nov 14 17:31:18 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Enkovich X-Patchwork-Id: 410949 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id B4AED1400AB for ; Sat, 15 Nov 2014 04:31:37 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:mime-version:content-type; q=dns; s= default; b=xM5mipKVx5m7Lv1rK6q4kbf/8BgY9VDXmZCdrd3CUbyzsvBav68bh xZecMvWXCUsE/xWcv4q/ctRHzWlQVvr+xrT2GnsnCCVmm6C26M+AsgPLEgmVSbR9 HyVFiP3KhWlq4Jn/G/kajKDfZIZ2SGAZCMaw7REH+4WQrGqrYFYvBA= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:mime-version:content-type; s= default; bh=lhjIgRJr0+3k5yIHhDoAKvnfksA=; b=S9cGDa6BP+A72RU09wsM RvbVR1/RDIgR1aKjAuTb5MXpoBJCwK6XiT3OXQAYphB+YXTJTlzdDUV5FKFKG7Si r70w7h1wuH17RyqJj81heoG3zN2cBJtiC8qagoHrciWNQ7+CY3wv3eD5VbbleiIs 9peLKM23+ZsyrzkwNDMcitY= Received: (qmail 1416 invoked by alias); 14 Nov 2014 17:31:29 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 1399 invoked by uid 89); 14 Nov 2014 17:31:29 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-pd0-f178.google.com Received: from mail-pd0-f178.google.com (HELO mail-pd0-f178.google.com) (209.85.192.178) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Fri, 14 Nov 2014 17:31:27 +0000 Received: by mail-pd0-f178.google.com with SMTP id y13so1950670pdi.37 for ; Fri, 14 Nov 2014 09:31:25 -0800 (PST) X-Received: by 10.66.118.136 with SMTP id km8mr11841952pab.100.1415986284626; Fri, 14 Nov 2014 09:31:24 -0800 (PST) Received: from msticlxl57.ims.intel.com (fmdmzpr02-ext.fm.intel.com. [192.55.55.37]) by mx.google.com with ESMTPSA id vo10sm28220827pab.19.2014.11.14.09.31.22 for (version=TLSv1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 14 Nov 2014 09:31:23 -0800 (PST) Date: Fri, 14 Nov 2014 20:31:18 +0300 From: Ilya Enkovich To: gcc-patches@gcc.gnu.org Subject: [PATCH, MPX wrappers 3/3] Tests Message-ID: <20141114173118.GC20207@msticlxl57.ims.intel.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-IsSubscribed: yes Hi, Here are few tests for MPX wrappers. Will add more in case patches #1,2 are OK. Thanks, Ilya --- 2014-11-14 Ilya Enkovich * lib/mpx-dg.exp (mpx_link_flags): Set path to wrappers library. * gcc.target/i386/mpx/calloc-1-lbv.c: New. * gcc.target/i386/mpx/calloc-1-ubv.c: New. * gcc.target/i386/mpx/calloc-1-nov.c: New. * gcc.target/i386/mpx/malloc-1-lbv.c: New. * gcc.target/i386/mpx/malloc-1-nov.c: New. * gcc.target/i386/mpx/malloc-1-ubv.c: New. * gcc.target/i386/mpx/mmap-1-lbv.c: New. * gcc.target/i386/mpx/mmap-1-nov.c: New. * gcc.target/i386/mpx/mmap-1-ubv.c: New. diff --git a/gcc/testsuite/gcc.target/i386/mpx/calloc-1-lbv.c b/gcc/testsuite/gcc.target/i386/mpx/calloc-1-lbv.c new file mode 100644 index 0000000..0ba5d73 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/mpx/calloc-1-lbv.c @@ -0,0 +1,26 @@ +/* { dg-do run } */ +/* { dg-shouldfail "bounds violation" } */ +/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ + + +#define SHOULDFAIL + +#include "mpx-check.h" + +int rd (int *p, int i) +{ + int res = p[i]; + printf ("%d\n", res); + return res; +} + +int mpx_test (int argc, const char **argv) +{ + int *buf = (int *)calloc (100, sizeof(int)); + + rd (buf, -1); + + free (buf); + + return 0; +} diff --git a/gcc/testsuite/gcc.target/i386/mpx/calloc-1-nov.c b/gcc/testsuite/gcc.target/i386/mpx/calloc-1-nov.c new file mode 100644 index 0000000..cb755e5 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/mpx/calloc-1-nov.c @@ -0,0 +1,24 @@ +/* { dg-do run } */ +/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ + + +#include "mpx-check.h" + +int rd (int *p, int i) +{ + int res = p[i]; + printf ("%d\n", res); + return res; +} + +int mpx_test (int argc, const char **argv) +{ + int *buf = (int *)calloc (100, sizeof(int)); + + rd (buf, 0); + rd (buf, 99); + + free (buf); + + return 0; +} diff --git a/gcc/testsuite/gcc.target/i386/mpx/calloc-1-ubv.c b/gcc/testsuite/gcc.target/i386/mpx/calloc-1-ubv.c new file mode 100644 index 0000000..a932a8c --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/mpx/calloc-1-ubv.c @@ -0,0 +1,26 @@ +/* { dg-do run } */ +/* { dg-shouldfail "bounds violation" } */ +/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ + + +#define SHOULDFAIL + +#include "mpx-check.h" + +int rd (int *p, int i) +{ + int res = p[i]; + printf ("%d\n", res); + return res; +} + +int mpx_test (int argc, const char **argv) +{ + int *buf = (int *)calloc (100, sizeof(int)); + + rd (buf, 100); + + free (buf); + + return 0; +} diff --git a/gcc/testsuite/gcc.target/i386/mpx/malloc-1-lbv.c b/gcc/testsuite/gcc.target/i386/mpx/malloc-1-lbv.c new file mode 100644 index 0000000..aa2aed9 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/mpx/malloc-1-lbv.c @@ -0,0 +1,26 @@ +/* { dg-do run } */ +/* { dg-shouldfail "bounds violation" } */ +/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ + + +#define SHOULDFAIL + +#include "mpx-check.h" + +int rd (int *p, int i) +{ + int res = p[i]; + printf ("%d\n", res); + return res; +} + +int mpx_test (int argc, const char **argv) +{ + int *buf = (int *)malloc (100 * sizeof(int)); + + rd (buf, -1); + + free (buf); + + return 0; +} diff --git a/gcc/testsuite/gcc.target/i386/mpx/malloc-1-nov.c b/gcc/testsuite/gcc.target/i386/mpx/malloc-1-nov.c new file mode 100644 index 0000000..56f26e9 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/mpx/malloc-1-nov.c @@ -0,0 +1,24 @@ +/* { dg-do run } */ +/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ + + +#include "mpx-check.h" + +int rd (int *p, int i) +{ + int res = p[i]; + printf ("%d\n", res); + return res; +} + +int mpx_test (int argc, const char **argv) +{ + int *buf = (int *)malloc (100 * sizeof(int)); + + rd (buf, 0); + rd (buf, 99); + + free (buf); + + return 0; +} diff --git a/gcc/testsuite/gcc.target/i386/mpx/malloc-1-ubv.c b/gcc/testsuite/gcc.target/i386/mpx/malloc-1-ubv.c new file mode 100644 index 0000000..6f48ec2 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/mpx/malloc-1-ubv.c @@ -0,0 +1,26 @@ +/* { dg-do run } */ +/* { dg-shouldfail "bounds violation" } */ +/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ + + +#define SHOULDFAIL + +#include "mpx-check.h" + +int rd (int *p, int i) +{ + int res = p[i]; + printf ("%d\n", res); + return res; +} + +int mpx_test (int argc, const char **argv) +{ + int *buf = (int *)malloc (100 * sizeof(int)); + + rd (buf, 100); + + free (buf); + + return 0; +} diff --git a/gcc/testsuite/gcc.target/i386/mpx/realloc-1-lbv.c b/gcc/testsuite/gcc.target/i386/mpx/realloc-1-lbv.c new file mode 100644 index 0000000..961196f --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/mpx/realloc-1-lbv.c @@ -0,0 +1,27 @@ +/* { dg-do run } */ +/* { dg-shouldfail "bounds violation" } */ +/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ + + +#define SHOULDFAIL + +#include "mpx-check.h" + +int rd (int *p, int i) +{ + int res = p[i]; + printf ("%d\n", res); + return res; +} + +int mpx_test (int argc, const char **argv) +{ + int *buf = (int *)malloc (100 * sizeof(int)); + buf = (int *)realloc (buf, 200 * sizeof(int)); + + rd (buf, -1); + + free (buf); + + return 0; +} diff --git a/gcc/testsuite/gcc.target/i386/mpx/realloc-1-nov.c b/gcc/testsuite/gcc.target/i386/mpx/realloc-1-nov.c new file mode 100644 index 0000000..f4b3dd8 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/mpx/realloc-1-nov.c @@ -0,0 +1,25 @@ +/* { dg-do run } */ +/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ + + +#include "mpx-check.h" + +int rd (int *p, int i) +{ + int res = p[i]; + printf ("%d\n", res); + return res; +} + +int mpx_test (int argc, const char **argv) +{ + int *buf = (int *)malloc (100 * sizeof(int)); + buf = (int *)realloc (buf, 200 * sizeof(int)); + + rd (buf, 0); + rd (buf, 199); + + free (buf); + + return 0; +} diff --git a/gcc/testsuite/gcc.target/i386/mpx/realloc-1-ubv.c b/gcc/testsuite/gcc.target/i386/mpx/realloc-1-ubv.c new file mode 100644 index 0000000..8a14baa --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/mpx/realloc-1-ubv.c @@ -0,0 +1,27 @@ +/* { dg-do run } */ +/* { dg-shouldfail "bounds violation" } */ +/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ + + +#define SHOULDFAIL + +#include "mpx-check.h" + +int rd (int *p, int i) +{ + int res = p[i]; + printf ("%d\n", res); + return res; +} + +int mpx_test (int argc, const char **argv) +{ + int *buf = (int *)malloc (100 * sizeof(int)); + buf = (int *)realloc (buf, 200 * sizeof(int)); + + rd (buf, 200); + + free (buf); + + return 0; +} diff --git a/gcc/testsuite/gcc.target/i386/mpx/realloc-2-lbv.c b/gcc/testsuite/gcc.target/i386/mpx/realloc-2-lbv.c new file mode 100644 index 0000000..919f62a --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/mpx/realloc-2-lbv.c @@ -0,0 +1,27 @@ +/* { dg-do run } */ +/* { dg-shouldfail "bounds violation" } */ +/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ + + +#define SHOULDFAIL + +#include "mpx-check.h" + +int rd (int *p, int i) +{ + int res = p[i]; + printf ("%d\n", res); + return res; +} + +int mpx_test (int argc, const char **argv) +{ + int *buf = (int *)malloc (100 * sizeof(int)); + buf = (int *)realloc (buf, 10 * sizeof(int)); + + rd (buf, -1); + + free (buf); + + return 0; +} diff --git a/gcc/testsuite/gcc.target/i386/mpx/realloc-2-nov.c b/gcc/testsuite/gcc.target/i386/mpx/realloc-2-nov.c new file mode 100644 index 0000000..569cd24 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/mpx/realloc-2-nov.c @@ -0,0 +1,25 @@ +/* { dg-do run } */ +/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ + + +#include "mpx-check.h" + +int rd (int *p, int i) +{ + int res = p[i]; + printf ("%d\n", res); + return res; +} + +int mpx_test (int argc, const char **argv) +{ + int *buf = (int *)malloc (100 * sizeof(int)); + buf = (int *)realloc (buf, 10 * sizeof(int)); + + rd (buf, 0); + rd (buf, 9); + + free (buf); + + return 0; +} diff --git a/gcc/testsuite/gcc.target/i386/mpx/realloc-2-ubv.c b/gcc/testsuite/gcc.target/i386/mpx/realloc-2-ubv.c new file mode 100644 index 0000000..36eb90c --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/mpx/realloc-2-ubv.c @@ -0,0 +1,27 @@ +/* { dg-do run } */ +/* { dg-shouldfail "bounds violation" } */ +/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ + + +#define SHOULDFAIL + +#include "mpx-check.h" + +int rd (int *p, int i) +{ + int res = p[i]; + printf ("%d\n", res); + return res; +} + +int mpx_test (int argc, const char **argv) +{ + int *buf = (int *)malloc (100 * sizeof(int)); + buf = (int *)realloc (buf, 10 * sizeof(int)); + + rd (buf, 10); + + free (buf); + + return 0; +} diff --git a/gcc/testsuite/lib/mpx-dg.exp b/gcc/testsuite/lib/mpx-dg.exp index ddedf09..b2fcce6 100644 --- a/gcc/testsuite/lib/mpx-dg.exp +++ b/gcc/testsuite/lib/mpx-dg.exp @@ -47,6 +47,14 @@ proc mpx_link_flags { paths } { append flags " -L${gccpath}/libmpx/mpxrt/.libs " append ld_library_path ":${gccpath}/libmpx/mpxrt/.libs" } + + if { [file exists "${gccpath}/libmpx/mpxwrap/.libs/libmpxwrappers.a"] + || [file exists "${gccpath}/libmpx/mpxwrap/.libs/libmpxwrappers.${shlib_ext}"] } { + append flags " -B${gccpath}/libmpx/ " + append flags " -B${gccpath}/libmpx/mpxwrap " + append flags " -L${gccpath}/libmpx/mpxwrap/.libs " + append ld_library_path ":${gccpath}/libmpx/mpxwrap/.libs" + } } else { global tool_root_dir @@ -55,6 +63,12 @@ proc mpx_link_flags { paths } { append flags "-L${libmpx} " append ld_library_path ":${libmpx}" } + + set libmpxwrappers [lookfor_file ${tool_root_dir} libmpxwrappers] + if { $libmpxwrappers != "" } { + append flags "-L${libmpxwrappers} " + append ld_library_path ":${libmpxwrappers}" + } } set_ld_library_path_env_vars