aboutsummaryrefslogtreecommitdiff
path: root/gotools/Makefile.am
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@golang.org>2017-06-14 19:26:21 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2017-06-14 19:26:21 +0000
commiteec2130ea274839bdbd7a9727b622b11b092d2bf (patch)
treecef1993448613e7482c2432a43b7408e6d833ea7 /gotools/Makefile.am
parent1a711a0b5cb291d875acc4b46a4a39ea9185eff3 (diff)
downloadgcc-eec2130ea274839bdbd7a9727b622b11b092d2bf.zip
gcc-eec2130ea274839bdbd7a9727b622b11b092d2bf.tar.gz
gcc-eec2130ea274839bdbd7a9727b622b11b092d2bf.tar.bz2
Makefile.am (libgosrcdir): Define.
* Makefile.am (libgosrcdir): Define. (check-head, check-gccgo, check-go-tool): New targets. (CHECK_ENV): Define. (check): New target. (mostlyclean-local): New target. * Makefile.in: Rebuild. From-SVN: r249203
Diffstat (limited to 'gotools/Makefile.am')
-rw-r--r--gotools/Makefile.am89
1 files changed, 88 insertions, 1 deletions
diff --git a/gotools/Makefile.am b/gotools/Makefile.am
index ccadbd2..bde5e43 100644
--- a/gotools/Makefile.am
+++ b/gotools/Makefile.am
@@ -42,7 +42,8 @@ AM_GOCFLAGS = -I $(libgodir)
AM_LDFLAGS = -L $(libgodir) -L $(libgodir)/.libs
GOLINK = $(GOCOMPILER) $(GOCFLAGS) $(AM_GOCFLAGS) $(LDFLAGS) $(AM_LDFLAGS) -o $@
-cmdsrcdir = $(srcdir)/../libgo/go/cmd
+libgosrcdir = $(srcdir)/../libgo/go
+cmdsrcdir = $(libgosrcdir)/cmd
go_cmd_go_files = \
$(cmdsrcdir)/go/alldocs.go \
@@ -131,6 +132,89 @@ install-exec-local: cgo$(EXEEXT)
uninstall-local:
rm -f $(DESTDIR)$(libexecsubdir)/cgo$(exeext)
+# Run tests using the go tool, and frob the output to look like that
+# generated by DejaGNU. The main output of this is two files:
+# gotools.sum and gotools.log.
+
+# check-head starts generating the log files in DejaGNU format. This
+# is a separate target so that the date is approximately when we start
+# running the tests.
+check-head:
+ @echo "Test Run By $${USER} on `date`" > gotools.head
+ @echo "Native configuration is $(host_triplet)" >> gotools.head
+ @echo >> gotools.head
+ @echo " === gotools tests ===" >> gotools.head
+ @echo >> gotools.head
+
+# check-gccgo is a little shell script that executes gccgo with the
+# options to pick up the newly built libgo.
+check-gccgo: Makefile
+ rm -f $@
+ echo "#!/bin/sh" > $@
+ abs_libgodir=`cd $(libgodir) && $(PWD_COMMAND)`; \
+ echo "$(GOCOMPILE)" '"$$@"' "-I $${abs_libgodir} -L $${abs_libgodir} -L $${abs_libgodir}/.libs" >> $@
+ chmod +x $@
+
+# CHECK_ENV sets up the environment to run the newly built go tool.
+CHECK_ENV = \
+ PATH=`echo $(abs_builddir):$${PATH} | sed 's,::*,:,g;s,^:*,,;s,:*$$,,'`; \
+ export PATH; \
+ GCCGO="$(abs_builddir)/check-gccgo"; \
+ export GCCGO; \
+ GCCGOTOOLDIR="$(abs_builddir)"; \
+ export GCCGOTOOLDIR; \
+ GO_TESTING_GOTOOLS=yes; \
+ export GO_TESTING_GOTOOLS; \
+ abs_libgodir=`cd $(libgodir) && $(PWD_COMMAND)`; \
+ LD_LIBRARY_PATH=`echo $${abs_libgodir}/.libs:$${LD_LIBRARY_PATH} | sed 's,::*,:,g;s,^:*,,;s,:*$$,,'`; \
+ export LD_LIBRARY_PATH;
+
+# 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
+ $(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/
+ $(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
+ grep '^--- ' cmd_go-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 \
+ testname=`echo $${file} | sed -e 's/-testlog//' -e 's|_|/|'`; \
+ echo "Running $${testname}" >> gotools.sum; \
+ echo "Running $${testname}" >> gotools.log; \
+ sed -e 's/^--- \(.*\) ([^)]*)$$/\1/' < $${file} >> gotools.log; \
+ grep '^--- ' $${file} | sed -e 's/^--- \(.*\) ([^)]*)$$/\1/' -e 's/SKIP/UNTESTED/' >> gotools.sum; \
+ done
+ @echo >> gotools.sum
+ @echo " === gotools Summary ===" >> 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`; \
+ if test "$${fail}" -ne "0"; then \
+ echo "# of unexpected failures $${fail}" >> gotools.sum; \
+ fi
+ 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
+
+.PHONY: check check-head check-go-tool
+
else
# For a non-native build we have to build the programs using a
@@ -140,3 +224,6 @@ else
# the go/build package. Figure this out later.
endif
+
+mostlyclean-local:
+ rm -rf check-go-dir