|
| 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 | + if [ ! -x $t/$tool_name ] ; then |
| 56 | + echo "$t/$tool_name is not an executable" |
| 57 | + exit 1 |
| 58 | + fi |
| 59 | + $t/$tool_name --help > help_string |
| 60 | + else |
| 61 | + if [ ! -x $bin_dir/$tool_name ] ; then |
| 62 | + echo "$bin_dir/$tool_name is not an executable" |
| 63 | + exit 1 |
| 64 | + fi |
| 65 | + $bin_dir/$tool_name --help > help_string |
| 66 | + fi |
| 67 | + for opt in $cleanstring ; do |
| 68 | + if ! grep -q -- $opt help_string ; then |
| 69 | + echo "Option $opt of $tool_name is undocumented" |
| 70 | + missing_options=1 |
| 71 | + fi |
| 72 | + done |
| 73 | + rm help_string |
| 74 | +done |
| 75 | + |
| 76 | +if [ $missing_options -eq 1 ] ; then |
| 77 | + echo "Undocumented options found" |
| 78 | + exit 1 |
| 79 | +else |
| 80 | + echo "All options are documented" |
| 81 | + exit 0 |
| 82 | +fi |
0 commit comments