selftests, bpf: Make docs tests fail more reliably
authorJoe Stringer <joe@cilium.io>
Tue, 8 Jun 2021 01:57:56 +0000 (18:57 -0700)
committerDaniel Borkmann <daniel@iogearbox.net>
Tue, 8 Jun 2021 20:04:35 +0000 (22:04 +0200)
Previously, if rst2man caught errors, then these would be ignored and
the output file would be written anyway. This would allow developers to
introduce regressions in the docs comments in the BPF headers.

Additionally, even if you instruct rst2man to fail out, it will still
write out to the destination target file, so if you ran the tests twice
in a row it would always pass. Use a temporary file for the initial run
to ensure that if rst2man fails out under "--strict" mode, subsequent
runs will not automatically pass.

Tested via ./tools/testing/selftests/bpf/test_doc_build.sh

Signed-off-by: Joe Stringer <joe@cilium.io>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Reviewed-by: Quentin Monnet <quentin@isovalent.com>
Link: https://lore.kernel.org/bpf/20210608015756.340385-1-joe@cilium.io
tools/testing/selftests/bpf/.gitignore
tools/testing/selftests/bpf/Makefile.docs
tools/testing/selftests/bpf/test_doc_build.sh

index a18f57044014ce269ec671da05b16494e547a8e1..eae6fc7d3ed8f35326ddc9fa5acbe702503d820f 100644 (file)
@@ -37,5 +37,6 @@ test_cpp
 /runqslower
 /bench
 *.ko
+*.tmp
 xdpxceiver
 xdp_redirect_multi
index ccf260021e835f3031a7277781a98f2974934c29..eb6a4fea8c794d8354363ac8daa0baac3e3bd060 100644 (file)
@@ -52,7 +52,8 @@ $(OUTPUT)%.$2: $(OUTPUT)%.rst
 ifndef RST2MAN_DEP
        $$(error "rst2man not found, but required to generate man pages")
 endif
-       $$(QUIET_GEN)rst2man $$< > $$@
+       $$(QUIET_GEN)rst2man --exit-status=1 $$< > $$@.tmp
+       $$(QUIET_GEN)mv $$@.tmp $$@
 
 docs-clean-$1:
        $$(call QUIET_CLEAN, eBPF_$1-manpage)
index 7eb940a7b2ebd7b5723cc11d0142b6133f781dfb..ed12111cd2f0986cd48879f8bc51e3e527dc8f40 100755 (executable)
@@ -1,5 +1,6 @@
 #!/bin/bash
 # SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+set -e
 
 # Assume script is located under tools/testing/selftests/bpf/. We want to start
 # build attempts from the top of kernel repository.