Here's something to try. --8<--------------------------cut here-------------------------->8--
commit f9a7e150e875a23646c4d1b07697e37059c8a088 Author: Ben Pfaff <[email protected]> Date: Wed Mar 23 21:41:00 2016 -0700 tests: Add support for generic wrapper. With this change, "make check RUNNER='...'" runs all of the binaries that PSPP builds under the supervision of $RUNNER, so that, for example, the "pspp" binary is run as "$RUNNER pspp". This is useful for wrapping programs with, for example, "wine", for cross-compiling. diff --git a/tests/automake.mk b/tests/automake.mk index 9284b93..dbbb3d3 100644 --- a/tests/automake.mk +++ b/tests/automake.mk @@ -406,7 +406,8 @@ DISTCLEANFILES += tests/atconfig tests/atlocal $(TESTSUITE) AUTOTEST_PATH = tests/data:tests/language/lexer:tests/libpspp:tests/output:src/ui/terminal:utilities $(srcdir)/tests/testsuite.at: tests/testsuite.in tests/automake.mk - $(AM_V_GEN)cp $< $@ + $(AM_V_GEN)printf '\043 Generated automatically -- do not modify! -*- buffer-read-only: t -*-\n' > $@ + $(AM_V_at)cat $< >> $@ $(AM_V_at)for t in $(TESTSUITE_AT); do \ echo "m4_include([$$t])" >> $@ ;\ done @@ -414,7 +415,7 @@ EXTRA_DIST += tests/testsuite.at CHECK_LOCAL += tests_check tests_check: tests/atconfig tests/atlocal $(TESTSUITE) $(check_PROGRAMS) - XTERM_LOCALE='' $(SHELL) '$(TESTSUITE)' -C tests AUTOTEST_PATH=$(AUTOTEST_PATH) $(TESTSUITEFLAGS) + XTERM_LOCALE='' $(SHELL) '$(TESTSUITE)' -C tests AUTOTEST_PATH=$(AUTOTEST_PATH) RUNNER='$(RUNNER)' $(TESTSUITEFLAGS) CLEAN_LOCAL += tests_clean tests_clean: @@ -437,51 +438,9 @@ $(srcdir)/package.m4: $(top_srcdir)/configure.ac echo 'm4_define([AT_PACKAGE_BUGREPORT], [$(PACKAGE_BUGREPORT)])' && \ echo 'm4_define([AT_PACKAGE_URL], [$(PACKAGE_URL)])'; \ } >'$(srcdir)/package.m4' - -# valgrind support for Autotest testsuite - -valgrind_wrappers = \ - tests/valgrind/datasheet-test \ - tests/valgrind/command-name-test \ - tests/valgrind/scan-test \ - tests/valgrind/segment-test \ - tests/valgrind/abt-test \ - tests/valgrind/bt-test \ - tests/valgrind/encoding-guesser-test \ - tests/valgrind/heap-test \ - tests/valgrind/hmap-test \ - tests/valgrind/hmapx-test \ - tests/valgrind/i18n-test \ - tests/valgrind/ll-test \ - tests/valgrind/llx-test \ - tests/valgrind/range-map-test \ - tests/valgrind/range-set-test \ - tests/valgrind/range-tower-test \ - tests/valgrind/sparse-array-test \ - tests/valgrind/sparse-xarray-test \ - tests/valgrind/str-test \ - tests/valgrind/string-map-test \ - tests/valgrind/stringi-map-test \ - tests/valgrind/string-set-test \ - tests/valgrind/stringi-set-test \ - tests/valgrind/tower-test \ - tests/valgrind/u8-istream-test \ - tests/valgrind/render-test \ - tests/valgrind/pspp-convert \ - tests/valgrind/pspp - -$(valgrind_wrappers): tests/valgrind-wrapper.in - @$(MKDIR_P) tests/valgrind - $(AM_V_GEN)$(SED) -e 's,[@]wrap_program[@],$@,' \ - $(top_srcdir)/tests/valgrind-wrapper.in > [email protected] - $(AM_V_at)chmod +x [email protected] - $(AM_V_at)mv [email protected] $@ -CLEANFILES += $(valgrind_wrappers) -EXTRA_DIST += tests/valgrind-wrapper.in -VALGRIND = $(SHELL) $(abs_top_builddir)/libtool --mode=execute valgrind --log-file=valgrind.%p --leak-check=full --num-callers=20 -check-valgrind: all tests/atconfig tests/atlocal $(TESTSUITE) $(valgrind_wrappers) - XTERM_LOCALE='' $(SHELL) '$(TESTSUITE)' -C tests VALGRIND='$(VALGRIND)' AUTOTEST_PATH='tests/valgrind:$(AUTOTEST_PATH)' -d $(TESTSUITEFLAGS) +check-valgrind: + $(MAKE) check RUNNER='$(SHELL) $(abs_top_builddir)/libtool --mode=execute valgrind --log-file=valgrind.%p --leak-check=full --num-callers=20' TESTSUITEFLAGS='$(TESTSUITEFLAGS) -d' @echo @echo '--------------------------------' @echo 'Valgrind output is in:' diff --git a/tests/testsuite.in b/tests/testsuite.in index 738ffea..95673dc 100644 --- a/tests/testsuite.in +++ b/tests/testsuite.in @@ -6,3 +6,41 @@ m4_ifndef([AT_SKIP_IF], [AT_CHECK([($1) \ && exit 77 || exit 0], [0], [ignore], [ignore])])]) +m4_divert_text([PREPARE_TESTS], [dnl +if test X"$RUNNER" != X; then + wrapper_dir=`pwd`/wrappers + rm "$wrapper_dir"/* + test -d "$wrapper_dir" || mkdir "$wrapper_dir" + + wrap_dir () { + test -d "$1" || return + for file in "$1"/*; do + if test -x "$file" && test -f "$file"; then + base=`basename $file` + wrapper=$wrapper_dir/$base + if test ! -e "$wrapper"; then + echo "exec $RUNNER $file \"\$@\"" > $wrapper + chmod +x $wrapper + fi + fi + done + } + + save_IFS=$IFS; IFS=$PATH_SEPARATOR + for dir in $AUTOTEST_PATH; do + IFS=$save_IFS + test X"$dir" = X && dir=. + case $dir in + [\\/]* | ?:[\\/]*) + wrap_dir "$dir" + ;; + *) + wrap_dir "$abs_top_builddir/$dir" + wrap_dir "$abs_top_srcdir/$dir" + ;; + esac + done + IFS=$save_IFS + PATH=$wrapper_dir:$PATH +fi +]) diff --git a/tests/valgrind-wrapper.in b/tests/valgrind-wrapper.in deleted file mode 100755 index a60cd9e..0000000 --- a/tests/valgrind-wrapper.in +++ /dev/null @@ -1,38 +0,0 @@ -#! /bin/sh - -program=`basename "$0"` - -new_PATH= -save_IFS=$IFS -IFS=: -found=no -for dir in $PATH; do - IFS=$save_IFS - if test "X$dir" = X; then - dir=. - fi - if test -x "$dir/$program"; then - if test $found = no; then - found=yes - continue - else - if test "X$next_program" = X; then - next_program=$dir/$program - fi - fi - fi -done -IFS=$save_IFS - -if test $found = no; then - echo "$0: $program not found in PATH ($PATH)" >&2 - exit 1 -elif test "X$next_program" = X; then - echo "$0: $program found only once in PATH ($PATH)" >&2 - exit 1 -fi - -: ${VALGRIND:=libtool --mode=execute valgrind --log-file=valgrind.%p --leak-check=full --num-callers=20} -exec $VALGRIND $next_program "$@" -echo "$0: $VALGRIND $wrap_program $* failed" >&2 -exit 1 _______________________________________________ pspp-dev mailing list [email protected] https://lists.gnu.org/mailman/listinfo/pspp-dev
