Add checking about go-race requested to run tests 45/17745/2
authorSebastien Douheret <sebastien.douheret@iot.bzh>
Tue, 6 Nov 2018 11:13:37 +0000 (12:13 +0100)
committerSebastien Douheret <sebastien.douheret@iot.bzh>
Tue, 6 Nov 2018 17:13:56 +0000 (18:13 +0100)
go-race package must be install in order to run tests with --race option
set else you will get such kind of error:
  runtime.RaceErrors: relocation target __tsan_report_count not defined

Change-Id: I037d53e10550c5fa74cbb6913d43614ccaa65d11
Signed-off-by: Sebastien Douheret <sebastien.douheret@iot.bzh>
Makefile

index a91af3f..6396405 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -78,8 +78,8 @@ export PATH := $(PATH):$(LOCAL_TOOLSDIR)
 GOVERSION := $(shell go version |grep -o '[0-9\.]*'|head -n 1)
 GOVERMAJ := $(shell echo $(GOVERSION) |cut -f1 -d.)
 GOVERMIN := $(shell echo $(GOVERSION) |cut -f2 -d.)
 GOVERSION := $(shell go version |grep -o '[0-9\.]*'|head -n 1)
 GOVERMAJ := $(shell echo $(GOVERSION) |cut -f1 -d.)
 GOVERMIN := $(shell echo $(GOVERSION) |cut -f2 -d.)
-CHECKGOVER := $(shell [ $(GOVERMAJ) -gt 1 -o \( $(GOVERMAJ) -eq 1 -a $(GOVERMIN) -ge 8 \) ] && echo true)
-CHECKERRMSG := "ERROR: Go version 1.8.1 or higher is requested (current detected version: $(GOVERSION))."
+CHECKGOVER := $(shell [ $(GOVERMAJ) -gt 1 -o \( $(GOVERMAJ) -eq 1 -a $(GOVERMIN) -ge 9 \) ] && echo true)
+CHECKERRMSG := "ERROR: Go version 1.9.0 or higher is requested (current detected version: $(GOVERSION))."
 
 
 VERBOSE_1 := -v
 
 
 VERBOSE_1 := -v
@@ -119,7 +119,7 @@ xds: scripts tools/syncthing/copytobin
        @cd $(ROOT_SRCDIR); $(BUILD_ENV_FLAGS) go build $(VERBOSE_$(V)) -i -o $(LOCAL_BINDIR)/$(TARGET)$(EXT) -ldflags "$(GO_LDFLAGS) -X main.AppVersion=$(VERSION) -X main.AppSubVersion=$(SUB_VERSION)" -gcflags "$(GO_GCFLAGS)" .
 
 .PHONY: test
        @cd $(ROOT_SRCDIR); $(BUILD_ENV_FLAGS) go build $(VERBOSE_$(V)) -i -o $(LOCAL_BINDIR)/$(TARGET)$(EXT) -ldflags "$(GO_LDFLAGS) -X main.AppVersion=$(VERSION) -X main.AppSubVersion=$(SUB_VERSION)" -gcflags "$(GO_GCFLAGS)" .
 
 .PHONY: test
-test: tools/glide
+test: checkgorace tools/glide
 ifndef name
        GOCACHE=off go test --race ./test -v
 else
 ifndef name
        GOCACHE=off go test --race ./test -v
 else
@@ -227,6 +227,9 @@ tools/syncthing/copytobin:
 checkgover:
        @test "$(CHECKGOVER)" = "true" || { echo $(CHECKERRMSG); exit 1; }
 
 checkgover:
        @test "$(CHECKGOVER)" = "true" || { echo $(CHECKERRMSG); exit 1; }
 
+.PHONY:
+checkgorace: checkgover
+       @ls $(shell go env GOROOT)/src/runtime/race/*.syso 1> /dev/null 2>&1 || { echo "ERROR: go-race package mandatory to run test. Please install it, for example: zypper install go-race"; exit 1; }
 
 .PHONY: help
 help:
 
 .PHONY: help
 help: