DPDK patches and discussions
 help / color / mirror / Atom feed
From: David Marchand <david.marchand@redhat.com>
To: dev@dpdk.org
Cc: arybchenko@solarflare.com, l.wojciechow@partner.samsung.com,
	thomas@monjalon.net
Subject: [dpdk-dev] [PATCH v3 1/3] test/log: check levels
Date: Fri,  9 Apr 2021 13:04:51 +0200	[thread overview]
Message-ID: <20210409110453.20078-2-david.marchand@redhat.com> (raw)
In-Reply-To: <20210409110453.20078-1-david.marchand@redhat.com>

Add checks on log levels:
- default values for rte_log_register and RTE_LOG_REGISTER,
- level changes with rte_log_set_level and consorts

Signed-off-by: David Marchand <david.marchand@redhat.com>
---
Changes since v1:
- dropped unrelated change moving logtype1 and logtype2 as global
  static variables,
- dropped __FILE__ + __LINE__ from assert logs, since the macro
  already logs the line,

---
 app/test/test_logs.c | 51 ++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 49 insertions(+), 2 deletions(-)

diff --git a/app/test/test_logs.c b/app/test/test_logs.c
index 425ae03cb9..7abb6eeca2 100644
--- a/app/test/test_logs.c
+++ b/app/test/test_logs.c
@@ -20,6 +20,8 @@
 #define RTE_LOGTYPE_TESTAPP1 RTE_LOGTYPE_USER1
 #define RTE_LOGTYPE_TESTAPP2 RTE_LOGTYPE_USER2
 
+RTE_LOG_REGISTER(logtype3, logtype3, ERR)
+
 /*
  * Logs
  * ====
@@ -64,6 +66,22 @@ test_logs(void)
 	int logtype1, logtype2;
 	int ret;
 
+#define CHECK_LEVELS(exp1, exp2, exp3) do \
+{ \
+	ret = rte_log_get_level(logtype1); \
+	TEST_ASSERT_EQUAL(ret, exp1, \
+		"invalid level for logtype1 got %d, expecting %d\n", \
+		ret, exp1); \
+	ret = rte_log_get_level(logtype2); \
+	TEST_ASSERT_EQUAL(ret, exp2, \
+		"invalid level for logtype2 got %d, expecting %d\n", \
+		ret, exp2); \
+	ret = rte_log_get_level(logtype3); \
+	TEST_ASSERT_EQUAL(ret, exp3, \
+		"invalid level for logtype3 got %d, expecting %d\n", \
+		ret, exp3); \
+} while (0)
+
 	printf("== dynamic log types\n");
 
 	logtype1 = rte_log_register("logtype1");
@@ -77,9 +95,36 @@ test_logs(void)
 		return -1;
 	}
 
+	ret = rte_log_get_level(logtype1);
+	TEST_ASSERT_EQUAL(ret, RTE_LOG_INFO,
+		"invalid default level for logtype1 got %d, expecting %d\n",
+		ret, RTE_LOG_INFO);
+
+	ret = rte_log_get_level(logtype2);
+	TEST_ASSERT_EQUAL(ret, RTE_LOG_INFO,
+		"invalid default level for logtype2 got %d, expecting %d\n",
+		ret, RTE_LOG_INFO);
+
+	ret = rte_log_get_level(logtype3);
+	TEST_ASSERT_EQUAL(ret, RTE_LOG_ERR,
+		"invalid default level for logtype3 got %d, expecting %d\n",
+		ret, RTE_LOG_ERR);
+
+	rte_log_set_level(logtype1, RTE_LOG_ERR);
+	CHECK_LEVELS(RTE_LOG_ERR, RTE_LOG_INFO, RTE_LOG_ERR);
+
+	rte_log_set_level_regexp("type$", RTE_LOG_EMERG);
+	CHECK_LEVELS(RTE_LOG_ERR, RTE_LOG_INFO, RTE_LOG_ERR);
+
+	rte_log_set_level_regexp("type[23]", RTE_LOG_EMERG);
+	CHECK_LEVELS(RTE_LOG_ERR, RTE_LOG_EMERG, RTE_LOG_EMERG);
+
+	rte_log_set_level_pattern("logtype", RTE_LOG_DEBUG);
+	CHECK_LEVELS(RTE_LOG_ERR, RTE_LOG_EMERG, RTE_LOG_EMERG);
+
 	/* set logtype level low to so we can test global level */
-	rte_log_set_level(logtype1, RTE_LOG_DEBUG);
-	rte_log_set_level(logtype2, RTE_LOG_DEBUG);
+	rte_log_set_level_pattern("logtype*", RTE_LOG_DEBUG);
+	CHECK_LEVELS(RTE_LOG_DEBUG, RTE_LOG_DEBUG, RTE_LOG_DEBUG);
 
 	/* log in error level */
 	rte_log_set_global_level(RTE_LOG_ERR);
@@ -103,6 +148,8 @@ test_logs(void)
 	if (ret < 0)
 		return ret;
 
+#undef CHECK_LEVELS
+
 	return 0;
 }
 
-- 
2.23.0


  reply	other threads:[~2021-04-09 11:05 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-26 11:47 [dpdk-dev] [RFC PATCH] log: track log level changes David Marchand
2020-06-26 14:46 ` Andrew Rybchenko
2020-07-09  0:16   ` Lukasz Wojciechowski
2021-03-23  8:19     ` David Marchand
2021-03-23 10:19 ` [dpdk-dev] [PATCH 0/3] Track " David Marchand
2021-03-23 10:19   ` [dpdk-dev] [PATCH 1/3] test/log: check levels David Marchand
2021-03-23 10:19   ` [dpdk-dev] [PATCH 2/3] log: track log level changes David Marchand
2021-03-23 10:19   ` [dpdk-dev] [PATCH 3/3] eal: fix evaluation of log level option David Marchand
2021-03-23 15:54     ` [dpdk-dev] [dpdk-stable] " Thomas Monjalon
2021-03-24  9:45       ` Lukasz Wojciechowski
2021-03-24 10:32 ` [dpdk-dev] [PATCH v2 0/3] Track log level changes David Marchand
2021-03-24 10:32   ` [dpdk-dev] [PATCH v2 1/3] test/log: check levels David Marchand
2021-03-24 10:32   ` [dpdk-dev] [PATCH v2 2/3] log: track log level changes David Marchand
2021-04-08 15:54     ` Thomas Monjalon
2021-04-09  9:08       ` David Marchand
2021-04-09  9:12         ` Thomas Monjalon
2021-03-24 10:32   ` [dpdk-dev] [PATCH v2 3/3] eal: fix evaluation of log level option David Marchand
2021-04-09 11:04 ` [dpdk-dev] [PATCH v3 0/3] Track log level changes David Marchand
2021-04-09 11:04   ` David Marchand [this message]
2021-04-09 11:04   ` [dpdk-dev] [PATCH v3 2/3] log: track " David Marchand
2021-04-09 11:59     ` Thomas Monjalon
2021-04-09 12:14       ` David Marchand
2021-04-09 11:04   ` [dpdk-dev] [PATCH v3 3/3] eal: fix evaluation of log level option David Marchand
2021-04-09 12:21   ` [dpdk-dev] [PATCH v3 0/3] Track log level changes David Marchand

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=20210409110453.20078-2-david.marchand@redhat.com \
    --to=david.marchand@redhat.com \
    --cc=arybchenko@solarflare.com \
    --cc=dev@dpdk.org \
    --cc=l.wojciechow@partner.samsung.com \
    --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).