Skip to content
This repository has been archived by the owner on Dec 7, 2019. It is now read-only.

Commit

Permalink
improve the subtest infrastructure
Browse files Browse the repository at this point in the history
* document
* use test.Run to run the subtests
* don't export functions we don't need to export
  • Loading branch information
Stebalien committed Jun 11, 2018
1 parent 091ae62 commit 0b77558
Showing 1 changed file with 24 additions and 24 deletions.
48 changes: 24 additions & 24 deletions test/ttest.go
Original file line number Diff line number Diff line change
Expand Up @@ -508,33 +508,33 @@ func SubtestStress1Conn100Stream100Msg10MB(t *testing.T, tr smux.Transport) {
})
}

func SubtestAll(t *testing.T, tr smux.Transport) {
// Subtests are all the subtests run by SubtestAll
var Subtests = []TransportTest{
SubtestSimpleWrite,
SubtestWriteAfterClose,
SubtestStress1Conn1Stream1Msg,
SubtestStress1Conn1Stream100Msg,
SubtestStress1Conn100Stream100Msg,
SubtestStress50Conn10Stream50Msg,
SubtestStress1Conn1000Stream10Msg,
SubtestStress1Conn100Stream100Msg10MB,
SubtestStreamOpenStress,
SubtestStreamReset,
}

tests := []TransportTest{
SubtestSimpleWrite,
SubtestWriteAfterClose,
SubtestStress1Conn1Stream1Msg,
SubtestStress1Conn1Stream100Msg,
SubtestStress1Conn100Stream100Msg,
SubtestStress50Conn10Stream50Msg,
SubtestStress1Conn1000Stream10Msg,
SubtestStress1Conn100Stream100Msg10MB,
SubtestStreamOpenStress,
SubtestStreamReset,
}
func getFunctionName(i interface{}) string {
return runtime.FuncForPC(reflect.ValueOf(i).Pointer()).Name()
}

for _, f := range tests {
if testing.Verbose() {
fmt.Fprintf(os.Stderr, "==== RUN %s\n", GetFunctionName(f))
}
f(t, tr)
// SubtestAll runs all the stream multiplexer tests against the target
// transport.
func SubtestAll(t *testing.T, tr smux.Transport) {
for _, f := range Subtests {
t.Run(getFunctionName(f), func(t *testing.T) {
f(t, tr)
})
}
}

// TransportTest is a stream multiplex transport test case
type TransportTest func(t *testing.T, tr smux.Transport)

func TestNoOp(t *testing.T) {}

func GetFunctionName(i interface{}) string {
return runtime.FuncForPC(reflect.ValueOf(i).Pointer()).Name()
}

0 comments on commit 0b77558

Please sign in to comment.