From a2c41e650da5e303a5d27a587b5699fe9ea0db90 Mon Sep 17 00:00:00 2001 From: Christian Couder Date: Mon, 6 Apr 2015 17:52:28 +0200 Subject: [PATCH 1/5] test/bin: add checkflags to detect flag changes This script can be used in a Makefile to detect flag changes and to save the new flags in a file. License: MIT Signed-off-by: Christian Couder --- test/bin/checkflags | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100755 test/bin/checkflags diff --git a/test/bin/checkflags b/test/bin/checkflags new file mode 100755 index 000000000..a246a82c3 --- /dev/null +++ b/test/bin/checkflags @@ -0,0 +1,23 @@ +#!/bin/sh +# Author: Christian Couder +# MIT LICENSED + +if test "$#" -lt 3 +then + echo >&2 "usage $0 FILE VALUES MSG..." + exit 1 +fi + +FLAG_FILE="$1" +FLAG_VALS="$2" +shift +shift +FLAG_MSGS="$@" + +# Use x in front of tested values as flags could be +# interpreted by "test" to be for itself. +if test x"$FLAG_VALS" != x"$(cat "$FLAG_FILE" 2>/dev/null)" +then + echo "$FLAG_MSGS" + echo "$FLAG_VALS" >"$FLAG_FILE" +fi From 7edfc784ac45bc0715a9e2ca63ce8d78a1a3827f Mon Sep 17 00:00:00 2001 From: Christian Couder Date: Sat, 4 Apr 2015 11:59:45 +0200 Subject: [PATCH 2/5] test: add GOFLAGS variable to the Makefile This makes it possible to build binaries with different flags. The content of the GOFLAGS variable is stored in a IPFS-BUILD-OPTIONS file, so that if GOFLAGS changes a rebuild of the binaries with the new flags is forced. License: MIT Signed-off-by: Christian Couder --- test/Makefile | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/test/Makefile b/test/Makefile index 868eac731..648b3a439 100644 --- a/test/Makefile +++ b/test/Makefile @@ -6,6 +6,9 @@ RANDOM_SRC = ../Godeps/_workspace/src/github.com/jbenet/go-random MULTIHASH_SRC = ../Godeps/_workspace/src/github.com/jbenet/go-multihash POLLENDPOINT_SRC= ../thirdparty/pollEndpoint +# User might want to override those on the command line +GOFLAGS = + all: deps deps: bins @@ -15,17 +18,21 @@ clean: bins: $(BINS) -bin/random: $(RANDOM_SRC)/**/*.go - go build -o bin/random $(RANDOM_SRC)/random +bin/random: $(RANDOM_SRC)/**/*.go IPFS-BUILD-OPTIONS + @echo "*** installing $@ ***" + go build $(GOFLAGS) -o bin/random $(RANDOM_SRC)/random -bin/multihash: $(MULTIHASH_SRC)/**/*.go - go build -o bin/multihash $(MULTIHASH_SRC)/multihash +bin/multihash: $(MULTIHASH_SRC)/**/*.go IPFS-BUILD-OPTIONS + @echo "*** installing $@ ***" + go build $(GOFLAGS) -o bin/multihash $(MULTIHASH_SRC)/multihash -bin/ipfs: $(IPFS_ROOT)/**/*.go - go build -o bin/ipfs $(IPFS_CMD) +bin/ipfs: $(IPFS_ROOT)/**/*.go IPFS-BUILD-OPTIONS + @echo "*** installing $@ ***" + go build $(GOFLAGS) -o bin/ipfs $(IPFS_CMD) -bin/pollEndpoint: $(POLLENDPOINT_SRC)/*.go - go build -o bin/pollEndpoint $(POLLENDPOINT_SRC) +bin/pollEndpoint: $(POLLENDPOINT_SRC)/*.go IPFS-BUILD-OPTIONS + @echo "*** installing $@ ***" + go build $(GOFLAGS) -o bin/pollEndpoint $(POLLENDPOINT_SRC) test: test_expensive @@ -38,4 +45,7 @@ test_cheap: cd sharness && make cd 3nodetest && make -.PHONY: all clean +IPFS-BUILD-OPTIONS: FORCE + @bin/checkflags '$@' '$(GOFLAGS)' '*** new Go flags ***' + +.PHONY: all clean FORCE From 3edd3227fe476d94516be1394598362f5c298dfb Mon Sep 17 00:00:00 2001 From: Christian Couder Date: Sat, 4 Apr 2015 12:45:20 +0200 Subject: [PATCH 3/5] test: add test_race target to Makefile This builds go binaries using the -race flag and then runs all the tests. License: MIT Signed-off-by: Christian Couder --- test/Makefile | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test/Makefile b/test/Makefile index 648b3a439..93a287a3f 100644 --- a/test/Makefile +++ b/test/Makefile @@ -45,6 +45,11 @@ test_cheap: cd sharness && make cd 3nodetest && make +test_race: + cd sharness && make GOFLAGS=-race TEST_EXPENSIVE=1 + cd 3nodetest && make GOFLAGS=-race + cd dependencies && make GOFLAGS=-race + IPFS-BUILD-OPTIONS: FORCE @bin/checkflags '$@' '$(GOFLAGS)' '*** new Go flags ***' From 61550d08be8b9a655abb351a022e67827a30af32 Mon Sep 17 00:00:00 2001 From: Christian Couder Date: Sat, 4 Apr 2015 12:47:57 +0200 Subject: [PATCH 4/5] test: add IPFS-BUILD-OPTIONS to .gitignore ...and remove bin/* stuff from the .gitignore as /test/bin is already in the root .gitignore. License: MIT Signed-off-by: Christian Couder --- test/.gitignore | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/test/.gitignore b/test/.gitignore index 4f89478ac..c857e9182 100644 --- a/test/.gitignore +++ b/test/.gitignore @@ -1,2 +1 @@ -bin/ipfs -bin/random +IPFS-BUILD-OPTIONS From dbf91a19a1e5a87d36c93fc2f8df7374dd42dfe1 Mon Sep 17 00:00:00 2001 From: Christian Couder Date: Sat, 4 Apr 2015 12:50:29 +0200 Subject: [PATCH 5/5] test/sharness: add GOFLAGS variable and race target The GOFLAGS variable makes it possible to run all sharness tests with go binaries built with some special flags. The "race" target makes it easy run the sharness tests with go binaries built with the -race flag. License: MIT Signed-off-by: Christian Couder --- test/sharness/Makefile | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/test/sharness/Makefile b/test/sharness/Makefile index 144262f98..1166df6bb 100644 --- a/test/sharness/Makefile +++ b/test/sharness/Makefile @@ -11,6 +11,9 @@ BINS = bin/random bin/multihash bin/ipfs bin/pollEndpoint SHARNESS = lib/sharness/sharness.sh IPFS_ROOT = ../.. +# User might want to override those on the command line +GOFLAGS = + all: clean deps $(T) aggregate clean: @@ -32,11 +35,13 @@ $(SHARNESS): @echo "*** installing $@ ***" lib/install-sharness.sh -bin/%: $(IPFS_ROOT)/**/*.go - @echo "*** installing $@ ***" - cd .. && make $@ +bin/%: FORCE + cd .. && make GOFLAGS=$(GOFLAGS) $@ -.PHONY: all clean $(T) aggregate +race: + make GOFLAGS=-race all + +.PHONY: all clean $(T) aggregate FORCE # will fail if curl is not installed. # TODO: get rid of this and install curl with git or ipfs.