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 <[email protected]>
> > Acked-by: Jerin Jacob <[email protected]>
> > ---
> > 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.