From: Pavan Nikhilesh <pbhagavatula@caviumnetworks.com>
To: thomas@monjalon.net
Cc: dev@dpdk.org
Subject: Re: [dpdk-dev] [PATCH v5 01/11] eal: add common test assert macros
Date: Thu, 11 Jan 2018 15:59:11 +0530 [thread overview]
Message-ID: <20180111102910.fchcf42jm6usbz2l@Pavan-LT> (raw)
In-Reply-To: <20180111102156.12726-1-pbhagavatula@caviumnetworks.com>
+Cc: thomas@monjalon.net
On Thu, Jan 11, 2018 at 03:51:46PM +0530, Pavan Nikhilesh wrote:
> Adding common test assertion macros for unit testing.
> Replaced common macros in test/test.h with new RTE_TEST_ASSERT_* macros.
>
> Signed-off-by: Pavan Nikhilesh <pbhagavatula@caviumnetworks.com>
> Acked-by: Jerin Jacob <jerin.jacob@caviumnetworks.com>
> ---
>
> v5 Changes:
> - rebase patchset
> - remove duplication between test/test/test.h and rte_test.h by mapping
> RTE_TEST_ASSERT* macros to test.h
>
> v4 Changes:
> - add SPDX licence tags.
> - change octeontx selftest name to 'ssovf_evdev_selftest'
>
> v3 Changes:
> - add eventdev driver specific selftest to test/test
>
> v2 Changes:
> - remove duplications of test macros.
> - add selftest to test/test.
> - remove selftest devargs from sw eventdev.
>
> lib/librte_eal/common/Makefile | 2 +-
> lib/librte_eal/common/include/rte_test.h | 46 +++++++++++++++++++++
> test/test/test.h | 70 +++++---------------------------
> 3 files changed, 58 insertions(+), 60 deletions(-)
> create mode 100644 lib/librte_eal/common/include/rte_test.h
>
> diff --git a/lib/librte_eal/common/Makefile b/lib/librte_eal/common/Makefile
> index 9effd0d45..eba1059f2 100644
> --- a/lib/librte_eal/common/Makefile
> +++ b/lib/librte_eal/common/Makefile
> @@ -43,7 +43,7 @@ INC += rte_hexdump.h rte_devargs.h rte_bus.h rte_dev.h
> INC += rte_pci_dev_feature_defs.h rte_pci_dev_features.h
> INC += rte_malloc.h rte_keepalive.h rte_time.h
> INC += rte_service.h rte_service_component.h
> -INC += rte_bitmap.h rte_vfio.h
> +INC += rte_bitmap.h rte_vfio.h rte_test.h
>
> GENERIC_INC := rte_atomic.h rte_byteorder.h rte_cycles.h rte_prefetch.h
> GENERIC_INC += 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/common/include/rte_test.h
> new file mode 100644
> index 000000000..89e47f47a
> --- /dev/null
> +++ b/lib/librte_eal/common/include/rte_test.h
> @@ -0,0 +1,46 @@
> +/* SPDX-License-Identifier: BSD-3-Clause
> + * Copyright(c) 2015 Cavium, Inc
> + */
> +
> +#ifndef _RTE_TEST_H_
> +#define _RTE_TEST_H_
> +
> +#include <rte_log.h>
> +
> +/* Before including rte_test.h file you can define
> + * RTE_TEST_TRACE_FAILURE(_file, _line, _func) macro to better trace/debug test
> + * failures. Mostly useful in development phase.
> + */
> +#ifndef RTE_TEST_TRACE_FAILURE
> +#define RTE_TEST_TRACE_FAILURE(_file, _line, _func)
> +#endif
> +
> +
> +#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__); \
> + RTE_TEST_TRACE_FAILURE(__FILE__, __LINE__, __func__); \
> + return -1; \
> + } \
> +} while (0)
> +
> +#define RTE_TEST_ASSERT_EQUAL(a, b, msg, ...) \
> + RTE_TEST_ASSERT(a == b, msg, ##__VA_ARGS__)
> +
> +#define RTE_TEST_ASSERT_NOT_EQUAL(a, b, msg, ...) \
> + RTE_TEST_ASSERT(a != b, msg, ##__VA_ARGS__)
> +
> +#define RTE_TEST_ASSERT_SUCCESS(val, msg, ...) \
> + RTE_TEST_ASSERT(val == 0, msg, ##__VA_ARGS__)
> +
> +#define RTE_TEST_ASSERT_FAIL(val, msg, ...) \
> + RTE_TEST_ASSERT(val != 0, msg, ##__VA_ARGS__)
> +
> +#define RTE_TEST_ASSERT_NULL(val, msg, ...) \
> + RTE_TEST_ASSERT(val == NULL, msg, ##__VA_ARGS__)
> +
> +#define RTE_TEST_ASSERT_NOT_NULL(val, msg, ...) \
> + RTE_TEST_ASSERT(val != NULL, msg, ##__VA_ARGS__)
> +
> +#endif /* _RTE_TEST_H_ */
> diff --git a/test/test/test.h b/test/test/test.h
> index 08ffe949c..0ea18586c 100644
> --- a/test/test/test.h
> +++ b/test/test/test.h
> @@ -38,7 +38,6 @@
> #include <sys/queue.h>
>
> #include <rte_common.h>
> -#include <rte_log.h>
>
> #define TEST_SUCCESS (0)
> #define TEST_FAILED (-1)
> @@ -50,23 +49,13 @@
> # define TEST_TRACE_FAILURE(_file, _line, _func)
> #endif
>
> -#define TEST_ASSERT(cond, msg, ...) do { \
> - if (!(cond)) { \
> - printf("TestCase %s() line %d failed: " \
> - msg "\n", __func__, __LINE__, ##__VA_ARGS__); \
> - TEST_TRACE_FAILURE(__FILE__, __LINE__, __func__); \
> - return TEST_FAILED; \
> - } \
> -} while (0)
> +#define RTE_TEST_TRACE_FAILURE TEST_TRACE_FAILURE
>
> -#define TEST_ASSERT_EQUAL(a, b, msg, ...) do { \
> - if (!(a == b)) { \
> - printf("TestCase %s() line %d failed: " \
> - msg "\n", __func__, __LINE__, ##__VA_ARGS__); \
> - TEST_TRACE_FAILURE(__FILE__, __LINE__, __func__); \
> - return TEST_FAILED; \
> - } \
> -} while (0)
> +#include <rte_test.h>
> +
> +#define TEST_ASSERT RTE_TEST_ASSERT
> +
> +#define TEST_ASSERT_EQUAL RTE_TEST_ASSERT_EQUAL
>
> /* Compare two buffers (length in bytes) */
> #define TEST_ASSERT_BUFFERS_ARE_EQUAL(a, b, len, msg, ...) do { \
> @@ -134,52 +123,15 @@
> } \
> } while (0)
>
> -#define TEST_ASSERT_NOT_EQUAL(a, b, msg, ...) do { \
> - if (!(a != b)) { \
> - printf("TestCase %s() line %d failed: " \
> - msg "\n", __func__, __LINE__, ##__VA_ARGS__); \
> - TEST_TRACE_FAILURE(__FILE__, __LINE__, __func__); \
> - return TEST_FAILED; \
> - } \
> -} while (0)
> +#define TEST_ASSERT_NOT_EQUAL RTE_TEST_ASSERT_NOT_EQUAL
>
> -#define TEST_ASSERT_SUCCESS(val, msg, ...) do { \
> - typeof(val) _val = (val); \
> - if (!(_val == 0)) { \
> - printf("TestCase %s() line %d failed (err %d): " \
> - msg "\n", __func__, __LINE__, _val, \
> - ##__VA_ARGS__); \
> - TEST_TRACE_FAILURE(__FILE__, __LINE__, __func__); \
> - return TEST_FAILED; \
> - } \
> -} while (0)
> +#define TEST_ASSERT_SUCCESS RTE_TEST_ASSERT_SUCCESS
>
> -#define TEST_ASSERT_FAIL(val, msg, ...) do { \
> - if (!(val != 0)) { \
> - printf("TestCase %s() line %d failed: " \
> - msg "\n", __func__, __LINE__, ##__VA_ARGS__); \
> - TEST_TRACE_FAILURE(__FILE__, __LINE__, __func__); \
> - return TEST_FAILED; \
> - } \
> -} while (0)
> +#define TEST_ASSERT_FAIL RTE_TEST_ASSERT_FAIL
>
> -#define TEST_ASSERT_NULL(val, msg, ...) do { \
> - if (!(val == NULL)) { \
> - printf("TestCase %s() line %d failed: " \
> - msg "\n", __func__, __LINE__, ##__VA_ARGS__); \
> - TEST_TRACE_FAILURE(__FILE__, __LINE__, __func__); \
> - return TEST_FAILED; \
> - } \
> -} while (0)
> +#define TEST_ASSERT_NULL RTE_TEST_ASSERT_NULL
>
> -#define TEST_ASSERT_NOT_NULL(val, msg, ...) do { \
> - if (!(val != NULL)) { \
> - printf("TestCase %s() line %d failed: " \
> - msg "\n", __func__, __LINE__, ##__VA_ARGS__); \
> - TEST_TRACE_FAILURE(__FILE__, __LINE__, __func__); \
> - return TEST_FAILED; \
> - } \
> -} while (0)
> +#define TEST_ASSERT_NOT_NULL RTE_TEST_ASSERT_NOT_NULL
>
> struct unit_test_case {
> int (*setup)(void);
> --
> 2.15.1
>
next prev parent reply other threads:[~2018-01-11 10:29 UTC|newest]
Thread overview: 87+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-12 19:27 [dpdk-dev] [PATCH 1/7] event/octeontx: move eventdev octeontx test to driver Pavan Nikhilesh
2017-12-12 19:27 ` [dpdk-dev] [PATCH 2/7] event/octeontx: modify octeontx eventdev test Pavan Nikhilesh
2017-12-12 19:27 ` [dpdk-dev] [PATCH 3/7] event/octeontx: add selftest to device arguments Pavan Nikhilesh
2017-12-12 19:27 ` [dpdk-dev] [PATCH 4/7] event/sw: move eventdev sw test to driver Pavan Nikhilesh
2017-12-13 10:22 ` Van Haaren, Harry
2017-12-12 19:27 ` [dpdk-dev] [PATCH 5/7] event/sw: modify eventdev sw test Pavan Nikhilesh
2017-12-12 19:27 ` [dpdk-dev] [PATCH 6/7] event/sw: add selftest to device arguments Pavan Nikhilesh
2017-12-12 19:27 ` [dpdk-dev] [PATCH 7/7] doc: update eventdev documentation Pavan Nikhilesh
2017-12-13 13:48 ` Kovacevic, Marko
2017-12-13 10:19 ` [dpdk-dev] [PATCH 1/7] event/octeontx: move eventdev octeontx test to driver Van Haaren, Harry
2017-12-13 10:34 ` Bruce Richardson
2017-12-13 11:24 ` Pavan Nikhilesh Bhagavatula
2017-12-13 11:39 ` Bruce Richardson
2017-12-13 11:19 ` Pavan Nikhilesh Bhagavatula
2017-12-13 11:41 ` Bruce Richardson
2017-12-13 15:50 ` Pavan Nikhilesh Bhagavatula
2017-12-14 15:01 ` [dpdk-dev] [PATCH v2 00/11] eventdev: move eventdev pmd specific tests into the pmd dir Pavan Nikhilesh
2017-12-14 15:01 ` [dpdk-dev] [PATCH v2 01/11] eal: add common test assert macros Pavan Nikhilesh
2017-12-14 18:43 ` Ananyev, Konstantin
2017-12-15 9:04 ` Pavan Nikhilesh Bhagavatula
2017-12-15 10:58 ` Ananyev, Konstantin
2017-12-15 11:32 ` Pavan Nikhilesh Bhagavatula
2018-01-10 19:16 ` Jerin Jacob
2018-01-10 20:18 ` Thomas Monjalon
2017-12-14 15:01 ` [dpdk-dev] [PATCH v2 02/11] eventdev: add API to perform self test Pavan Nikhilesh
2017-12-19 15:45 ` Van Haaren, Harry
2017-12-14 15:01 ` [dpdk-dev] [PATCH v2 03/11] event/octeontx: move eventdev octeontx test to driver Pavan Nikhilesh
2017-12-14 15:01 ` [dpdk-dev] [PATCH v2 04/11] event/octeontx: modify octeontx eventdev test Pavan Nikhilesh
2017-12-14 15:01 ` [dpdk-dev] [PATCH v2 05/11] event/octeontx: update octeontx eventdev selftest ops Pavan Nikhilesh
2017-12-14 15:01 ` [dpdk-dev] [PATCH v2 06/11] event/octeontx: add selftest to device arguments Pavan Nikhilesh
2017-12-14 15:01 ` [dpdk-dev] [PATCH v2 07/11] event/sw: move eventdev software test to driver Pavan Nikhilesh
2017-12-14 15:01 ` [dpdk-dev] [PATCH v2 08/11] event/sw: modify eventdev software test Pavan Nikhilesh
2017-12-19 15:44 ` Van Haaren, Harry
2017-12-14 15:01 ` [dpdk-dev] [PATCH v2 09/11] event/sw: update software eventdev selftest ops Pavan Nikhilesh
2017-12-19 15:46 ` Van Haaren, Harry
2017-12-14 15:01 ` [dpdk-dev] [PATCH v2 10/11] test: register eventdev selftest Pavan Nikhilesh
2017-12-19 15:27 ` Van Haaren, Harry
2017-12-19 18:44 ` Pavan Nikhilesh
2017-12-20 11:07 ` Van Haaren, Harry
2017-12-14 15:01 ` [dpdk-dev] [PATCH v2 11/11] doc: update eventdev documentation Pavan Nikhilesh
2017-12-25 19:17 ` [dpdk-dev] [PATCH v3 01/11] eal: add common test assert macros Pavan Nikhilesh
2017-12-25 19:17 ` [dpdk-dev] [PATCH v3 02/11] eventdev: add API to perform self test Pavan Nikhilesh
2018-01-08 9:56 ` Jerin Jacob
2018-01-08 10:34 ` Pavan Nikhilesh
2017-12-25 19:17 ` [dpdk-dev] [PATCH v3 03/11] event/octeontx: move eventdev octeontx test to driver Pavan Nikhilesh
2018-01-08 9:58 ` Jerin Jacob
2017-12-25 19:17 ` [dpdk-dev] [PATCH v3 04/11] event/octeontx: modify octeontx eventdev test Pavan Nikhilesh
2017-12-26 14:11 ` Neil Horman
2017-12-27 5:18 ` Pavan Nikhilesh
2017-12-25 19:17 ` [dpdk-dev] [PATCH v3 05/11] event/octeontx: update octeontx eventdev selftest ops Pavan Nikhilesh
2018-01-08 10:09 ` Jerin Jacob
2017-12-25 19:17 ` [dpdk-dev] [PATCH v3 06/11] event/octeontx: add selftest to device arguments Pavan Nikhilesh
2018-01-08 10:14 ` Jerin Jacob
2017-12-25 19:17 ` [dpdk-dev] [PATCH v3 07/11] event/sw: move eventdev software test to driver Pavan Nikhilesh
2017-12-25 19:17 ` [dpdk-dev] [PATCH v3 08/11] event/sw: modify eventdev software test Pavan Nikhilesh
2017-12-25 19:17 ` [dpdk-dev] [PATCH v3 09/11] event/sw: update software eventdev selftest ops Pavan Nikhilesh
2017-12-25 19:17 ` [dpdk-dev] [PATCH v3 10/11] test: register eventdev selftest Pavan Nikhilesh
2018-01-08 9:49 ` Jerin Jacob
2017-12-25 19:17 ` [dpdk-dev] [PATCH v3 11/11] doc: update eventdev documentation Pavan Nikhilesh
2018-01-08 11:17 ` [dpdk-dev] [PATCH v3 01/11] eal: add common test assert macros Jerin Jacob
2018-01-08 13:47 ` [dpdk-dev] [PATCH v4 " Pavan Nikhilesh
2018-01-08 13:47 ` [dpdk-dev] [PATCH v4 02/11] eventdev: add API to perform self test Pavan Nikhilesh
2018-01-08 13:47 ` [dpdk-dev] [PATCH v4 03/11] event/octeontx: move eventdev octeontx test to driver Pavan Nikhilesh
2018-01-08 13:47 ` [dpdk-dev] [PATCH v4 04/11] event/octeontx: modify octeontx eventdev test Pavan Nikhilesh
2018-01-08 13:47 ` [dpdk-dev] [PATCH v4 05/11] event/octeontx: update octeontx eventdev selftest ops Pavan Nikhilesh
2018-01-08 13:47 ` [dpdk-dev] [PATCH v4 06/11] event/octeontx: add selftest to device arguments Pavan Nikhilesh
2018-01-08 13:47 ` [dpdk-dev] [PATCH v4 07/11] event/sw: move eventdev software test to driver Pavan Nikhilesh
2018-01-08 13:47 ` [dpdk-dev] [PATCH v4 08/11] event/sw: modify eventdev software test Pavan Nikhilesh
2018-01-08 13:47 ` [dpdk-dev] [PATCH v4 09/11] event/sw: update software eventdev selftest ops Pavan Nikhilesh
2018-01-08 13:47 ` [dpdk-dev] [PATCH v4 10/11] test: register eventdev selftest Pavan Nikhilesh
2018-01-08 13:47 ` [dpdk-dev] [PATCH v4 11/11] doc: update eventdev documentation Pavan Nikhilesh
2018-01-10 20:20 ` [dpdk-dev] [PATCH v4 01/11] eal: add common test assert macros Thomas Monjalon
2018-01-11 7:11 ` Pavan Nikhilesh
2018-01-11 10:21 ` [dpdk-dev] [PATCH v5 " Pavan Nikhilesh
2018-01-11 10:21 ` [dpdk-dev] [PATCH v5 02/11] eventdev: add API to perform self test Pavan Nikhilesh
2018-01-11 10:21 ` [dpdk-dev] [PATCH v5 03/11] event/octeontx: move eventdev octeontx test to driver Pavan Nikhilesh
2018-01-11 10:21 ` [dpdk-dev] [PATCH v5 04/11] event/octeontx: modify octeontx eventdev test Pavan Nikhilesh
2018-01-11 10:21 ` [dpdk-dev] [PATCH v5 05/11] event/octeontx: update octeontx eventdev selftest ops Pavan Nikhilesh
2018-01-11 10:21 ` [dpdk-dev] [PATCH v5 06/11] event/octeontx: add selftest to device arguments Pavan Nikhilesh
2018-01-11 10:21 ` [dpdk-dev] [PATCH v5 07/11] event/sw: move eventdev software test to driver Pavan Nikhilesh
2018-01-11 10:21 ` [dpdk-dev] [PATCH v5 08/11] event/sw: modify eventdev software test Pavan Nikhilesh
2018-01-11 10:21 ` [dpdk-dev] [PATCH v5 09/11] event/sw: update software eventdev selftest ops Pavan Nikhilesh
2018-01-11 10:21 ` [dpdk-dev] [PATCH v5 10/11] test: register eventdev selftest Pavan Nikhilesh
2018-01-11 10:21 ` [dpdk-dev] [PATCH v5 11/11] doc: update eventdev documentation Pavan Nikhilesh
2018-01-11 11:27 ` Jerin Jacob
2018-01-11 10:29 ` Pavan Nikhilesh [this message]
2018-01-11 10:44 ` [dpdk-dev] [PATCH v5 01/11] eal: add common test assert macros Thomas Monjalon
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180111102910.fchcf42jm6usbz2l@Pavan-LT \
--to=pbhagavatula@caviumnetworks.com \
--cc=dev@dpdk.org \
--cc=thomas@monjalon.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).