device: print direction when ping transit fails
Signed-off-by: Josh Bleecher Snyder <josh@tailscale.com>
This commit is contained in:
parent
15810daa22
commit
af408eb940
|
@ -8,7 +8,6 @@ package device
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"errors"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
|
@ -103,6 +102,13 @@ const (
|
||||||
Pong SendDirection = false
|
Pong SendDirection = false
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func (d SendDirection) String() string {
|
||||||
|
if d == Ping {
|
||||||
|
return "ping"
|
||||||
|
}
|
||||||
|
return "pong"
|
||||||
|
}
|
||||||
|
|
||||||
func (pair *testPair) Send(tb testing.TB, ping SendDirection, done chan struct{}) {
|
func (pair *testPair) Send(tb testing.TB, ping SendDirection, done chan struct{}) {
|
||||||
tb.Helper()
|
tb.Helper()
|
||||||
p0, p1 := pair[0], pair[1]
|
p0, p1 := pair[0], pair[1]
|
||||||
|
@ -118,10 +124,10 @@ func (pair *testPair) Send(tb testing.TB, ping SendDirection, done chan struct{}
|
||||||
select {
|
select {
|
||||||
case msgRecv := <-p0.tun.Inbound:
|
case msgRecv := <-p0.tun.Inbound:
|
||||||
if !bytes.Equal(msg, msgRecv) {
|
if !bytes.Equal(msg, msgRecv) {
|
||||||
err = errors.New("ping did not transit correctly")
|
err = fmt.Errorf("%s did not transit correctly", ping)
|
||||||
}
|
}
|
||||||
case <-timer.C:
|
case <-timer.C:
|
||||||
err = errors.New("ping did not transit")
|
err = fmt.Errorf("%s did not transit", ping)
|
||||||
case <-done:
|
case <-done:
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in a new issue