aboutsummaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorMatthias Rampke <mr@soundcloud.com>2017-08-21 16:46:43 +0000
committerMatthias Rampke <mr@soundcloud.com>2017-08-21 17:27:25 +0000
commit742004638360a90ee67f81ddb87bc6669fa1111b (patch)
tree9e96c49980d71b3c4d193833986e0d9914b788ac /Makefile
parent8661bbbb423fceee84c589a9cd3fc63f403abd96 (diff)
downloadprometheus_node_collector-742004638360a90ee67f81ddb87bc6669fa1111b.tar.bz2
prometheus_node_collector-742004638360a90ee67f81ddb87bc6669fa1111b.tar.xz
prometheus_node_collector-742004638360a90ee67f81ddb87bc6669fa1111b.zip
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.
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile25
1 files changed, 24 insertions, 1 deletions
diff --git a/Makefile b/Makefile
index 8ef57c0..b10d5a4 100644
--- a/Makefile
+++ b/Makefile
@@ -13,6 +13,7 @@
13 13
14GO ?= GO15VENDOREXPERIMENT=1 go 14GO ?= GO15VENDOREXPERIMENT=1 go
15GOPATH := $(firstword $(subst :, ,$(shell $(GO) env GOPATH))) 15GOPATH := $(firstword $(subst :, ,$(shell $(GO) env GOPATH)))
16GOARCH := $(shell $(GO) env GOARCH)
16 17
17PROMU ?= $(GOPATH)/bin/promu 18PROMU ?= $(GOPATH)/bin/promu
18STATICCHECK ?= $(GOPATH)/bin/staticcheck 19STATICCHECK ?= $(GOPATH)/bin/staticcheck
@@ -37,7 +38,22 @@ else
37 test-e2e := skip-test-e2e 38 test-e2e := skip-test-e2e
38endif 39endif
39 40
40all: format vet staticcheck build test $(test-e2e) 41# 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.
42cross-test = skip-test-32bit
43define goarch_pair
44ifeq ($$(GOARCH),$1)
45 GOARCH_CROSS = $2
46 cross-test = test-32bit
47endif
48endef
49
50# By default, "cross" test with ourselves to cover unknown pairings.
51$(eval $(call goarch_pair,amd64,386))
52$(eval $(call goarch_pair,arm64,arm))
53$(eval $(call goarch_pair,mips64,mips))
54$(eval $(call goarch_pair,mips64el,mipsel))
55
56all: format vet staticcheck build test $(cross-test) $(test-e2e)
41 57
42style: 58style:
43 @echo ">> checking code style" 59 @echo ">> checking code style"
@@ -47,6 +63,13 @@ test: collector/fixtures/sys/.unpacked
47 @echo ">> running tests" 63 @echo ">> running tests"
48 @$(GO) test -short -race $(pkgs) 64 @$(GO) test -short -race $(pkgs)
49 65
66test-32bit: collector/fixtures/sys/.unpacked
67 @echo ">> running tests in 32-bit mode"
68 @env GOARCH=$(GOARCH_CROSS) $(GO) test $(pkgs)
69
70skip-test-32bit:
71 @echo ">> SKIP running tests in 32-bit mode: not supported on $(GOARCH)"
72
50collector/fixtures/sys/.unpacked: collector/fixtures/sys.ttar 73collector/fixtures/sys/.unpacked: collector/fixtures/sys.ttar
51 ./ttar -C collector/fixtures -x -f collector/fixtures/sys.ttar 74 ./ttar -C collector/fixtures -x -f collector/fixtures/sys.ttar
52 touch $@ 75 touch $@