diff mbox series

devtools: check logtype format

Message ID 20210319203737.13526-1-david.marchand@redhat.com (mailing list archive)
State Rejected, archived
Delegated to: David Marchand
Headers show
Series devtools: check logtype format | expand

Checks

Context Check Description
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-testing success Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-abi-testing success Testing PASS
ci/github-robot success github build: passed
ci/travis-robot success travis build: passed
ci/intel-Testing success Testing PASS
ci/Intel-compilation success Compilation OK
ci/checkpatch success coding style OK

Commit Message

David Marchand March 19, 2021, 8:37 p.m. UTC
Enforce that added logtypes follow the convention:
- for lib/librte_XXX: lib.XXX and lib.XXX.*
- for drivers/class/XXX: pmd.class.XXX and pmd.class.XXX.*

Signed-off-by: David Marchand <david.marchand@redhat.com>
---
 devtools/checkpatches.sh | 44 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 44 insertions(+)

Comments

Thomas Monjalon March 20, 2021, 7:26 a.m. UTC | #1
19/03/2021 21:37, David Marchand:
> Enforce that added logtypes follow the convention:
> - for lib/librte_XXX: lib.XXX and lib.XXX.*
> - for drivers/class/XXX: pmd.class.XXX and pmd.class.XXX.*

What about common drivers which skip the "common" part: pmd.XXX?
Andrew Rybchenko March 21, 2021, 8:33 p.m. UTC | #2
On 3/20/21 10:26 AM, Thomas Monjalon wrote:
> 19/03/2021 21:37, David Marchand:
>> Enforce that added logtypes follow the convention:
>> - for lib/librte_XXX: lib.XXX and lib.XXX.*
>> - for drivers/class/XXX: pmd.class.XXX and pmd.class.XXX.*
> 
> What about common drivers which skip the "common" part: pmd.XXX?

I'd vote to keep it.
David Marchand May 11, 2021, 9:46 a.m. UTC | #3
On Fri, Mar 19, 2021 at 9:38 PM David Marchand
<david.marchand@redhat.com> wrote:
>
> Enforce that added logtypes follow the convention:
> - for lib/librte_XXX: lib.XXX and lib.XXX.*
> - for drivers/class/XXX: pmd.class.XXX and pmd.class.XXX.*

As discussed offlist, I dropped this idea.

Instead we can use helpers that provide standardized logtype names.
For interested parties, the thread for this approach is at:
https://inbox.dpdk.org/dev/20210409124334.24479-1-david.marchand@redhat.com/
diff mbox series

Patch

diff --git a/devtools/checkpatches.sh b/devtools/checkpatches.sh
index 78a408ef98..11ad4bee8d 100755
--- a/devtools/checkpatches.sh
+++ b/devtools/checkpatches.sh
@@ -199,6 +199,42 @@  check_internal_tags() { # <patch>
 	return $res
 }
 
+check_logtypes() { # <patch>
+	res=0
+
+	cat "$1" |awk '
+	BEGIN {
+		pattern = "";
+		ret = 0;
+	}
+	/^+++ b\// {
+		count = split($2, path, "/")
+		if (count >= 4 && path[2] == "lib") {
+			pattern = "lib\\." gensub(/librte_(.*)/, "\\1", "", path[3])
+		} else if (count >= 5 && path[2] == "drivers") {
+			pattern = "pmd\\." path[3] "\\." path[4]
+		} else {
+			pattern = "";
+		}
+	}
+	/^+.*RTE_LOG_REGISTER\([^,]+,[^,]+,/ {
+		if (pattern == "") {
+			next;
+		}
+		if (!($0 ~ "RTE_LOG_REGISTER\\([^,]+, " pattern "(|\\.[^,]+),")) {
+			print $0
+			print "Added logtype does not comply with pattern: " \
+				gensub(/\\/, "", "g", pattern)
+			ret = 1;
+		}
+	}
+	END {
+		exit ret;
+	}' || res=1
+
+	return $res
+}
+
 number=0
 range='origin/main..'
 quiet=false
@@ -290,6 +326,14 @@  check () { # <patch> <commit> <title>
 		ret=1
 	fi
 
+	! $verbose || printf '\nChecking RTE_LOG_REGISTER:\n'
+	report=$(check_logtypes "$tmpinput")
+	if [ $? -ne 0 ] ; then
+		$headline_printed || print_headline "$3"
+		printf '%s\n' "$report"
+		ret=1
+	fi
+
 	if [ "$tmpinput" != "$1" ]; then
 		rm -f "$tmpinput"
 		trap - INT