Run basic tests with race detector
This commit is contained in:
parent
b10960bfd6
commit
2766c65c13
|
@ -7,8 +7,6 @@ go:
|
|||
- 1.12.x
|
||||
|
||||
env:
|
||||
global:
|
||||
# - GOTFLAGS="-race"
|
||||
matrix:
|
||||
- BUILD_DEPTYPE=gomod
|
||||
|
||||
|
@ -16,8 +14,10 @@ env:
|
|||
install:
|
||||
- true
|
||||
|
||||
# run tests with and without race detection
|
||||
script:
|
||||
- bash <(curl -s https://raw.githubusercontent.com/ipfs/ci-helpers/master/travis-ci/run-standard-tests.sh)
|
||||
- GOTFLAGS="-race" bash <(curl -s https://raw.githubusercontent.com/ipfs/ci-helpers/master/travis-ci/run-standard-tests.sh)
|
||||
|
||||
cache:
|
||||
directories:
|
||||
|
|
1
go.mod
1
go.mod
|
@ -4,6 +4,7 @@ go 1.12
|
|||
|
||||
require (
|
||||
github.com/ipfs/go-log v0.0.1
|
||||
github.com/jbenet/go-detect-race v0.0.0-20150302022421-3463798d9574
|
||||
github.com/libp2p/go-libp2p-crypto v0.0.1
|
||||
github.com/libp2p/go-libp2p-peer v0.1.0
|
||||
github.com/libp2p/go-libp2p-transport v0.0.5-0.20190506231221-045097a6a962
|
||||
|
|
2
go.sum
2
go.sum
|
@ -46,6 +46,8 @@ github.com/ipfs/go-ds-leveldb v0.0.1/go.mod h1:feO8V3kubwsEF22n0YRQCffeb79OOYIyk
|
|||
github.com/ipfs/go-ipfs-delay v0.0.0-20181109222059-70721b86a9a8/go.mod h1:8SP1YXK1M1kXuc4KJZINY3TQQ03J2rwBG9QfXmbRPrw=
|
||||
github.com/ipfs/go-log v0.0.1 h1:9XTUN/rW64BCG1YhPK9Hoy3q8nr4gOmHHBpgFdfw6Lc=
|
||||
github.com/ipfs/go-log v0.0.1/go.mod h1:kL1d2/hzSpI0thNYjiKfjanbVNU+IIGA/WnNESY9leM=
|
||||
github.com/jbenet/go-detect-race v0.0.0-20150302022421-3463798d9574 h1:Pxjl8Wn3cCU7nB/MCmPEUMbjMHxXFqODW6rce0jpxB4=
|
||||
github.com/jbenet/go-detect-race v0.0.0-20150302022421-3463798d9574/go.mod h1:gynVu6LUw+xMXD3XEvjHQcIbJkWEamnGjJDebRHqTd0=
|
||||
github.com/jbenet/goprocess v0.0.0-20160826012719-b497e2f366b8 h1:bspPhN+oKYFk5fcGNuQzp6IGzYQSenLEgH3s6jkXrWw=
|
||||
github.com/jbenet/goprocess v0.0.0-20160826012719-b497e2f366b8/go.mod h1:Ly/wlsjFq/qrU3Rar62tu1gASgGw6chQbSh/XgIIXCY=
|
||||
github.com/jessevdk/go-flags v0.0.0-20141203071132-1679536dcc89/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI=
|
||||
|
|
|
@ -5,6 +5,7 @@ import (
|
|||
"runtime"
|
||||
"testing"
|
||||
|
||||
detectrace "github.com/jbenet/go-detect-race"
|
||||
peer "github.com/libp2p/go-libp2p-peer"
|
||||
tpt "github.com/libp2p/go-libp2p-transport"
|
||||
utils "github.com/libp2p/go-libp2p-transport/test"
|
||||
|
@ -15,7 +16,15 @@ import (
|
|||
// in order to disable some tests while we investigate performance issues when
|
||||
// running the tests on resource restricted environments like the Travis CI.
|
||||
|
||||
var Subtests = []func(t *testing.T, ta, tb tpt.Transport, maddr ma.Multiaddr, peerA peer.ID){
|
||||
func getFunctionName(i interface{}) string {
|
||||
return runtime.FuncForPC(reflect.ValueOf(i).Pointer()).Name()
|
||||
}
|
||||
|
||||
func SubtestTransport(t *testing.T, ta, tb tpt.Transport, addr string, peerA peer.ID) {
|
||||
subtests := []func(t *testing.T, ta, tb tpt.Transport, maddr ma.Multiaddr, peerA peer.ID){}
|
||||
|
||||
if detectrace.WithRace() {
|
||||
subtests = []func(t *testing.T, ta, tb tpt.Transport, maddr ma.Multiaddr, peerA peer.ID){
|
||||
utils.SubtestProtocols,
|
||||
utils.SubtestBasic,
|
||||
|
||||
|
@ -24,6 +33,9 @@ var Subtests = []func(t *testing.T, ta, tb tpt.Transport, maddr ma.Multiaddr, pe
|
|||
|
||||
// Stolen from the stream muxer test suite.
|
||||
utils.SubtestStress1Conn1Stream1Msg,
|
||||
}
|
||||
} else {
|
||||
subtests = []func(t *testing.T, ta, tb tpt.Transport, maddr ma.Multiaddr, peerA peer.ID){
|
||||
utils.SubtestStress1Conn1Stream100Msg,
|
||||
utils.SubtestStress1Conn100Stream100Msg,
|
||||
utils.SubtestStress50Conn10Stream50Msg,
|
||||
|
@ -32,17 +44,13 @@ var Subtests = []func(t *testing.T, ta, tb tpt.Transport, maddr ma.Multiaddr, pe
|
|||
utils.SubtestStreamOpenStress,
|
||||
utils.SubtestStreamReset,
|
||||
}
|
||||
|
||||
func getFunctionName(i interface{}) string {
|
||||
return runtime.FuncForPC(reflect.ValueOf(i).Pointer()).Name()
|
||||
}
|
||||
|
||||
func SubtestTransport(t *testing.T, ta, tb tpt.Transport, addr string, peerA peer.ID) {
|
||||
maddr, err := ma.NewMultiaddr(addr)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
for _, f := range Subtests {
|
||||
for _, f := range subtests {
|
||||
t.Run(getFunctionName(f), func(t *testing.T) {
|
||||
f(t, ta, tb, maddr, peerA)
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue