Merge pull request #652 from prometheus/mr/test-32

Automatically cross-test 32bit based on GOARCH
This commit is contained in:
Tobias Schmidt 2017-08-22 00:10:04 +02:00 committed by GitHub
commit 505275b48c

View File

@ -13,6 +13,7 @@
GO ?= GO15VENDOREXPERIMENT=1 go
GOPATH := $(firstword $(subst :, ,$(shell $(GO) env GOPATH)))
GOARCH := $(shell $(GO) env GOARCH)
PROMU ?= $(GOPATH)/bin/promu
STATICCHECK ?= $(GOPATH)/bin/staticcheck
@ -37,7 +38,22 @@ else
test-e2e := skip-test-e2e
endif
all: format vet staticcheck build test $(test-e2e)
# 64bit -> 32bit mapping for cross-checking. At least for amd64/386, the 64bit CPU can execute 32bit code but not the other way around, so we don't support cross-testing upwards.
cross-test = skip-test-32bit
define goarch_pair
ifeq ($$(GOARCH),$1)
GOARCH_CROSS = $2
cross-test = test-32bit
endif
endef
# By default, "cross" test with ourselves to cover unknown pairings.
$(eval $(call goarch_pair,amd64,386))
$(eval $(call goarch_pair,arm64,arm))
$(eval $(call goarch_pair,mips64,mips))
$(eval $(call goarch_pair,mips64el,mipsel))
all: format vet staticcheck build test $(cross-test) $(test-e2e)
style:
@echo ">> checking code style"
@ -47,6 +63,13 @@ test: collector/fixtures/sys/.unpacked
@echo ">> running tests"
@$(GO) test -short -race $(pkgs)
test-32bit: collector/fixtures/sys/.unpacked
@echo ">> running tests in 32-bit mode"
@env GOARCH=$(GOARCH_CROSS) $(GO) test $(pkgs)
skip-test-32bit:
@echo ">> SKIP running tests in 32-bit mode: not supported on $(GOARCH)"
collector/fixtures/sys/.unpacked: collector/fixtures/sys.ttar
./ttar -C collector/fixtures -x -f collector/fixtures/sys.ttar
touch $@