From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by dpdk.org (Postfix) with ESMTP id 56FC39FE for ; Thu, 14 Dec 2017 19:43:29 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 14 Dec 2017 10:43:28 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.45,401,1508828400"; d="scan'208";a="1678414" Received: from irsmsx103.ger.corp.intel.com ([163.33.3.157]) by fmsmga002.fm.intel.com with ESMTP; 14 Dec 2017 10:43:26 -0800 Received: from irsmsx105.ger.corp.intel.com ([169.254.7.67]) by IRSMSX103.ger.corp.intel.com ([169.254.3.49]) with mapi id 14.03.0319.002; Thu, 14 Dec 2017 18:43:25 +0000 From: "Ananyev, Konstantin" To: Pavan Nikhilesh , "jerin.jacob@caviumnetworks.com" , "santosh.shukla@caviumnetworks.com" , "Richardson, Bruce" , "Van Haaren, Harry" , "Eads, Gage" , "hemant.agrawal@nxp.com" , "nipun.gupta@nxp.com" , "Ma, Liang J" CC: "dev@dpdk.org" Thread-Topic: [dpdk-dev] [PATCH v2 01/11] eal: add common test assert macros Thread-Index: AQHTdOyZUAPCJF8ezkSgc6sw+hJ8a6NDLMfg Date: Thu, 14 Dec 2017 18:43:24 +0000 Message-ID: <2601191342CEEE43887BDE71AB9772585FAC9A88@irsmsx105.ger.corp.intel.com> References: <20171212192713.17620-1-pbhagavatula@caviumnetworks.com> <20171214150138.25667-1-pbhagavatula@caviumnetworks.com> <20171214150138.25667-2-pbhagavatula@caviumnetworks.com> In-Reply-To: <20171214150138.25667-2-pbhagavatula@caviumnetworks.com> Accept-Language: en-IE, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiMzZhYTc3NzMtOGI4ZS00ZWExLWI4YjQtY2MxNzcxZDRhNWU4IiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX0lDIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE2LjUuOS4zIiwiVHJ1c3RlZExhYmVsSGFzaCI6IlwvWUR3ZStwazI3QXowWkNUcktJT294b0lRWUREZUVzXC9VOFwvd3lkbGtXZjA9In0= x-ctpclassification: CTP_IC dlp-product: dlpe-windows dlp-version: 11.0.0.116 dlp-reaction: no-action x-originating-ip: [163.33.239.182] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH v2 01/11] eal: add common test assert macros X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 14 Dec 2017 18:43:29 -0000 > -----Original Message----- > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Pavan Nikhilesh > Sent: Thursday, December 14, 2017 3:01 PM > To: jerin.jacob@caviumnetworks.com; santosh.shukla@caviumnetworks.com; Ri= chardson, Bruce ; Van > Haaren, Harry ; Eads, Gage ; hemant.agrawal@nxp.com; nipun.gupta@nxp.com; > Ma, Liang J > Cc: dev@dpdk.org; Pavan Nikhilesh > Subject: [dpdk-dev] [PATCH v2 01/11] eal: add common test assert macros >=20 > Adding common test assertion macros for unit testing. Wonder what's wrong with existing RTE_ASSERT() and RTE_VERIFY()? Konstantin > Taken from test/test.h. >=20 > Signed-off-by: Pavan Nikhilesh > --- > lib/librte_eal/common/Makefile | 2 +- > lib/librte_eal/common/include/rte_test.h | 97 ++++++++++++++++++++++++++= ++++++ > 2 files changed, 98 insertions(+), 1 deletion(-) > create mode 100644 lib/librte_eal/common/include/rte_test.h >=20 > diff --git a/lib/librte_eal/common/Makefile b/lib/librte_eal/common/Makef= ile > index 9effd0d45..eba1059f2 100644 > --- a/lib/librte_eal/common/Makefile > +++ b/lib/librte_eal/common/Makefile > @@ -43,7 +43,7 @@ INC +=3D rte_hexdump.h rte_devargs.h rte_bus.h rte_dev.= h > INC +=3D rte_pci_dev_feature_defs.h rte_pci_dev_features.h > INC +=3D rte_malloc.h rte_keepalive.h rte_time.h > INC +=3D rte_service.h rte_service_component.h > -INC +=3D rte_bitmap.h rte_vfio.h > +INC +=3D rte_bitmap.h rte_vfio.h rte_test.h >=20 > GENERIC_INC :=3D rte_atomic.h rte_byteorder.h rte_cycles.h rte_prefetch.= h > GENERIC_INC +=3D rte_spinlock.h rte_memcpy.h rte_cpuflags.h rte_rwlock.h > diff --git a/lib/librte_eal/common/include/rte_test.h b/lib/librte_eal/co= mmon/include/rte_test.h > new file mode 100644 > index 000000000..256117f79 > --- /dev/null > +++ b/lib/librte_eal/common/include/rte_test.h > @@ -0,0 +1,97 @@ > +/*- > + * BSD LICENSE > + * > + * Copyright(c) 2017 Cavium, Inc. All rights reserved. > + * > + * Redistribution and use in source and binary forms, with or without > + * modification, are permitted provided that the following conditions > + * are met: > + * > + * * Redistributions of source code must retain the above copyright > + * notice, this list of conditions and the following disclaimer. > + * * Redistributions in binary form must reproduce the above copyright > + * notice, this list of conditions and the following disclaimer in > + * the documentation and/or other materials provided with the > + * distribution. > + * * Neither the name of Cavium, Inc nor the names of its > + * contributors may be used to endorse or promote products derived > + * from this software without specific prior written permission. > + * > + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS > + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT > + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS F= OR > + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGH= T > + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTA= L, > + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT > + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF US= E, > + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON A= NY > + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT > + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE U= SE > + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE= . > + */ > + > +#ifndef _RTE_TEST_H_ > +#define _RTE_TEST_H_ > + > +#include > + > +#define RTE_TEST_ASSERT(cond, msg, ...) do { = \ > + if (!(cond)) { \ > + RTE_LOG(DEBUG, EAL, "Test assert %s line %d failed: " \ > + msg "\n", __func__, __LINE__, ##__VA_ARGS__); \ > + return -1; \ > + } \ > +} while (0) > + > +#define RTE_TEST_ASSERT_EQUAL(a, b, msg, ...) do { = \ > + if (!(a =3D=3D b)) { = \ > + RTE_LOG(DEBUG, EAL, "Test assert %s line %d failed: " \ > + msg "\n", __func__, __LINE__, ##__VA_ARGS__); \ > + return -1; \ > + } \ > +} while (0) > + > +#define RTE_TEST_ASSERT_NOT_EQUAL(a, b, msg, ...) do { = \ > + if (!(a !=3D b)) { = \ > + RTE_LOG(DEBUG, EAL, "Test assert %s line %d failed: " \ > + msg "\n", __func__, __LINE__, ##__VA_ARGS__); \ > + return -1; \ > + } \ > +} while (0) > + > +#define RTE_TEST_ASSERT_SUCCESS(val, msg, ...) do { = \ > + typeof(val) _val =3D (val); = \ > + if (!(_val =3D=3D 0)) { = \ > + RTE_LOG(DEBUG, EAL, \ > + "Test assert %s line %d failed (err %d): " \ > + msg "\n", __func__, __LINE__, _val, \ > + ##__VA_ARGS__); \ > + return -1; \ > + } \ > +} while (0) > + > +#define RTE_TEST_ASSERT_FAIL(val, msg, ...) do { = \ > + if (!(val !=3D 0)) { = \ > + RTE_LOG(DEBUG, EAL, "Test assert %s line %d failed: " \ > + msg "\n", __func__, __LINE__, ##__VA_ARGS__); \ > + return -1; \ > + } \ > +} while (0) > + > +#define RTE_TEST_ASSERT_NULL(val, msg, ...) do { = \ > + if (!(val =3D=3D NULL)) { = \ > + RTE_LOG(DEBUG, EAL, "Test assert %s line %d failed: " \ > + msg "\n", __func__, __LINE__, ##__VA_ARGS__); \ > + return -1; \ > + } \ > +} while (0) > + > +#define RTE_TEST_ASSERT_NOT_NULL(val, msg, ...) do { = \ > + if (!(val !=3D NULL)) { = \ > + RTE_LOG(DEBUG, EAL, "Test assert %s line %d failed: " \ > + msg "\n", __func__, __LINE__, ##__VA_ARGS__); \ > + return -1; \ > + } \ > +} while (0) > + > +#endif /* _RTE_TEST_H_ */ > -- > 2.14.1