From: Alan T. DeKok Date: Fri, 27 Sep 2019 17:44:23 +0000 (-0400) Subject: document and clarify check for missing xlats X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b034fb6dc9edf11ec9be6adf2f591cb14c724ebe;p=thirdparty%2Ffreeradius-server.git document and clarify check for missing xlats --- diff --git a/doc/all.mk b/doc/all.mk index 8f872135baf..256f20c9e77 100644 --- a/doc/all.mk +++ b/doc/all.mk @@ -122,18 +122,10 @@ clean.doc: # update-check.doc: ${Q}echo "TEST-DOC UPDATE XLAT & RADDB DATABASE" - ${Q}./scripts/build/missing-xlat-doc.sh > ${top_srcdir}/scripts/build/missing-xlat-doc.txt + ${Q}./scripts/build/missing-xlat-doc.sh ${top_srcdir}/scripts/build/missing-xlat-doc.txt ${Q}./scripts/build/missing-raddb-mod-conf.sh > ${top_srcdir}/scripts/build/missing-raddb-mod-conf.txt check.doc: - ${Q}echo "TEST-DOC XLAT CHECK"; \ - check_xlatA="${top_srcdir}/scripts/build/missing-xlat-doc.txt"; \ - check_xlatB="${BUILD_DIR}/tests/missing-xlat-doc.txt"; \ - ./scripts/build/missing-xlat-doc.sh > $${check_xlatB}; \ - if ! diff $${check_xlatA} $${check_xlatB}; then \ - echo "FAILED: XLAT'S MISSING CHECKS: $$check_xlatA != $$check_xlatB"; \ - exit 1; \ - fi ${Q}echo "TEST-DOC RADDB CHECK"; \ check_xlatA="${top_srcdir}/scripts/build/missing-raddb-mod-conf.txt"; \ check_xlatB="${BUILD_DIR}/tests/missing-raddb-mod-conf.txt"; \ diff --git a/scripts/build/missing-xlat-doc.sh b/scripts/build/missing-xlat-doc.sh index d51575ffe81..48a6b0e5a92 100755 --- a/scripts/build/missing-xlat-doc.sh +++ b/scripts/build/missing-xlat-doc.sh @@ -2,14 +2,59 @@ # Script used to verify the xlat funcs vs documentation # main() + +# +# Which API functions are used to register xlats +# xlat_api_funcs="xlat_register|xlat_async_register" src_dir="src/" doc_xlat="doc/" +# +# Where our output goes. +# +OUTPUT=$1 +shift + +# +# Where the correct output is located +# +CORRECT=$(echo $0 | sed 's/\.sh/.txt/') + +rm -f $OUTPUT +mkdir -p $(dirname $OUTPUT) +touch $OUTPUT + +# +# Search through all of the code for references to xlat API +# registration functions. Then, pull out the names of the xlats +# which are registered. +# grep --include "*.c" -E "($xlat_api_funcs).*\"" -r $src_dir 2>&1 | \ perl -lpe 's/^.*"(.*)".*$/\1/' | sort | uniq | \ + +# +# Search through the documentation for references to the names of the +# registered xlat functions. +# while read _d; do + echo "CHECKING for %{$_d: ... }" if ! grep -q "%{$_d:" --include "*.adoc" -r $doc_xlat 2>&1; then - echo "%{$_d:...}" + echo "%{$_d:...}" >> $OUTPUT fi done + +# +# Files should be identical. If not, panic. +# +if ! diff $OUTPUT $CORRECT 2>/dev/null ; then + echo "ERROR: Some registered xlats are not documented." + echo "Please compare the following two files:" + echo " expected - $CORRECT" + echo " found - $OUTPUT" + echo + echo "If the found output is correct, then just copy that file to the expected output". + exit 1 +fi + +exit 0 diff --git a/scripts/build/missing-xlat-doc.txt b/scripts/build/missing-xlat-doc.txt index c29b0551392..e8e76af61c0 100644 --- a/scripts/build/missing-xlat-doc.txt +++ b/scripts/build/missing-xlat-doc.txt @@ -1,3 +1,5 @@ +%{aka_sim_id_method:...} +%{aka_sim_id_type:...} %{attr:...} %{attr_by_num:...} %{attr_by_oid:...}