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=<host_to_test_on> 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
This commit is contained in:
Joshua Warner 2013-02-14 17:21:57 -07:00 committed by Joshua Warner
parent b4a73a2e0b
commit 1258b23ea1
2 changed files with 28 additions and 7 deletions

View File

@ -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 $(@)"

View File

@ -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