From: Bart Van Assche Date: Sun, 23 Oct 2011 12:14:51 +0000 (+0000) Subject: Check Makefile.am consistency before running regression tests. Closes #283813. X-Git-Tag: svn/VALGRIND_3_7_0~25 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b89d16e2ba6cc0c03c789f2a4eb6d104ac1ce53c;p=thirdparty%2Fvalgrind.git Check Makefile.am consistency before running regression tests. Closes #283813. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12214 --- diff --git a/Makefile.am b/Makefile.am index 5966e61234..fadc32acc7 100644 --- a/Makefile.am +++ b/Makefile.am @@ -76,6 +76,7 @@ default.supp: $(DEFAULT_SUPP_FILES) ## Preprend @PERL@ because tests/vg_regtest isn't executable regtest: check + -tests/check_makefile_consistency gdbserver_tests $(TEST_TOOLS) $(TEST_EXP_TOOLS) gdbserver_tests/make_local_links $(GDB) @PERL@ tests/vg_regtest gdbserver_tests $(TEST_TOOLS) $(TEST_EXP_TOOLS) nonexp-regtest: check diff --git a/tests/check_makefile_consistency b/tests/check_makefile_consistency new file mode 100755 index 0000000000..3e0ae4cbc6 --- /dev/null +++ b/tests/check_makefile_consistency @@ -0,0 +1,125 @@ +#!/bin/sh + +# Verify consistency of the regression test files present in a directory with +# the contents of the EXTRA_DIST Makefile.am variable. + +# Expand variables in a Makefile ($(NAME) syntax), evaluate $(add_suffix ...) +# and ignore $(noinst_SCRIPTS). +parse_makefile() { + cat "$1" | + awk '/\\$/ { + n = $0 + sub("\\\\$", "", n) + if (line != "") + line = line " " n + else + line = n + } + /[^\\]$/ { + if (line != "") { + print line " " $0 + line = "" + } else { + print + } + }' | + awk '{ + if (match($0, "^ *[A-Za-z_]* *= *.*$")) { + varname = $0 + gsub("^ *", "", varname) + gsub(" *=.*", "", varname) + value = $0 + gsub("^ *[A-Za-z_]* *= *", "", value) + var[varname] = value + } + for (v in var) + gsub("\\$\\( *" v " *\\)", var[v]) + while ((pos = match($0, "\\$\\( *addsuffix *[^,)]*, *[^)]*\\)")) >= 1) { + suffix = substr($0, pos) + gsub("^\\$\\( *addsuffix *", "", suffix) + gsub(",.*", "", suffix) + names = substr($0, pos) + gsub("^\\$\\( *addsuffix *[^,)]*, *", "", names) + gsub("\\).*", "", names) + split(names, name) + name_and_suff="" + for (n in name) + name_and_suff = name_and_suff " " name[n] suffix + sub("\\$\\( *addsuffix *[^,)]*, *[^)]*\\)", name_and_suff) + } + print + }' | + sed 's/\$(noinst_SCRIPTS)//' +} + +if [ $# = 0 ]; then + echo "Error: tool name argument is missing." + exit 1 +fi + +rc=0 + +# For all directories specified as an argument, find the Makefile.am files +# beneath and check the consistency of the files *.vgtest and *.exp* files +# in that directory with the filenames specified in EXTRA_DIST in Makefile.am. +for t in "$@" +do + find $t -name Makefile.am | + while read m; do + d="$(dirname "$m")" + ( + rc=0 + if cd $d; then + parsed_makefile="$(parse_makefile Makefile.am)" + for f in $(ls -d *.exp* *.gdb *.vgtest 2>/dev/null) + do + if [ "$f" = "*.exp*" -o "$f" = "*.gdb" -o "$f" = "*.vgtest" ]; then + continue + fi + if ! echo "${parsed_makefile}" 2>/dev/null | grep '^ *EXTRA_DIST *=' | + grep -qw "$f" + then + echo "$m:1: error: $f is missing in EXTRA_DIST" + rc=1 + fi + done + + for f in $(ls -d filter* 2>/dev/null) + do + if ! echo "${parsed_makefile}" 2>/dev/null | grep '^ *dist_noinst_SCRIPTS *=' | + grep -qw "$f" + then + echo "$m:1: error: $f is missing in dist_noinst_SCRIPTS" + rc=1 + fi + done + + for f in $(parse_makefile Makefile.am | sed -n 's/^ *EXTRA_DIST *=//p') + do + if [ ! -e "$f" ]; then + echo "$m:1: error: $f is in EXTRA_DIST but doesn't exist" + rc=1 + fi + done + + for f in $(parse_makefile Makefile.am | sed -n 's/^ *dist_noinst_SCRIPTS *=//p') + do + if [ ! -e "$f" ]; then + echo "$m:1: error: $f is in dist_noinst_SCRIPTS but doesn't exist" + rc=1 + fi + done + fi + [ $rc = 0 ] + ) + if [ $? != 0 ]; then + rc=1 + fi + [ $rc = 0 ] + done + if [ $? != 0 ]; then + rc=1 + fi + [ $rc = 0 ] +done +exit $?