From mboxrd@z Thu Jan 1 00:00:00 1970 From: Pavan Nikhilesh Subject: Re: [PATCH v4 01/11] eal: add common test assert macros Date: Thu, 11 Jan 2018 12:41:14 +0530 Message-ID: <20180111071113.vi6mqdfcgifdd5zm@Pavan-LT> References: <20171212192713.17620-1-pbhagavatula@caviumnetworks.com> <20180108134742.30857-1-pbhagavatula@caviumnetworks.com> <2190857.p1lhncMtO2@xps> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: dev@dpdk.org To: Thomas Monjalon , jerin.jacob@caviumnetworks.com, harry.van.haaren@intel.com, gage.eads@intel.com, liang.j.ma@intel.com Return-path: Received: from NAM02-BL2-obe.outbound.protection.outlook.com (mail-bl2nam02on0089.outbound.protection.outlook.com [104.47.38.89]) by dpdk.org (Postfix) with ESMTP id 3AB201B1CE for ; Thu, 11 Jan 2018 08:11:56 +0100 (CET) Content-Disposition: inline In-Reply-To: <2190857.p1lhncMtO2@xps> List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" On Wed, Jan 10, 2018 at 09:20:06PM +0100, Thomas Monjalon wrote: > 08/01/2018 14:47, Pavan Nikhilesh: > > Adding common test assertion macros for unit testing. > > Taken from test/test.h. > > > > Signed-off-by: Pavan Nikhilesh > > Acked-by: Jerin Jacob > > --- > > lib/librte_eal/common/Makefile | 2 +- > > lib/librte_eal/common/include/rte_test.h | 69 ++++++++++++++++++++++++++++++++ > > 2 files changed, 70 insertions(+), 1 deletion(-) > > create mode 100644 lib/librte_eal/common/include/rte_test.h > > Is the original file still needed? The original file still contains macros and structs related to unit test suite, I think everything should be gradually ported to rte_test.h > Can we always use rte_test.h from EAL? I will link the test assert macros rte test assert macros and not remove them for now as it would break other tests. > > > +#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 == b)) { \ > > + RTE_LOG(DEBUG, EAL, "Test assert %s line %d failed: " \ > > + msg "\n", __func__, __LINE__, ##__VA_ARGS__); \ > > + return -1; \ > > + } \ > > +} while (0) > > Why not call RTE_TEST_ASSERT in all derived macros? Agreed, that would reduce code duplication will send a v5 with the changes.