Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

expose a map, not a slice, of muxer tests #41

Merged
merged 1 commit into from
Dec 10, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 13 additions & 7 deletions suites/mux/muxer_suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,23 @@ import (
)

var randomness []byte
var Subtests map[string]TransportTest

func init() {
// read 1MB of randomness
randomness = make([]byte, 1<<20)
if _, err := crand.Read(randomness); err != nil {
panic(err)
}

Subtests = make(map[string]TransportTest)
for _, f := range subtests {
Subtests[getFunctionName(f)] = f
}
}

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

type Options struct {
Expand Down Expand Up @@ -542,7 +552,7 @@ func SubtestStress1Conn100Stream100Msg10MB(t *testing.T, tr mux.Multiplexer) {
}

// Subtests are all the subtests run by SubtestAll
var Subtests = []TransportTest{
var subtests = []TransportTest{
SubtestSimpleWrite,
SubtestWriteAfterClose,
SubtestStress1Conn1Stream1Msg,
Expand All @@ -555,15 +565,11 @@ var Subtests = []TransportTest{
SubtestStreamReset,
}

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

// SubtestAll runs all the stream multiplexer tests against the target
// transport.
func SubtestAll(t *testing.T, tr mux.Multiplexer) {
for _, f := range Subtests {
t.Run(getFunctionName(f), func(t *testing.T) {
for name, f := range Subtests {
t.Run(name, func(t *testing.T) {
f(t, tr)
})
}
Expand Down