scripts/get_maintainer.pl | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
KUnit test files are scattered across the tree and don't always match
the F: patterns in the KERNEL UNIT TESTING FRAMEWORK MAINTAINERS entry.
Add the KUnit maintainers automatically when the file path matches
common KUnit naming conventions: _kunit.c, -kunit.c, _kunit_test.c,
and -kunit-tests.c.
Signed-off-by: Matteo Croce <teknoraver@meta.com>
---
v2: added missing SOB
scripts/get_maintainer.pl | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/scripts/get_maintainer.pl b/scripts/get_maintainer.pl
index 4414194bedcf..c07723af4132 100755
--- a/scripts/get_maintainer.pl
+++ b/scripts/get_maintainer.pl
@@ -966,6 +966,20 @@ sub get_maintainers {
}
}
+ ## Add KUnit maintainers for KUnit test files
+ if ($file =~ m/[_-]kunit[_-]?.*\.c$/) {
+ my $kunit_tvi = find_first_section();
+ while ($kunit_tvi < @typevalue) {
+ my $kunit_start = find_starting_index($kunit_tvi);
+ if ($typevalue[$kunit_start] =~ m/^KERNEL UNIT TESTING FRAMEWORK/) {
+ $hash{$kunit_tvi} = 0;
+ add_categories($kunit_tvi, "");
+ last;
+ }
+ $kunit_tvi = find_ending_index($kunit_tvi) + 1;
+ }
+ }
+
maintainers_in_file($file);
}
--
2.53.0
On Sun, 2026-03-01 at 02:11 +0100, Matteo Croce wrote: > ``` > KUnit test files are scattered across the tree and don't always match > the F: patterns in the KERNEL UNIT TESTING FRAMEWORK MAINTAINERS entry. > Add the KUnit maintainers automatically when the file path matches > common KUnit naming conventions: _kunit.c, -kunit.c, _kunit_test.c, > and -kunit-tests.c. nack. There's no need to modify get_maintainer. Use F: patterns instead. diff --git a/MAINTAINERS b/MAINTAINERS index 96e97d25e1c2..9796e184b9d5 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -13956,6 +13956,11 @@ F: rust/kernel/kunit.rs F: rust/macros/kunit.rs F: scripts/rustdoc_test_* F: tools/testing/kunit/ +F: */*[_-]kunit*.c +F: */*/*[_-]kunit*.c +F: */*/*/*[_-]kunit*.c +F: */*/*/*/*[_-]kunit*.c +F: */*/*/*/*/*[_-]kunit*.c KERNEL USERMODE HELPER M: Luis Chamberlain <mcgrof@kernel.org>
Il giorno dom 1 mar 2026 alle ore 03:36 Joe Perches <joe@perches.com>
ha scritto:
>
> On Sun, 2026-03-01 at 02:11 +0100, Matteo Croce wrote:
> > ```
> > KUnit test files are scattered across the tree and don't always match
> > the F: patterns in the KERNEL UNIT TESTING FRAMEWORK MAINTAINERS entry.
> > Add the KUnit maintainers automatically when the file path matches
> > common KUnit naming conventions: _kunit.c, -kunit.c, _kunit_test.c,
> > and -kunit-tests.c.
>
> nack. There's no need to modify get_maintainer.
>
> Use F: patterns instead.
>
> diff --git a/MAINTAINERS b/MAINTAINERS
> index 96e97d25e1c2..9796e184b9d5 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -13956,6 +13956,11 @@ F: rust/kernel/kunit.rs
> F: rust/macros/kunit.rs
> F: scripts/rustdoc_test_*
> F: tools/testing/kunit/
> +F: */*[_-]kunit*.c
> +F: */*/*[_-]kunit*.c
> +F: */*/*/*[_-]kunit*.c
> +F: */*/*/*/*[_-]kunit*.c
> +F: */*/*/*/*/*[_-]kunit*.c
>
> KERNEL USERMODE HELPER
> M: Luis Chamberlain <mcgrof@kernel.org>
So many rules covering all possible depths?
Sounds good.
BTW at this point it would be useful to implement the ** glob operator,
but maybe it's not worth it.
Regards,
--
Matteo Croce
perl -e 'for($t=0;;$t++){print chr($t*($t>>8|$t>>13)&255)}' |aplay
On Sun, 2026-03-01 at 12:17 +0100, Matteo Croce wrote:
> BTW at this point it would be useful to implement the ** glob operator,
> but maybe it's not worth it.
Hi Matteo.
Given you've now touched get_maintainer, you are welcome to do it.
Maybe change "sub file_match_pattern {".
But I believe this is the first actual use case so I will not.
Il giorno dom 1 mar 2026 alle ore 17:42 Joe Perches <joe@perches.com>
ha scritto:
>
> On Sun, 2026-03-01 at 12:17 +0100, Matteo Croce wrote:
> > BTW at this point it would be useful to implement the ** glob operator,
> > but maybe it's not worth it.
>
> Hi Matteo.
>
> Given you've now touched get_maintainer, you are welcome to do it.
> Maybe change "sub file_match_pattern {".
> But I believe this is the first actual use case so I will not.
Mmm not really the first usage, I see this pattern being already used:
$ grep -F '/*/*/' MAINTAINERS
F: Documentation/devicetree/bindings/*/*/*ma35*
F: drivers/*/*/*ma35*
F: Documentation/devicetree/bindings/*/*/*npcm*
F: drivers/*/*/*npcm*
F: arch/*/*/*/*ftrace*
F: arch/*/*/*ftrace*
F: drivers/net/ethernet/*/*/*/*/*xdp*
F: drivers/net/ethernet/*/*/*xdp*
I tried to implement it and seems easier than expected, the chunk below does it
(validated with: scripts/get_maintainer.pl --self-test=patterns)
--- a/scripts/get_maintainer.pl
+++ b/scripts/get_maintainer.pl
@@ -375,7 +375,9 @@ sub read_maintainer_file {
##Filename pattern matching
if ($type eq "F" || $type eq "X") {
$value =~ s@\.@\\\.@g; ##Convert . to \.
- $value =~ s/\*/\.\*/g; ##Convert * to .*
+ $value =~ s/\*\*/\x00/g; ##Convert ** to placeholder
+ $value =~ s/\*/[^\/]*/g; ##Convert * to [^/]*
+ $value =~ s/\x00/.*/g; ##Convert placeholder to .*
$value =~ s/\?/\./g; ##Convert ? to .
##if pattern is a directory and it lacks a trailing slash, add one
if ((-d $value)) {
@@ -919,6 +921,8 @@ sub get_maintainers {
if ($type eq 'F') {
if (file_match_pattern($file, $value)) {
my $value_pd = ($value =~ tr@/@@);
+ ## Discount slashes inside [^/] character classes
+ $value_pd -= (() = $value =~ /\[\^\/\]/g);
my $file_pd = ($file =~ tr@/@@);
$value_pd++ if (substr($value,-1,1) ne "/");
$value_pd = -1 if ($value =~ /^\.\*/);
@@ -955,7 +959,8 @@ sub get_maintainers {
$line =~ s/([^\\])\.([^\*])/$1\?$2/g;
$line =~ s/([^\\])\.$/$1\?/g; ##Convert . back to ?
$line =~ s/\\\./\./g; ##Convert \. to .
- $line =~ s/\.\*/\*/g; ##Convert .* to *
+ $line =~ s/\[\^\/\]\*/\*/g; ##Convert [^/]* to *
+ $line =~ s/\.\*/\*\*/g; ##Convert .* to **
}
my $count = $line =~ s/^([A-Z]):/$1:\t/g;
if ($letters eq "" || (!$count || $letters =~ /$1/i)) {
@@ -1045,12 +1050,8 @@ sub file_match_pattern {
return 1;
}
} else {
- if ($file =~ m@^$pattern@) {
- my $s1 = ($file =~ tr@/@@);
- my $s2 = ($pattern =~ tr@/@@);
- if ($s1 == $s2) {
- return 1;
- }
+ if ($file =~ m@^$pattern$@) {
+ return 1;
}
}
return 0;
Regards,
--
Matteo Croce
perl -e 'for($t=0;;$t++){print chr($t*($t>>8|$t>>13)&255)}' |aplay
On Mon, 2026-03-02 at 01:50 +0100, Matteo Croce wrote:
> ```
> Il giorno dom 1 mar 2026 alle ore 17:42 Joe Perches <[joe@perches.com](mailto:joe@perches.com)>
> ha scritto:
>
> > On Sun, 2026-03-01 at 12:17 +0100, Matteo Croce wrote:
> BTW at this point it would be useful to implement the ** glob operator,
> > > but maybe it's not worth it.
>
> >
> > Hi Matteo.
> >
> > Given you've now touched get_maintainer, you are welcome to do it.
> > Maybe change "sub file_match_pattern {".
> > But I believe this is the first actual use case so I will not.
>
>
> Mmm not really the first usage, I see this pattern being already used:
>
> $ grep -F '/*/*/' MAINTAINERS
> F: Documentation/devicetree/bindings/*/*/*ma35*
> F: drivers/*/*/*ma35*
> F: Documentation/devicetree/bindings/*/*/*npcm*
> F: drivers/*/*/*npcm*
> F: arch/*/*/*/*ftrace*
> F: arch/*/*/*ftrace*
> F: drivers/net/ethernet/*/*/*/*/*xdp*
> F: drivers/net/ethernet/*/*/*xdp*
Nope.
Those are specific directory depth matches.
Your use case is _all_ directory depth matches.
> I tried to implement it and seems easier than expected, the chunk below does it
> (validated with: scripts/get_maintainer.pl --self-test=patterns)
>
> --- a/scripts/get_maintainer.pl
> +++ b/scripts/get_maintainer.pl
This doesn't apply as there are tab/space problems.
> @@ -375,7 +375,9 @@ sub read_maintainer_file {
[]
> @@ -1045,12 +1050,8 @@ sub file_match_pattern {
> return 1;
> }
> } else {
> - if ($file =~ m@^$pattern@) {
> - my $s1 = ($file =~ tr@/@@);
> - my $s2 = ($pattern =~ tr@/@@);
> - if ($s1 == $s2) {
> - return 1;
> - }
> + if ($file =~ m@^$pattern$@) {
> + return 1;
and I think the count of / characters matters
but if you send a patch that applies, I'll verify.
cheers,
> }
> }
> return 0;
>
> Regards,
>
> ```
Il giorno lun 2 mar 2026 alle ore 03:05 Joe Perches <joe@perches.com>
ha scritto:
>
> and I think the count of / characters matters
> but if you send a patch that applies, I'll verify.
>
I see that it's used in file_match_pattern.
Anyway I made another simpler patch, I'll send in another standalone
patch, so it won't be corrupted
> cheers,
cheers,
--
Matteo Croce
perl -e 'for($t=0;;$t++){print chr($t*($t>>8|$t>>13)&255)}' |aplay
On 2026-03-01 12:17:17+0100, Matteo Croce wrote: > Il giorno dom 1 mar 2026 alle ore 03:36 Joe Perches <joe@perches.com> > ha scritto: > > > > On Sun, 2026-03-01 at 02:11 +0100, Matteo Croce wrote: > > > ``` > > > KUnit test files are scattered across the tree and don't always match > > > the F: patterns in the KERNEL UNIT TESTING FRAMEWORK MAINTAINERS entry. > > > Add the KUnit maintainers automatically when the file path matches > > > common KUnit naming conventions: _kunit.c, -kunit.c, _kunit_test.c, > > > and -kunit-tests.c. > > > > nack. There's no need to modify get_maintainer. > > > > Use F: patterns instead. > > > > diff --git a/MAINTAINERS b/MAINTAINERS > > index 96e97d25e1c2..9796e184b9d5 100644 > > --- a/MAINTAINERS > > +++ b/MAINTAINERS > > @@ -13956,6 +13956,11 @@ F: rust/kernel/kunit.rs > > F: rust/macros/kunit.rs > > F: scripts/rustdoc_test_* > > F: tools/testing/kunit/ > > +F: */*[_-]kunit*.c > > +F: */*/*[_-]kunit*.c > > +F: */*/*/*[_-]kunit*.c > > +F: */*/*/*/*[_-]kunit*.c > > +F: */*/*/*/*/*[_-]kunit*.c > > > > KERNEL USERMODE HELPER > > M: Luis Chamberlain <mcgrof@kernel.org> > > So many rules covering all possible depths? > Sounds good. > > BTW at this point it would be useful to implement the ** glob operator, > but maybe it's not worth it. K: or N: patterns would be cleaner than both proposals here. Thomas
© 2016 - 2026 Red Hat, Inc.