Automatically cross-test 32bit based on GOARCH
Try to determine the corresponding 32bit architecture from the current GOARCH and run the tests under that architecture. This only works on a GOOS/GOARCH that can execute binaries for the smaller architecture, such as running linux/386 binaries under linux/amd64. I tested that this works under linux/amd64 and darwin/amd64, the rest of the architectures is guesswork. While we still only run regular tests on Intel/Linux architectures, this covers general integer overflow issues like #629.
This commit is contained in:
parent
8661bbbb42
commit
7420046383
25
Makefile
25
Makefile
|
@ -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 $@
|
||||
|
|
Loading…
Reference in New Issue