checkpatch.pl: Add a check for tests needed for uclasses
authorSimon Glass <sjg@chromium.org>
Fri, 22 May 2020 22:32:37 +0000 (16:32 -0600)
committerTom Rini <trini@konsulko.com>
Thu, 4 Jun 2020 22:10:02 +0000 (18:10 -0400)
A common problem when submitting a new uclass is to forget to add sandbox
tests. Add a warning for this.

Of course tests should always be added for new code, but this one seems to
be missed by nearly every new contributor.

Signed-off-by: Simon Glass <sjg@chromium.org>
scripts/checkpatch.pl

index b8b057ce56e66290fdadea999dc0c2d81bb0491c..1053d29ce94e225c5236ad17acd0dea53c546209 100755 (executable)
@@ -2243,6 +2243,12 @@ sub pos_last_openparen {
 # Checks specific to U-Boot
 sub u_boot_line {
        my ($realfile, $line,  $herecurr) = @_;
 # Checks specific to U-Boot
 sub u_boot_line {
        my ($realfile, $line,  $herecurr) = @_;
+
+       # ask for a test if a new uclass ID is added
+       if ($realfile =~ /uclass-id.h/ && $line =~ /^\+/) {
+               WARN("NEW_UCLASS",
+                    "Possible new uclass - make sure to add a sandbox driver, plus a test in test/dm/<name>.c\n" . $herecurr);
+       }
 }
 
 sub process {
 }
 
 sub process {