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:
Adam Langley 2013-03-08 10:09:40 -05:00
Родитель eccdd1285a
Коммит dc703e91d7
1 изменённых файлов: 5 добавлений и 16 удалений

Просмотреть файл

@ -14,7 +14,6 @@ import (
"io"
"strings"
"testing"
"time"
)
func TestRunCommandSuccess(t *testing.T) {
@ -154,22 +153,12 @@ func TestValidTerminalMode(t *testing.T) {
stdin.Write([]byte("stty -a && exit\n"))
rc := make(chan string)
go func() {
var buf bytes.Buffer
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):
var buf bytes.Buffer
if _, err := io.Copy(&buf, stdout); err != nil {
t.Fatalf("reading failed: %s", err)
}
if !strings.Contains(result, "-echo") {
t.Fatalf("terminal mode failure: expected '%s'", "-echo")
if sttyOutput := buf.String(); !strings.Contains(sttyOutput, "-echo ") {
t.Fatalf("terminal mode failure: expected -echo in stty output, got %s", sttyOutput)
}
}