DPDK patches and discussions
 help / color / mirror / Atom feed
From: Honnappa Nagarahalli <Honnappa.Nagarahalli@arm.com>
To: Thomas Monjalon <thomas@monjalon.net>
Cc: Dharmik Thakkar <Dharmik.Thakkar@arm.com>,
	"Wang, Yipeng1" <yipeng1.wang@intel.com>,
	"Richardson, Bruce" <bruce.richardson@intel.com>,
	"De Lara Guarch, Pablo" <pablo.de.lara.guarch@intel.com>,
	"dev@dpdk.org" <dev@dpdk.org>, nd <nd@arm.com>
Subject: Re: [dpdk-dev] [dpdk-stable] [PATCH v2] test/hash: solve unit test hash compilation error
Date: Mon, 29 Oct 2018 04:54:58 +0000	[thread overview]
Message-ID: <AM6PR08MB367223A0834AA39F1FC6ED9698F30@AM6PR08MB3672.eurprd08.prod.outlook.com> (raw)
In-Reply-To: <23350481.mpM1qx9Ftk@xps>

> 
> 29/10/2018 05:16, Honnappa Nagarahalli:
> > > > >> Subject: Re: [dpdk-stable] [PATCH v2] test/hash: solve unit
> > > > >> test hash compilation error
> > > > >>
> > > > >> +Cc Yipeng
> > > > >>
> > > > >> 18/09/2018 21:22, Dharmik Thakkar:
> > > > >>> Enable print_key_info() function compilation always.
> > > > >>
> > > > >> Please see my first comment: you need to show the compilation
> > > > >> error in this message. Otherwise, we don't know what you are
> > > > >> trying to fix.
> > > > >>
> > > > >>> Fixes: af75078fece36 ("first public release")
> > > > >>> Cc: stable@dpdk.org
> > > > >>>
> > > > >>> Suggested-by: Honnappa Nagarahalli
> > > > >>> <honnappa.nagarahalli@arm.com>
> > > > >>> Signed-off-by: Dharmik Thakkar <dharmik.thakkar@arm.com>
> > > > >>> Reviewed-by: Honnappa Nagarahalli
> > > > >>> <honnappa.nagarahalli@arm.com>
> > > > >>> Reviewed-by: Gavin Hu <gavin.hu@arm.com>
> > > > >>> ---
> > > > >>> v2:
> > > > >>> * Fix checkpatch coding style issue
> > > > >>> * Add "Fixes:" tag
> > > > >>> ---
> > > > >>> test/test/test_hash.c | 24 +++++++++---------------
> > > > >>> 1 file changed, 9 insertions(+), 15 deletions(-)
> > > > >>>
> > > > >>> diff --git a/test/test/test_hash.c b/test/test/test_hash.c
> > > > >>> index
> > > > >>> b3db9fd10547..db6442a2b101 100644
> > > > >>> --- a/test/test/test_hash.c
> > > > >>> +++ b/test/test/test_hash.c
> > > > >>> +#define UNIT_TEST_HASH_VERBOSE	0
> > > > >>> /*
> > > > >>>  * Print out result of unit test hash operation.
> > > > >>>  */
> > > > >>> -#if defined(UNIT_TEST_HASH_VERBOSE) static void
> > > > >>> print_key_info(const char *msg, const struct flow_key *key,
> > > > >>>
> 	int32_t pos)
> > > > >>> {
> > > > >>> -	uint8_t *p = (uint8_t *)key;
> > > > >>> -	unsigned i;
> > > > >>> -
> > > > >>> -	printf("%s key:0x", msg);
> > > > >>> -	for (i = 0; i < sizeof(struct flow_key); i++) {
> > > > >>> -		printf("%02X", p[i]);
> > > > >>> +	if (UNIT_TEST_HASH_VERBOSE) {
> > > > >>
> > > > >> This is very suspicious.
> > > > >> Why keeping this code if it is never called?
> > > > >
> > > > > [Wang, Yipeng] I assume this is for the convenience for debug. E.g.
> > > > > if the unit test failed, developer can set the macro and print
> > > > > more
> > > information, but by default the code is not used.
> > > > >
> > > > > A quick grep I found  the test_timer_racecond and efd unit test
> > > > > has similar macros. But could anyone let me know what is the
> > > > > best coding
> > > practice for such purpose in unit test?
> > > > Thank you bringing up the discussion, Yipeng. I, too, would like
> > > > to know the
> > > best coding practice for such purposes.
> > > >
> > > > One disadvantage of such macros is: That section of the code is
> > > > only
> > > compiled when the macro is defined.
> > > > For eg., previously, ‘print_key_info()’ did not compile without
> > > > defining
> > > UNIT_TEST_HASH_VERBOSE.
> > > > Thus, it’s compilation error(s) are not accounted for always.
> > >
> > > The compilation time options are generally bad.
> > > In this case, we could use the log level as a condition for printing.
> > This is test code. So, printing the extra log under a separate flag like
> UNIT_TEST_HASH_VERBOSE is ok.
> > When I was debugging the code, I enabled it and it did not compile. This
> patch ensures that the code is compiled always. But the extra logs are printed
> only when UNIT_TEST_HASH_VERBOSE is set to non-zero.
> 
> If you keep a compilation time flag, there is a big chance that it becomes
> buggy again.
> 
I believe you meant, buggy during run time. If yes, I agree. This patch removes only compile time bugs.
Looks like using 'rte_log_set_level', one can enable the logs only for hash library. So, it can be used for unit tests as well rather than defining another flag.
However, it will not solve the run time bugs as the log level will be set to not print the info by default. IMO, it does not make sense to print this all the time.

  reply	other threads:[~2018-10-29  4:54 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-27 14:26 [dpdk-dev] [PATCH] " Dharmik Thakkar
2018-08-27 14:41 ` Gavin Hu
2018-09-16  9:59 ` Thomas Monjalon
2018-09-18 19:22 ` [dpdk-dev] [PATCH v2] " Dharmik Thakkar
2018-10-01 20:04   ` Honnappa Nagarahalli
2018-10-26 20:24   ` [dpdk-dev] [dpdk-stable] " Thomas Monjalon
2018-10-26 21:05     ` Wang, Yipeng1
2018-10-26 21:55       ` Dharmik Thakkar
2018-10-26 21:59         ` Thomas Monjalon
2018-10-29  4:16           ` Honnappa Nagarahalli
2018-10-29  4:24             ` Thomas Monjalon
2018-10-29  4:54               ` Honnappa Nagarahalli [this message]
2018-10-26 21:09     ` Dharmik Thakkar
2018-10-26 21:43   ` [dpdk-dev] [PATCH v3] " Dharmik Thakkar
2018-11-06  2:19     ` 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=AM6PR08MB367223A0834AA39F1FC6ED9698F30@AM6PR08MB3672.eurprd08.prod.outlook.com \
    --to=honnappa.nagarahalli@arm.com \
    --cc=Dharmik.Thakkar@arm.com \
    --cc=bruce.richardson@intel.com \
    --cc=dev@dpdk.org \
    --cc=nd@arm.com \
    --cc=pablo.de.lara.guarch@intel.com \
    --cc=thomas@monjalon.net \
    --cc=yipeng1.wang@intel.com \
    /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).