From mboxrd@z Thu Jan 1 00:00:00 1970 From: Thomas Monjalon Subject: Re: [PATCH v4 01/11] eal: add common test assert macros Date: Wed, 10 Jan 2018 21:20:06 +0100 Message-ID: <2190857.p1lhncMtO2@xps> References: <20171212192713.17620-1-pbhagavatula@caviumnetworks.com> <20180108134742.30857-1-pbhagavatula@caviumnetworks.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7Bit Cc: dev@dpdk.org, jerin.jacob@caviumnetworks.com, harry.van.haaren@intel.com, gage.eads@intel.com, liang.j.ma@intel.com To: Pavan Nikhilesh Return-path: Received: from out3-smtp.messagingengine.com (out3-smtp.messagingengine.com [66.111.4.27]) by dpdk.org (Postfix) with ESMTP id 198AE1B22B for ; Wed, 10 Jan 2018 21:20:32 +0100 (CET) In-Reply-To: <20180108134742.30857-1-pbhagavatula@caviumnetworks.com> List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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? Can we always use rte_test.h from EAL? > +#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?