Skip to content

Commit 4e7194f

Browse files
committed
Add man page groff warning test
The manual page sources were not covered by make check, so groff syntax regressions could land unnoticed. Two existing pages already emitted warnings: one used an undefined lowercase .b macro and another used a font escape that groff could not select through man. The fix adds a doc/check-manpages.sh Automake test that renders every local man page source with man --warnings under a stable UTF-8 locale and treats any formatter stderr as a failure. The existing warnings were fixed by using the proper .B macro and normal man-page bold formatting for the command example. The new test is run from the doc make check target and also covers the optional fapolicyd-perf-test.8 source by including it in the distributed doc files.
1 parent 7aa37d4 commit 4e7194f

4 files changed

Lines changed: 75 additions & 5 deletions

File tree

doc/Makefile.am

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,11 @@
2020
# Steve Grubb <sgrubb@redhat.com>
2121
#
2222

23-
EXTRA_DIST = $(man_MANS)
23+
EXTRA_DIST = $(man_MANS) fapolicyd-perf-test.8 check-manpages.sh
24+
25+
TEST_EXTENSIONS = .sh
26+
SH_LOG_COMPILER = $(SHELL)
27+
TESTS = check-manpages.sh
2428

2529
man_MANS = \
2630
fapolicyd.8 \

doc/check-manpages.sh

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
#!/bin/sh
2+
#
3+
# Check every manual page source in this directory with groff warnings enabled.
4+
# man exits successfully for formatter warnings, so stderr is treated as a
5+
# test failure.
6+
7+
set -u
8+
9+
: "${MAN:=man}"
10+
: "${srcdir:=.}"
11+
12+
if test "$srcdir" = "."; then
13+
case "$0" in
14+
*/*)
15+
srcdir=${0%/*}
16+
;;
17+
esac
18+
fi
19+
20+
if ! command -v "$MAN" >/dev/null 2>&1; then
21+
echo "SKIP: man command not found"
22+
exit 77
23+
fi
24+
25+
if command -v locale >/dev/null 2>&1; then
26+
if ! LC_ALL=C.UTF-8 locale charmap >/dev/null 2>&1; then
27+
echo "SKIP: C.UTF-8 locale not available"
28+
exit 77
29+
fi
30+
fi
31+
32+
if ! "$MAN" --help 2>&1 | grep -- "--warnings" >/dev/null 2>&1; then
33+
echo "SKIP: man command does not support --warnings"
34+
exit 77
35+
fi
36+
37+
failed=0
38+
found=0
39+
40+
for page in "$srcdir"/*.[0-9]; do
41+
test -e "$page" || continue
42+
found=1
43+
44+
output=$(
45+
LC_ALL=C.UTF-8 MANROFFSEQ='' MANWIDTH=80 \
46+
"$MAN" --warnings -E UTF-8 -l -Tutf8 -Z "$page" \
47+
2>&1 >/dev/null
48+
)
49+
status=$?
50+
51+
if test $status -ne 0 || test -n "$output"; then
52+
failed=1
53+
echo "$page:"
54+
if test -n "$output"; then
55+
printf '%s\n' "$output"
56+
fi
57+
if test $status -ne 0; then
58+
echo "man exited with status $status"
59+
fi
60+
fi
61+
done
62+
63+
if test $found -eq 0; then
64+
echo "No manual pages found"
65+
exit 1
66+
fi
67+
68+
exit $failed

doc/fapolicyd.conf.5

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -225,9 +225,7 @@ Ensure each mount is truly \fIdata\-only\fR and is mounted with \fBnoexec\fR.
225225
.IP \[bu]
226226
Run the advisory check:
227227
.nf
228-
\f[C]
229-
fapolicyd-cli --check-ignore_mounts[=MOUNT]
230-
\f[R]
228+
.B fapolicyd-cli \-\-check-ignore_mounts[=MOUNT]
231229
.fi
232230
to verify the mount exists, confirm \fBnoexec\fR, and scan for executable
233231
regular files, ELF/shared objects, archives/JARs/ZIPs, bytecode caches,

doc/fapolicyd.rules.5

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ Set is a named group of values of the same type. Fapolicyd internally distinguis
157157
.SS SETS EXAMPLES
158158
.nf
159159
.B # definition
160-
.b # string set
160+
.B # string set
161161
.B %python=/usr/bin/python2.7,/usr/bin/python3.6
162162
.B allow exe=%python : all trust=1
163163
.B #

0 commit comments

Comments
 (0)