docs: Kconfig/Makefile: add a check for broken ABI files
authorMauro Carvalho Chehab <mchehab+huawei@kernel.org>
Fri, 30 Oct 2020 07:40:45 +0000 (08:40 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 30 Oct 2020 12:08:07 +0000 (13:08 +0100)
The files under Documentation/ABI should follow the syntax
as defined at Documentation/ABI/README.

Allow checking if they're following the syntax by running
the ABI parser script on COMPILE_TEST.

With that, when there's a problem with a file under
Documentation/ABI, it would produce a warning like:

Warning: file ./Documentation/ABI/testing/sysfs-bus-pci-devices-aer_stats#14:
What '/sys/bus/pci/devices/<dev>/aer_stats/aer_rootport_total_err_cor' doesn't have a description
Warning: file ./Documentation/ABI/testing/sysfs-bus-pci-devices-aer_stats#21:
What '/sys/bus/pci/devices/<dev>/aer_stats/aer_rootport_total_err_fatal' doesn't have a description

Acked-by: Jonathan Corbet <corbet@lwn.net>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Link: https://lore.kernel.org/r/57a38de85cb4b548857207cf1fc1bf1ee08613c9.1604042072.git.mchehab+huawei@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Documentation/Kconfig
Documentation/Makefile
lib/Kconfig.debug
scripts/get_abi.pl

index 66046fa1c341eb551567723d26da937a444f9695..e549a61f4d9660fc3560dcbfba2c89aca24a4bb2 100644 (file)
@@ -10,4 +10,14 @@ config WARN_MISSING_DOCUMENTS
 
           If unsure, select 'N'.
 
+config WARN_ABI_ERRORS
+       bool "Warn if there are errors at ABI files"
+       depends on COMPILE_TEST
+       help
+          The files under Documentation/ABI should follow what's
+          described at Documentation/ABI/README. Yet, as they're manually
+          written, it would be possible that some of those files would
+          have errors that would break them for being parsed by
+          scripts/get_abi.pl. Add a check to verify them.
 
+          If unsure, select 'N'.
index 6b12dd82f71249318637aa8b2de73139d95de4b7..6a59a13d3c53361645b93e10ef42886de7e8ba54 100644 (file)
@@ -10,6 +10,11 @@ ifeq ($(CONFIG_WARN_MISSING_DOCUMENTS),y)
 $(shell $(srctree)/scripts/documentation-file-ref-check --warn)
 endif
 
+# Check for broken ABI files
+ifeq ($(CONFIG_WARN_ABI_ERRORS),y)
+$(shell $(srctree)/scripts/get_abi.pl validate --dir $(srctree)/Documentation/ABI)
+endif
+
 # You can set these variables from the command line.
 SPHINXBUILD   = sphinx-build
 SPHINXOPTS    =
index d7a7bc3b6098287dc7af87b2c94d5304675401f3..c789b39ed527173219adefcca72f0f7778d15aa2 100644 (file)
@@ -2446,4 +2446,6 @@ config HYPERV_TESTING
 
 endmenu # "Kernel Testing and Coverage"
 
+source "Documentation/Kconfig"
+
 endmenu # Kernel hacking
index ff4f9f82ecad4b6279253c3831d7c0dc17dd3bda..f6adf4b38a2bf5720f6f9e122784f868066a2744 100755 (executable)
@@ -50,7 +50,15 @@ my %symbols;
 sub parse_error($$$$) {
        my ($file, $ln, $msg, $data) = @_;
 
-       print STDERR "file $file#$ln: $msg at\n\t$data";
+       $data =~ s/\s+$/\n/;
+
+       print STDERR "Warning: file $file#$ln:\n\t$msg";
+
+       if ($data ne "") {
+               print STDERR ". Line\n\t\t$data";
+       } else {
+           print STDERR "\n";
+       }
 }
 
 #
@@ -110,7 +118,7 @@ sub parse_abi {
 
                        # Invalid, but it is a common mistake
                        if ($new_tag eq "where") {
-                               parse_error($file, $ln, "tag 'Where' is invalid. Should be 'What:' instead", $_);
+                               parse_error($file, $ln, "tag 'Where' is invalid. Should be 'What:' instead", "");
                                $new_tag = "what";
                        }
 
@@ -225,7 +233,7 @@ sub parse_abi {
                }
 
                # Everything else is error
-               parse_error($file, $ln, "Unexpected line:", $_);
+               parse_error($file, $ln, "Unexpected content", $_);
        }
        $data{$nametag}->{description} =~ s/^\n+// if ($data{$nametag}->{description});
        if ($what) {