From a0fdc9bf8ff41a49ac384d90f2c33aef62db3abf Mon Sep 17 00:00:00 2001 From: Francesco Chemolli Date: Fri, 20 Aug 2010 18:15:46 +0200 Subject: [PATCH] Compilation speedup: optimize test-suite/testheaders.sh --- compat/Makefile.am | 3 +-- lib/Makefile.am | 2 +- src/Makefile.am | 7 +----- src/auth/Makefile.am | 6 +---- src/fs/Makefile.am | 3 +-- src/repl/Makefile.am | 2 +- test-suite/testheaders.sh | 51 ++++++++++++++++----------------------- 7 files changed, 27 insertions(+), 47 deletions(-) diff --git a/compat/Makefile.am b/compat/Makefile.am index 1761ef3934..55493e2369 100644 --- a/compat/Makefile.am +++ b/compat/Makefile.am @@ -72,8 +72,7 @@ TESTS += testHeaders ## Special Universal .h dependency test script ## aborts if error encountered testHeaders: $(srcdir)/*.h $(srcdir)/os/*.h - $(SHELL) $(top_srcdir)/test-suite/testheaders.sh "$(CXXCOMPILE)" "$(srcdir)" || exit 1 - $(SHELL) $(top_srcdir)/test-suite/testheaders.sh "$(CXXCOMPILE)" "$(srcdir)/os" || exit 1 + $(SHELL) $(top_srcdir)/test-suite/testheaders.sh "$(CXXCOMPILE)" $^ || exit 1 CLEANFILES += testHeaders diff --git a/lib/Makefile.am b/lib/Makefile.am index a1fcf15c37..8427107fb4 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -108,7 +108,7 @@ tests_testAll_LDFLAGS = $(LIBADD_DL) ## Special Universal .h dependency test script ## aborts if error encountered testHeaders: $(top_srcdir)/include/*.h - $(SHELL) $(top_srcdir)/test-suite/testheaders.sh "$(CXXCOMPILE)" "$(top_srcdir)/include" || exit 1 + $(SHELL) $(top_srcdir)/test-suite/testheaders.sh "$(CXXCOMPILE)" $^ || exit 1 TESTS += testHeaders CLEANFILES += testHeaders diff --git a/src/Makefile.am b/src/Makefile.am index 1e6b57e126..97c189222e 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -2281,12 +2281,7 @@ TESTS += testHeaders ## Special Universal .h dependency test script ## aborts if error encountered testHeaders: $(srcdir)/*.h $(srcdir)/DiskIO/*.h $(srcdir)/DiskIO/*/*.h - $(SHELL) $(top_srcdir)/test-suite/testheaders.sh "$(CXXCOMPILE)" "$(srcdir)" || exit 1 - $(SHELL) $(top_srcdir)/test-suite/testheaders.sh "$(CXXCOMPILE)" "$(srcdir)/DiskIO" || exit 1 - $(SHELL) $(top_srcdir)/test-suite/testheaders.sh "$(CXXCOMPILE)" "$(srcdir)/DiskIO/AIO" || exit 1 - $(SHELL) $(top_srcdir)/test-suite/testheaders.sh "$(CXXCOMPILE)" "$(srcdir)/DiskIO/Blocking" || exit 1 - $(SHELL) $(top_srcdir)/test-suite/testheaders.sh "$(CXXCOMPILE)" "$(srcdir)/DiskIO/DiskDaemon" || exit 1 - $(SHELL) $(top_srcdir)/test-suite/testheaders.sh "$(CXXCOMPILE)" "$(srcdir)/DiskIO/DiskThreads" || exit 1 + $(SHELL) $(top_srcdir)/test-suite/testheaders.sh "$(CXXCOMPILE)" $^ || exit 1 ## src/repl/ has no .h files and its own makefile. CLEANFILES += testHeaders diff --git a/src/auth/Makefile.am b/src/auth/Makefile.am index f87a492990..f6faae982e 100644 --- a/src/auth/Makefile.am +++ b/src/auth/Makefile.am @@ -81,11 +81,7 @@ TESTS += testHeaders ## Special Universal .h dependency test script ## aborts if error encountered testHeaders: $(top_srcdir)/src/auth/*.h $(top_srcdir)/src/auth/basic/*.h $(top_srcdir)/src/auth/digest/*.h $(top_srcdir)/src/auth/ntlm/*.h $(top_srcdir)/src/auth/negotiate/*.h - $(SHELL) $(top_srcdir)/test-suite/testheaders.sh "$(CXXCOMPILE)" "$(top_srcdir)/src/auth/" || exit 1 - $(SHELL) $(top_srcdir)/test-suite/testheaders.sh "$(CXXCOMPILE)" "$(top_srcdir)/src/auth/basic" || exit 1 - $(SHELL) $(top_srcdir)/test-suite/testheaders.sh "$(CXXCOMPILE)" "$(top_srcdir)/src/auth/digest" || exit 1 - $(SHELL) $(top_srcdir)/test-suite/testheaders.sh "$(CXXCOMPILE)" "$(top_srcdir)/src/auth/ntlm" || exit 1 - $(SHELL) $(top_srcdir)/test-suite/testheaders.sh "$(CXXCOMPILE)" "$(top_srcdir)/src/auth/negotiate" || exit 1 + $(SHELL) $(top_srcdir)/test-suite/testheaders.sh "$(CXXCOMPILE)" $^ || exit 1 CLEANFILES += testHeaders .PHONY: testHeaders diff --git a/src/fs/Makefile.am b/src/fs/Makefile.am index 51171216a2..e7c7a0dad8 100644 --- a/src/fs/Makefile.am +++ b/src/fs/Makefile.am @@ -51,8 +51,7 @@ TESTS += testHeaders ## Special Universal .h dependency test script ## aborts if error encountered testHeaders: $(srcdir)/ufs/*.h $(srcdir)/coss/*.h - $(SHELL) $(top_srcdir)/test-suite/testheaders.sh "$(CXXCOMPILE)" "$(srcdir)/ufs" || exit 1 - $(SHELL) $(top_srcdir)/test-suite/testheaders.sh "$(CXXCOMPILE)" "$(srcdir)/coss" || exit 1 + $(SHELL) $(top_srcdir)/test-suite/testheaders.sh "$(CXXCOMPILE)" $^ || exit 1 ## diskd/ has no .h files ## aufs/ has no .h files ## ./ has no .h files diff --git a/src/repl/Makefile.am b/src/repl/Makefile.am index 65bb5a2667..c246c564d2 100644 --- a/src/repl/Makefile.am +++ b/src/repl/Makefile.am @@ -25,7 +25,7 @@ TESTS += testHeaders ## Special Universal .h dependency test script ## aborts if error encountered testHeaders: $(srcdir)/heap/*.h - $(SHELL) $(top_srcdir)/test-suite/testheaders.sh "$(CXXCOMPILE)" "$(srcdir)/heap" || exit 1 + $(SHELL) $(top_srcdir)/test-suite/testheaders.sh "$(CXXCOMPILE)" $^ || exit 1 ## ./ has no .h files. ## ./lru/ has no .h files. diff --git a/test-suite/testheaders.sh b/test-suite/testheaders.sh index 48f358fd02..ccc7bb208d 100755 --- a/test-suite/testheaders.sh +++ b/test-suite/testheaders.sh @@ -9,39 +9,30 @@ # This script should be run from the makefile with the directory path and ccflags # cc="${1}" - -if test "${2}" = ""; then - dir="." -else - dir="${2}" -fi +shift exitCode=0 -for f in `cd ${dir} && ls -1 *.h 2>/dev/null`; do - echo -n "Testing ${dir}/${f} ..." - hdr=`echo "${f}" | sed s/.h//` - if [ ! -e ./testHeaderDeps_${hdr}.o -o ${dir}/${f} -nt ./testHeaderDeps_${hdr}.o ]; then - ( echo "/* This file is AUTOMATICALLY GENERATED. DO NOT ALTER IT */" - echo "#include \"${dir}/${f}\" " - echo "int main( int argc, char* argv[] ) { return 0; } " - ) >./testHeaderDeps_${hdr}.cc - - # run compile test on the new file. - # DEBUG: echo "TRY: ${cc} -o testHeaderDeps.o ./testHeaderDeps_${hdr}.cc" - ${cc} -c -o testHeaderDeps_${hdr}.o ./testHeaderDeps_${hdr}.cc - rm ./testHeaderDeps_${hdr}.cc - fi - if [ ! -f testHeaderDeps_${hdr}.o ]; then - rm testHeaders - exitCode=1 - else - echo "OK." - # unit-tests require an app to run. - # our most-recent object suits this purpose. - # let's link or some tests will fail - ${cc} ./testHeaderDeps_${hdr}.o -o ./testHeaders - fi +for f in $@; do + echo -n "Testing ${f} ..." + t="testhdr_`basename ${f}`" + if [ ! -f "$t.o" -o $f -nt "$t.o" ]; then + echo >$t.cc <