Commit ffa98da4 by Ian Lance Taylor

runtime: introduce build targets for running benchmarks

This introduces the "bench" build target, which can be used to run
all benchmarks.

It is also possible to run subsets of benchmarks with the
"package/check" build targets by setting GOBENCH to a matching regex.

From-SVN: r212212
parent 25eff60d
...@@ -1996,6 +1996,7 @@ BUILDPACKAGE = \ ...@@ -1996,6 +1996,7 @@ BUILDPACKAGE = \
$(LTGOCOMPILE) -I . -c -fgo-pkgpath=`echo $@ | sed -e 's/.lo$$//' -e 's/-go$$//'` -o $@ $$files $(LTGOCOMPILE) -I . -c -fgo-pkgpath=`echo $@ | sed -e 's/.lo$$//' -e 's/-go$$//'` -o $@ $$files
GOTESTFLAGS = GOTESTFLAGS =
GOBENCH =
# Check a package. # Check a package.
CHECK = \ CHECK = \
...@@ -2015,6 +2016,8 @@ CHECK = \ ...@@ -2015,6 +2016,8 @@ CHECK = \
rm -f $@-testsum $@-testlog; \ rm -f $@-testsum $@-testlog; \
if test "$(USE_DEJAGNU)" = "yes"; then \ if test "$(USE_DEJAGNU)" = "yes"; then \
$(SHELL) $(srcdir)/testsuite/gotest --dejagnu=yes --basedir=$(srcdir) --srcdir=$(srcdir)/go/$(@D) --pkgpath="$(@D)" --pkgfiles="$(go_$(subst /,_,$(@D))_files)" --testname="$(@D)" --goarch="$(GOARCH)" $(GOTESTFLAGS) $(go_$(subst /,_,$(@D))_test_files); \ $(SHELL) $(srcdir)/testsuite/gotest --dejagnu=yes --basedir=$(srcdir) --srcdir=$(srcdir)/go/$(@D) --pkgpath="$(@D)" --pkgfiles="$(go_$(subst /,_,$(@D))_files)" --testname="$(@D)" --goarch="$(GOARCH)" $(GOTESTFLAGS) $(go_$(subst /,_,$(@D))_test_files); \
elif test "$(GOBENCH)" != ""; then \
$(SHELL) $(srcdir)/testsuite/gotest --basedir=$(srcdir) --srcdir=$(srcdir)/go/$(@D) --pkgpath="$(@D)" --pkgfiles="$(go_$(subst /,_,$(@D))_files)" --goarch="$(GOARCH)" --bench="$(GOBENCH)" $(GOTESTFLAGS) $(go_$(subst /,_,$(@D))_test_files); \
else \ else \
if $(SHELL) $(srcdir)/testsuite/gotest --basedir=$(srcdir) --srcdir=$(srcdir)/go/$(@D) --pkgpath="$(@D)" --pkgfiles="$(go_$(subst /,_,$(@D))_files)" --goarch="$(GOARCH)" $(GOTESTFLAGS) $(go_$(subst /,_,$(@D))_test_files) >>$@-testlog 2>&1; then \ if $(SHELL) $(srcdir)/testsuite/gotest --basedir=$(srcdir) --srcdir=$(srcdir)/go/$(@D) --pkgpath="$(@D)" --pkgfiles="$(go_$(subst /,_,$(@D))_files)" --goarch="$(GOARCH)" $(GOTESTFLAGS) $(go_$(subst /,_,$(@D))_test_files) >>$@-testlog 2>&1; then \
echo "PASS: $(@D)" >> $@-testlog; \ echo "PASS: $(@D)" >> $@-testlog; \
...@@ -3845,6 +3848,9 @@ check-am: ...@@ -3845,6 +3848,9 @@ check-am:
check-multi: check-multi:
$(MULTIDO) $(AM_MAKEFLAGS) DO=check-am multi-do # $(MAKE) $(MULTIDO) $(AM_MAKEFLAGS) DO=check-am multi-do # $(MAKE)
bench:
-@$(MAKE) -k $(TEST_PACKAGES) GOBENCH=.
MOSTLYCLEAN_FILES = libgo.head libgo.sum.sep libgo.log.sep MOSTLYCLEAN_FILES = libgo.head libgo.sum.sep libgo.log.sep
mostlyclean-local: mostlyclean-local:
......
...@@ -2066,6 +2066,7 @@ BUILDPACKAGE = \ ...@@ -2066,6 +2066,7 @@ BUILDPACKAGE = \
$(LTGOCOMPILE) -I . -c -fgo-pkgpath=`echo $@ | sed -e 's/.lo$$//' -e 's/-go$$//'` -o $@ $$files $(LTGOCOMPILE) -I . -c -fgo-pkgpath=`echo $@ | sed -e 's/.lo$$//' -e 's/-go$$//'` -o $@ $$files
GOTESTFLAGS = GOTESTFLAGS =
GOBENCH =
# Check a package. # Check a package.
CHECK = \ CHECK = \
...@@ -2085,6 +2086,8 @@ CHECK = \ ...@@ -2085,6 +2086,8 @@ CHECK = \
rm -f $@-testsum $@-testlog; \ rm -f $@-testsum $@-testlog; \
if test "$(USE_DEJAGNU)" = "yes"; then \ if test "$(USE_DEJAGNU)" = "yes"; then \
$(SHELL) $(srcdir)/testsuite/gotest --dejagnu=yes --basedir=$(srcdir) --srcdir=$(srcdir)/go/$(@D) --pkgpath="$(@D)" --pkgfiles="$(go_$(subst /,_,$(@D))_files)" --testname="$(@D)" --goarch="$(GOARCH)" $(GOTESTFLAGS) $(go_$(subst /,_,$(@D))_test_files); \ $(SHELL) $(srcdir)/testsuite/gotest --dejagnu=yes --basedir=$(srcdir) --srcdir=$(srcdir)/go/$(@D) --pkgpath="$(@D)" --pkgfiles="$(go_$(subst /,_,$(@D))_files)" --testname="$(@D)" --goarch="$(GOARCH)" $(GOTESTFLAGS) $(go_$(subst /,_,$(@D))_test_files); \
elif test "$(GOBENCH)" != ""; then \
$(SHELL) $(srcdir)/testsuite/gotest --basedir=$(srcdir) --srcdir=$(srcdir)/go/$(@D) --pkgpath="$(@D)" --pkgfiles="$(go_$(subst /,_,$(@D))_files)" --goarch="$(GOARCH)" --bench="$(GOBENCH)" $(GOTESTFLAGS) $(go_$(subst /,_,$(@D))_test_files); \
else \ else \
if $(SHELL) $(srcdir)/testsuite/gotest --basedir=$(srcdir) --srcdir=$(srcdir)/go/$(@D) --pkgpath="$(@D)" --pkgfiles="$(go_$(subst /,_,$(@D))_files)" --goarch="$(GOARCH)" $(GOTESTFLAGS) $(go_$(subst /,_,$(@D))_test_files) >>$@-testlog 2>&1; then \ if $(SHELL) $(srcdir)/testsuite/gotest --basedir=$(srcdir) --srcdir=$(srcdir)/go/$(@D) --pkgpath="$(@D)" --pkgfiles="$(go_$(subst /,_,$(@D))_files)" --goarch="$(GOARCH)" $(GOTESTFLAGS) $(go_$(subst /,_,$(@D))_test_files) >>$@-testlog 2>&1; then \
echo "PASS: $(@D)" >> $@-testlog; \ echo "PASS: $(@D)" >> $@-testlog; \
...@@ -6083,6 +6086,9 @@ check-am: ...@@ -6083,6 +6086,9 @@ check-am:
check-multi: check-multi:
$(MULTIDO) $(AM_MAKEFLAGS) DO=check-am multi-do # $(MAKE) $(MULTIDO) $(AM_MAKEFLAGS) DO=check-am multi-do # $(MAKE)
bench:
-@$(MAKE) -k $(TEST_PACKAGES) GOBENCH=.
mostlyclean-local: mostlyclean-local:
find . -name '*.lo' -print | xargs $(LIBTOOL) --mode=clean rm -f find . -name '*.lo' -print | xargs $(LIBTOOL) --mode=clean rm -f
find . -name '*.$(OBJEXT)' -print | xargs rm -f find . -name '*.$(OBJEXT)' -print | xargs rm -f
......
...@@ -36,6 +36,7 @@ dejagnu=no ...@@ -36,6 +36,7 @@ dejagnu=no
GOARCH="" GOARCH=""
timeout=240 timeout=240
testname="" testname=""
bench=""
trace=false trace=false
while $loop; do while $loop; do
case "x$1" in case "x$1" in
...@@ -124,6 +125,15 @@ while $loop; do ...@@ -124,6 +125,15 @@ while $loop; do
testname=`echo $1 | sed -e 's/^--testname=//'` testname=`echo $1 | sed -e 's/^--testname=//'`
shift shift
;; ;;
x--bench)
bench=$2
shift
shift
;;
x--bench=*)
bench=`echo $1 | sed -e 's/^--bench=//'`
shift
;;
x--trace) x--trace)
trace=true trace=true
shift shift
...@@ -473,6 +483,7 @@ xno) ...@@ -473,6 +483,7 @@ xno)
fi fi
${GL} *.o ${GOLIBS} ${GL} *.o ${GOLIBS}
if test "$bench" = ""; then
if test "$trace" = "true"; then if test "$trace" = "true"; then
echo ./a.out -test.short -test.timeout=${timeout}s "$@" echo ./a.out -test.short -test.timeout=${timeout}s "$@"
fi fi
...@@ -488,6 +499,13 @@ xno) ...@@ -488,6 +499,13 @@ xno)
if ! test -f gotest-timeout; then if ! test -f gotest-timeout; then
kill $alarmpid kill $alarmpid
fi fi
else
if test "$trace" = "true"; then
echo ./a.out -test.run=^\$ -test.bench="${bench}" "$@"
fi
./a.out -test.run=^\$ -test.bench="${bench}" "$@"
status=$?
fi
exit $status exit $status
;; ;;
xyes) xyes)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment