ssh/test: deflake session test.
The session test previously had a one second timeout for the output of stty and this was leading to flakiness. This change removes the timeout since go test has a generic timeout mechanism. Additionally, the test was looking for "-echo" in the output to test the value of the echo flag. However, there are also typically "echoe", "echok" and "echonl" flags, and "-echo" could be a prefix of any of time. Thus we now also match a trailing space. R=golang-dev, rsc, extraterrestrial.neighbour CC=golang-dev https://golang.org/cl/7579043
This commit is contained in:
@@ -14,7 +14,6 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestRunCommandSuccess(t *testing.T) {
|
func TestRunCommandSuccess(t *testing.T) {
|
||||||
@@ -154,22 +153,12 @@ func TestValidTerminalMode(t *testing.T) {
|
|||||||
|
|
||||||
stdin.Write([]byte("stty -a && exit\n"))
|
stdin.Write([]byte("stty -a && exit\n"))
|
||||||
|
|
||||||
rc := make(chan string)
|
var buf bytes.Buffer
|
||||||
go func() {
|
if _, err := io.Copy(&buf, stdout); err != nil {
|
||||||
var buf bytes.Buffer
|
t.Fatalf("reading failed: %s", err)
|
||||||
if _, err := io.Copy(&buf, stdout); err != nil {
|
|
||||||
t.Fatalf("reading failed: %s", err)
|
|
||||||
}
|
|
||||||
rc <- buf.String()
|
|
||||||
}()
|
|
||||||
|
|
||||||
result := ""
|
|
||||||
select {
|
|
||||||
case result = <-rc:
|
|
||||||
case <-time.After(1 * time.Second):
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if !strings.Contains(result, "-echo") {
|
if sttyOutput := buf.String(); !strings.Contains(sttyOutput, "-echo ") {
|
||||||
t.Fatalf("terminal mode failure: expected '%s'", "-echo")
|
t.Fatalf("terminal mode failure: expected -echo in stty output, got %s", sttyOutput)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user