Many of the tests of the runtime package require invoking the go tool, and therefore are not run when testing libgo. This patch to gotools/Makefile.am adds an additional test of the runtime package on a native system, this time letting it run the newly built go tool. This provides significantly more testing. Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu.
Ian 2017-06-23 Ian Lance Taylor <i...@golang.org> * Makefile.am (MOSTLYCLEANFILES): Remove testing files and logs. (mostlyclean-local): Remove check-runtime-dir. (ECHO_ENV): Define. (check-go-tool): Depend on cgo. Write command to testlog. (check-runtime): New target. (check): Depend on check-runtime. Add @ to prettify output. * Makefile.in: Rebuild.
Index: Makefile.am =================================================================== --- Makefile.am (revision 249203) +++ Makefile.am (working copy) @@ -106,7 +106,12 @@ s-zdefaultcc: Makefile $(SHELL) $(srcdir)/../move-if-change zdefaultcc.go.tmp zdefaultcc.go $(STAMP) $@ -MOSTLYCLEANFILES = zdefaultcc.go s-zdefaultcc +MOSTLYCLEANFILES = \ + zdefaultcc.go s-zdefaultcc \ + check-gccgo gotools.head *-testlog gotools.sum gotools.log + +mostlyclean-local: + rm -rf check-go-dir check-runtime-dir if NATIVE @@ -156,6 +161,7 @@ check-gccgo: Makefile chmod +x $@ # CHECK_ENV sets up the environment to run the newly built go tool. +# If you change this, change ECHO_ENV, below. CHECK_ENV = \ PATH=`echo $(abs_builddir):$${PATH} | sed 's,::*,:,g;s,^:*,,;s,:*$$,,'`; \ export PATH; \ @@ -169,25 +175,54 @@ CHECK_ENV = \ LD_LIBRARY_PATH=`echo $${abs_libgodir}/.libs:$${LD_LIBRARY_PATH} | sed 's,::*,:,g;s,^:*,,;s,:*$$,,'`; \ export LD_LIBRARY_PATH; +# ECHO_ENV is a variant of CHECK_ENV to put into a testlog file. +# It assumes that abs_libgodir is set. +ECHO_ENV = PATH=`echo $(abs_builddir):$${PATH} | sed 's,::*,:,g;s,^:*,,;s,:*$$,,'` GCCGO='$(abs_builddir)/check-gccgo' GCCGOTOOLDIR='$(abs_builddir)' GO_TESTING_GOTOOLS=yes LD_LIBRARY_PATH=`echo $${abs_libgodir}/.libs:$${LD_LIBRARY_PATH} | sed 's,::*,:,g;s,^:*,,;s,:*$$,,'` + # check-go-tools runs `go test cmd/go` in our environment. -check-go-tool: go$(EXEEXT) check-head check-gccgo - rm -rf check-go-dir +check-go-tool: go$(EXEEXT) cgo$(EXEEXT) check-head check-gccgo + rm -rf check-go-dir cmd_go-testlog $(MKDIR_P) check-go-dir/src/cmd/go cp $(cmdsrcdir)/go/*.go check-go-dir/src/cmd/go/ cp $(libgodir)/zstdpkglist.go check-go-dir/src/cmd/go/ cp zdefaultcc.go check-go-dir/src/cmd/go/ cp -r $(cmdsrcdir)/go/testdata check-go-dir/src/cmd/go/ + @abs_libgodir=`cd $(libgodir) && $(PWD_COMMAND)`; \ + abs_checkdir=`cd check-go-dir && $(PWD_COMMAND)`; \ + echo "cd check-go-dir/src/cmd/go && $(ECHO_ENV) GOPATH=$${abs_checkdir} $(abs_builddir)/go$(EXEEXT) test -test.short -test.v" > cmd_go-testlog $(CHECK_ENV) \ GOPATH=`cd check-go-dir && $(PWD_COMMAND)`; \ export GOPATH; \ - (cd check-go-dir/src/cmd/go && $(abs_builddir)/go$(EXEEXT) test -test.short -test.v) >& cmd_go-testlog || true + (cd check-go-dir/src/cmd/go && $(abs_builddir)/go$(EXEEXT) test -test.short -test.v) >> cmd_go-testlog 2>&1 || true grep '^--- ' cmd_go-testlog | sed -e 's/^--- \(.*\) ([^)]*)$$/\1/' +# check-runtime runs `go test runtime` in our environment. +# The runtime package is also tested as part of libgo, +# but the runtime tests use the go tool heavily, so testing +# here too will catch more problems. +check-runtime: go$(EXEEXT) cgo$(EXEEXT) check-head check-gccgo + rm -rf check-runtime-dir runtime-testlog + $(MKDIR_P) check-runtime-dir + @abs_libgodir=`cd $(libgodir) && $(PWD_COMMAND)`; \ + LD_LIBRARY_PATH=`echo $${abs_libgodir}/.libs:$${LD_LIBRARY_PATH} | sed 's,::*,:,g;s,^:*,,;s,:*$$,,'`; \ + GOARCH=`$(abs_builddir)/go$(EXEEXT) env GOARCH`; \ + GOOS=`$(abs_builddir)/go$(EXEEXT) env GOOS`; \ + files=`$(SHELL) $(libgosrcdir)/../match.sh --goarch=$${GOARCH} --goos=$${GOOS} --srcdir=$(libgosrcdir)/runtime --extrafiles="$(libgodir)/runtime_sysinfo.go $(libgodir)/sigtab.go" --tag=libffi`; \ + echo "$(ECHO_ENV) GC='$(abs_builddir)/check-gccgo -fgo-compiling-runtime' GOARCH=$${GOARCH} GOOS=$${GOOS} $(SHELL) $(libgosrcdir)/../testsuite/gotest --goarch=$${GOARCH} --goos=$${GOOS} --basedir=$(libgosrcdir)/.. --srcdir=$(libgosrcdir)/runtime --pkgpath=runtime --pkgfiles='$${files}' -test.v" > runtime-testlog + $(CHECK_ENV) \ + GC="$${GCCGO} -fgo-compiling-runtime"; \ + export GC; \ + GOARCH=`$(abs_builddir)/go$(EXEEXT) env GOARCH`; \ + GOOS=`$(abs_builddir)/go$(EXEEXT) env GOOS`; \ + files=`$(SHELL) $(libgosrcdir)/../match.sh --goarch=$${GOARCH} --goos=$${GOOS} --srcdir=$(libgosrcdir)/runtime --extrafiles="$(libgodir)/runtime_sysinfo.go $(libgodir)/sigtab.go" --tag=libffi`; \ + $(SHELL) $(libgosrcdir)/../testsuite/gotest --goarch=$${GOARCH} --goos=$${GOOS} --basedir=$(libgosrcdir)/.. --srcdir=$(libgosrcdir)/runtime --pkgpath=runtime --pkgfiles="$${files}" -test.v >> runtime-testlog 2>&1 || true + grep '^--- ' runtime-testlog | sed -e 's/^--- \(.*\) ([^)]*)$$/\1/' + # The check targets runs the tests and assembles the output files. -check: check-head check-go-tool - mv gotools.head gotools.sum - cp gotools.sum gotools.log - for file in cmd_go-testlog; do \ +check: check-head check-go-tool check-runtime + @mv gotools.head gotools.sum + @cp gotools.sum gotools.log + @for file in cmd_go-testlog runtime-testlog; do \ testname=`echo $${file} | sed -e 's/-testlog//' -e 's|_|/|'`; \ echo "Running $${testname}" >> gotools.sum; \ echo "Running $${testname}" >> gotools.log; \ @@ -196,22 +231,22 @@ check: check-head check-go-tool done @echo >> gotools.sum @echo " === gotools Summary ===" >> gotools.sum - pass=`grep -c '^PASS' gotools.sum`; \ + @pass=`grep -c '^PASS' gotools.sum`; \ if test "$${pass}" -ne "0"; then \ echo "# of expected passes $${pass}" >> gotools.sum; \ fi - fail=`grep -c '^FAIL' gotools.sum`; \ + @fail=`grep -c '^FAIL' gotools.sum`; \ if test "$${fail}" -ne "0"; then \ echo "# of unexpected failures $${fail}" >> gotools.sum; \ fi - untested=`grep -c '^UNTESTED' gotools.sum`; \ + @untested=`grep -c '^UNTESTED' gotools.sum`; \ if test "$${untested}" -ne "0"; then \ echo "# of untested testcases $${untested}" >> gotools.sum; \ fi - echo `echo $(GOC_FOR_TARGET) | sed -e 's/ .*//'` `$(GOC_FOR_TARGET) -v 2>&1 | grep " version" | sed -n -e 's/.* \(version.*$$\)/\1/p'` >> gotools.sum - echo >> gotools.log - echo "runtest completed at `date`" >> gotools.log - if grep '^FAIL' gotools.sum >/dev/null 2>&1; then exit 1; fi + @echo `echo $(GOC_FOR_TARGET) | sed -e 's/ .*//'` `$(GOC_FOR_TARGET) -v 2>&1 | grep " version" | sed -n -e 's/.* \(version.*$$\)/\1/p'` >> gotools.sum + @echo >> gotools.log + @echo "runtest completed at `date`" >> gotools.log + @if grep '^FAIL' gotools.sum >/dev/null 2>&1; then exit 1; fi .PHONY: check check-head check-go-tool @@ -224,6 +259,3 @@ else # the go/build package. Figure this out later. endif - -mostlyclean-local: - rm -rf check-go-dir