From 1258b23ea1882fc73c762ab1bac6a7cf13ceafa1 Mon Sep 17 00:00:00 2001 From: Joshua Warner Date: Thu, 14 Feb 2013 17:21:57 -0700 Subject: [PATCH] add remote-test capability To execute tests on a remote host (for instance, because you're cross-compiling), simply do: make remote-test=true remote-test-host= test You can set several variables to control the functionality of remote-test. See them below, along with their default values: remote-test-host = localhost # host to ssh to remote-test-port = 22 remote-test-user = ${USER} # user to execute tests as remote-test-dir = /tmp/avian-test-${USER} # dir to rsync build output to --- makefile | 30 ++++++++++++++++++++++++------ test/test.sh | 5 ++++- 2 files changed, 28 insertions(+), 7 deletions(-) diff --git a/makefile b/makefile index b83d2d45a7..5ee56d857b 100755 --- a/makefile +++ b/makefile @@ -266,9 +266,14 @@ asm-output = -o $(1) asm-input = -c $(1) asm-format = S as = $(cc) -ld = $(cxx) +ld = $(cc) build-ld = $(build-cc) +remote-test-host = localhost +remote-test-port = 22 +remote-test-user = ${USER} +remote-test-dir = /tmp/avian-test-${USER} + static = -static shared = -shared @@ -1251,11 +1256,14 @@ vg: build $(library-path) $(vg) $(test-executable) $(test-args) .PHONY: test -test: build - $(library-path) /bin/sh $(test)/test.sh 2>/dev/null \ - $(test-executable) $(mode) "$(test-flags)" \ - $(call class-names,$(test-build),$(filter-out $(test-support-classes), $(test-classes))) \ - $(continuation-tests) $(tail-tests) +test: build $(build)/run-tests.sh $(build)/test.sh +ifneq ($(remote-test),true) + /bin/sh $(build)/run-tests.sh +else + @echo "testing remotely..." $(arch) $(target-arch) + rsync $(build) -rav --exclude '*.o' --rsh="ssh -p$(remote-test-port)" $(remote-test-user)@$(remote-test-host):$(remote-test-dir) + ssh -p$(remote-test-port) $(remote-test-user)@$(remote-test-host) sh "$(remote-test-dir)/$(platform)-$(arch)$(options)/run-tests.sh" +endif .PHONY: tarball tarball: @@ -1286,6 +1294,16 @@ ifeq ($(continuations),true) $(build)/compile-x86-asm.o: $(src)/continuations-x86.$(asm-format) endif +$(build)/run-tests.sh: $(test-classes) makefile + echo 'cd $$(dirname $$0)' > $(@) + echo "sh ./test.sh 2>/dev/null \\" >> $(@) + echo "$(shell echo $(library-path) | sed 's|$(build)|\.|g') ./$(name)${exe-suffix} $(mode) \"-Djava.library.path=$$(pwd) -cp test\" log.txt \\" >> $(@) + echo "$(call class-names,$(test-build),$(filter-out $(test-support-classes), $(test-classes))) \\" >> $(@) + echo "$(continuation-tests) $(tail-tests)" >> $(@) + +$(build)/test.sh: $(test)/test.sh + cp $(<) $(@) + gen-arg = $(shell echo $(1) | sed -e 's:$(build)/type-\(.*\)\.cpp:\1:') $(generated-code): %.cpp: $(src)/types.def $(generator) $(classpath-dep) @echo "generating $(@)" diff --git a/test/test.sh b/test/test.sh index defd6af06a..2dc26b4ef3 100644 --- a/test/test.sh +++ b/test/test.sh @@ -1,14 +1,17 @@ #!/bin/sh -log=build/log.txt vg="nice valgrind --leak-check=full --num-callers=32 \ --freelist-vol=100000000 --error-exitcode=1" +ld_path=${1}; shift vm=${1}; shift mode=${1}; shift flags=${1}; shift +log=${1}; shift tests=${@} +export ${ld_path} + echo -n "" >${log} echo