Skip to content

Commit 7bec8db

Browse files
committed
Check completeness of help output in CI
This commit adds a new script to run post-build that assesses the completeness of --help for all binaries except for goto-cc.
1 parent ec395cd commit 7bec8db

File tree

2 files changed

+111
-0
lines changed

2 files changed

+111
-0
lines changed

.github/workflows/pull-request-checks.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ jobs:
5555
make -C jbmc/unit -j2 CXX="ccache g++" LIBS="$PWD/riss.git/release/lib/libriss-coprocessor.a -lpthread" IPASIR=$PWD/riss.git/riss
5656
- name: Print ccache stats
5757
run: ccache -s
58+
- name: Checking completeness of help output
59+
run: scripts/check_help.sh
5860
- name: Run unit tests
5961
run: |
6062
make -C unit test IPASIR=$PWD/riss.git/riss
@@ -233,6 +235,8 @@ jobs:
233235
run: cd build; ninja -j2
234236
- name: Print ccache stats
235237
run: ccache -s
238+
- name: Checking completeness of help output
239+
run: scripts/check_help.sh build/bin
236240
- name: Check if package building works
237241
run: |
238242
cd build

scripts/check_help.sh

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
# if a command-line argument is provided, use it as a path to built binaries
6+
# (CMake-style build); otherwise assume we use Makefile-based in-tree build
7+
if [ $# -eq 1 ] ; then
8+
bin_dir=$(cd $1 ; pwd)
9+
else
10+
unset bin_dir
11+
fi
12+
echo $bin_dir
13+
14+
# make sure we execute the remainder in the directory containing this script
15+
cd `dirname $0`
16+
17+
missing_options=0
18+
19+
# we don't check goto-cc for now
20+
# we omit crangler for it doesn't take options other than help or a file name
21+
for t in \
22+
../jbmc/src/janalyzer \
23+
../jbmc/src/jbmc \
24+
../jbmc/src/jdiff \
25+
../src/cbmc \
26+
../src/goto-analyzer \
27+
../src/goto-diff \
28+
../src/goto-harness \
29+
../src/goto-instrument \
30+
../src/memory-analyzer \
31+
../src/symtab2gb \
32+
; do
33+
tool_name=$(basename $t)
34+
opt_name=$(echo $tool_name | tr 'a-z-' 'A-Z_')
35+
echo "Extracting the raw list of parameters from $tool_name"
36+
g++ -E -dM -std=c++11 -I../src -I../jbmc/src $t/*_parse_options.cpp -o macros.c
37+
# goto-analyzer partly uses the spelling "analyser" within the code base
38+
echo ${opt_name}_OPTIONS | sed 's/GOTO_ANALYZER/GOTO_ANALYSER/' >> macros.c
39+
rawstring="`gcc -E -P -w macros.c` \"?h(help)\""
40+
rm macros.c
41+
42+
# now the main bit, convert from raw format to a proper list of switches
43+
cleanstring=`(
44+
# extract 2-hyphen switches, such as --foo
45+
# grep for '(foo)' expressions, and then use sed to remove parantheses and
46+
# put '-' at the start (we accept both --X and -X)
47+
(echo $rawstring | grep -o "([^)]*)" | sed "s/^.\(.*\).$/-\1/") ;
48+
# extract 1-hyphen switches, such as -F
49+
# use sed to remove all (foo) expressions, then you're left with switches
50+
# and ':', so grep the colons out and then use sed to include the '-'
51+
(echo $rawstring | sed "s/([^)]*)//g" | grep -o "[a-zA-Z0-9?]" | sed "s/\(.*\)/-\1/")
52+
) | sed 's/" "//g'`
53+
54+
if [ "x$bin_dir" = "x" ] ; then
55+
tool_bin=$t/$tool_name
56+
else
57+
tool_bin=$bin_dir/$tool_name
58+
fi
59+
60+
if [ ! -x $tool_bin ] ; then
61+
echo "$tool_bin is not an executable"
62+
exit 1
63+
fi
64+
$tool_bin --help > help_string
65+
66+
# some options are intentionally undocumented
67+
case $tool_name in
68+
cbmc)
69+
echo "-all-claims -all-properties -claim -show-claims" >> help_string
70+
echo "-document-subgoals" >> help_string
71+
echo "-no-propagation -no-simplify -no-simplify-if" >> help_string
72+
echo "-floatbv -no-unwinding-assertions" >> help_string
73+
echo "-slice-by-trace" >> help_string
74+
;;
75+
goto-analyzer)
76+
echo "-show-intervals -show-non-null" >> help_string
77+
;;
78+
goto-instrument)
79+
echo "-document-claims-html -document-claims-latex -show-claims" >> help_string
80+
echo "-no-simplify" >> help_string
81+
;;
82+
janalyzer)
83+
echo "-show-intervals -show-non-null" >> help_string
84+
;;
85+
jbmc)
86+
echo "-document-subgoals" >> help_string
87+
echo "-no-propagation -no-simplify -no-simplify-if" >> help_string
88+
echo "-no-unwinding-assertions" >> help_string
89+
;;
90+
esac
91+
92+
for opt in $cleanstring ; do
93+
if ! grep -q -- $opt help_string ; then
94+
echo "Option $opt of $tool_name is undocumented"
95+
missing_options=1
96+
fi
97+
done
98+
rm help_string
99+
done
100+
101+
if [ $missing_options -eq 1 ] ; then
102+
echo "Undocumented options found"
103+
exit 1
104+
else
105+
echo "All options are documented"
106+
exit 0
107+
fi

0 commit comments

Comments
 (0)