diff options
author | Matthias Rampke <mr@soundcloud.com> | 2017-08-21 16:46:43 +0000 |
---|---|---|
committer | Matthias Rampke <mr@soundcloud.com> | 2017-08-21 17:27:25 +0000 |
commit | 742004638360a90ee67f81ddb87bc6669fa1111b (patch) | |
tree | 9e96c49980d71b3c4d193833986e0d9914b788ac /Makefile | |
parent | 8661bbbb423fceee84c589a9cd3fc63f403abd96 (diff) | |
download | prometheus_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-- | Makefile | 25 |
1 files changed, 24 insertions, 1 deletions
@@ -13,6 +13,7 @@ | |||
13 | 13 | ||
14 | GO ?= GO15VENDOREXPERIMENT=1 go | 14 | GO ?= GO15VENDOREXPERIMENT=1 go |
15 | GOPATH := $(firstword $(subst :, ,$(shell $(GO) env GOPATH))) | 15 | GOPATH := $(firstword $(subst :, ,$(shell $(GO) env GOPATH))) |
16 | GOARCH := $(shell $(GO) env GOARCH) | ||
16 | 17 | ||
17 | PROMU ?= $(GOPATH)/bin/promu | 18 | PROMU ?= $(GOPATH)/bin/promu |
18 | STATICCHECK ?= $(GOPATH)/bin/staticcheck | 19 | STATICCHECK ?= $(GOPATH)/bin/staticcheck |
@@ -37,7 +38,22 @@ else | |||
37 | test-e2e := skip-test-e2e | 38 | test-e2e := skip-test-e2e |
38 | endif | 39 | endif |
39 | 40 | ||
40 | all: 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. |
42 | cross-test = skip-test-32bit | ||
43 | define goarch_pair | ||
44 | ifeq ($$(GOARCH),$1) | ||
45 | GOARCH_CROSS = $2 | ||
46 | cross-test = test-32bit | ||
47 | endif | ||
48 | endef | ||
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 | |||
56 | all: format vet staticcheck build test $(cross-test) $(test-e2e) | ||
41 | 57 | ||
42 | style: | 58 | style: |
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 | ||
66 | test-32bit: collector/fixtures/sys/.unpacked | ||
67 | @echo ">> running tests in 32-bit mode" | ||
68 | @env GOARCH=$(GOARCH_CROSS) $(GO) test $(pkgs) | ||
69 | |||
70 | skip-test-32bit: | ||
71 | @echo ">> SKIP running tests in 32-bit mode: not supported on $(GOARCH)" | ||
72 | |||
50 | collector/fixtures/sys/.unpacked: collector/fixtures/sys.ttar | 73 | collector/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 $@ |