get_maintainer: add KUnit maintainers for KUnit test files
Subsystems (2)
PATCH v2 1/1 get_maintainer: add KUnit maintainers for KUnit test files
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.
---
v2: added missing SOB
scripts/get_maintainer.pl | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
scripts/get_maintainer.pl +14 -0
@@ -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); }
Signature · 1 line
2.53.0
Joe Perches
maintainerQuoted 6 lines · Matteo Croce
```
KUnit test files are scattered across the tree and don't always match the F: patterns in the KERNEL UNIT TESTING FRAMEWORKMAINTAINERSentry. 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.
MAINTAINERS +5 -0
@@ -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 <[email protected]>
Il giorno dom 1 mar 2026 alle ore 03:36 Joe Perches <[email protected]> ha scritto:
Quoted 19 lines · Matteo Croce
Quoted 6 lines
```
KUnit test files are scattered across the tree and don't always match the F: patterns in the KERNEL UNIT TESTING FRAMEWORKMAINTAINERSentry. 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.
MAINTAINERS +0
-0@@ -13956,6 +13956,11 @@ F: rust/kernel/kunit.rs F: rust/macros/kunit.rs
MAINTAINERS F: rust/kernel/kunit.rs · line 13966
Quoted 10 lines
MAINTAINERS +5
-0F: 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 <[email protected]>
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,
Signature · 3 lines
Matteo Croce
perl -e 'for($t=0;;$t++){print chr($t*($t>>8|$t>>13)&255)}' |aplayQuoted 29 lines · Matteo Croce
Il giorno dom 1 mar 2026 alle ore 03:36 Joe Perches <[email protected]> ha scritto:
Quoted 27 lines · Matteo Croce
Quoted 6 lines
```
KUnit test files are scattered across the tree and don't always match the F: patterns in the KERNEL UNIT TESTING FRAMEWORKMAINTAINERSentry. 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.
MAINTAINERS +5
-0@@ -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
Quoted 8 lines
MAINTAINERS F: rust/kernel/kunit.rs · line 13966
Quoted 2 lines
MAINTAINERS +0
-0KERNEL USERMODE HELPER M: Luis Chamberlain <[email protected]>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
Joe Perches
maintainerQuoted 2 lines · Matteo Croce
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 <[email protected]> ha scritto:
Quoted 10 lines · Matteo Croce
Quoted 2 lines
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 "subfile_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)
scripts/get_maintainer.pl +9 -8
@@ -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,
Signature · 3 lines
Matteo Croce
perl -e 'for($t=0;;$t++){print chr($t*($t>>8|$t>>13)&255)}' |aplayJoe Perches
maintainerQuoted 18 lines · Matteo Croce
```
Il giorno dom 1 mar 2026 alle ore 17:42 Joe Perches <[[email protected]](mailto:[email protected])> ha scritto:Quoted 1 line · Matteo Croce
BTW at this point it would be useful to implement the ** glob operator,
Quoted 8 lines
Quoted 1 line
but maybe it's not worth it.
Hi Matteo.
Given you've now touched
get_maintainer, you are welcome to do it. Maybe change "subfile_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:
Quoted 9 lines
$ 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.
scripts/get_maintainer.pl
Quoted 5 lines
I tried to implement it and seems easier than expected, the chunk below does it (validated with:
scripts/get_maintainer.pl--self-test=patterns)scripts/get_maintainer.pl +0
-0
This doesn't apply as there are tab/space problems.
scripts/get_maintainer.pl sub read_maintainer_file {
Quoted 1 line
scripts/get_maintainer.pl +0
-0@@ -375,7 +375,9 @@ sub read_maintainer_file {
[]
scripts/get_maintainer.pl sub file_match_pattern { · line 1054
Quoted 12 lines
scripts/get_maintainer.pl +2
-6@@ -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,
Quoted 7 lines
scripts/get_maintainer.pl +0
-0} } return 0;Regards,
```
Il giorno lun 2 mar 2026 alle ore 03:05 Joe Perches <[email protected]> ha scritto:
Quoted 4 lines
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
Quoted 1 line
cheers,
cheers,
Signature · 3 lines
Matteo Croce
perl -e 'for($t=0;;$t++){print chr($t*($t>>8|$t>>13)&255)}' |aplay