aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBryan C. Mills <bcmills@google.com>2023-04-17 12:30:28 -0400
committerGopher Robot <gobot@golang.org>2023-04-17 17:20:41 +0000
commit7d6d3f5d4adbee52131e89d4465c8cdf88d80aad (patch)
tree09bd4b1f370a798c76fe2eea8272886eabb2f974
parent1faeef9713563c936e077b84e4c3a0f3cac0fbe4 (diff)
downloadgo-x-crypto-7d6d3f5d4adbee52131e89d4465c8cdf88d80aad.tar.xz
ssh/test: skip TestValidTerminalMode on non-Bourne shells
Fixes golang/go#38037. Change-Id: Ide77dddc9f57b3f0318a419a1474e11215623b64 Reviewed-on: https://go-review.googlesource.com/c/crypto/+/485175 Run-TryBot: Bryan Mills <bcmills@google.com> Commit-Queue: Bryan Mills <bcmills@google.com> Auto-Submit: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Roland Shoemaker <roland@golang.org>
-rw-r--r--ssh/test/session_test.go26
1 files changed, 22 insertions, 4 deletions
diff --git a/ssh/test/session_test.go b/ssh/test/session_test.go
index d66509b..f88c3b7 100644
--- a/ssh/test/session_test.go
+++ b/ssh/test/session_test.go
@@ -14,6 +14,8 @@ import (
"errors"
"fmt"
"io"
+ "path/filepath"
+ "regexp"
"runtime"
"strings"
"testing"
@@ -255,15 +257,31 @@ func TestValidTerminalMode(t *testing.T) {
t.Fatalf("session failed: %s", err)
}
- stdin.Write([]byte("stty -a && exit\n"))
+ if _, err := io.WriteString(stdin, "echo SHELL $SHELL && stty -a && exit\n"); err != nil {
+ t.Fatal(err)
+ }
- var buf bytes.Buffer
- if _, err := io.Copy(&buf, stdout); err != nil {
+ buf := new(strings.Builder)
+ if _, err := io.Copy(buf, stdout); err != nil {
t.Fatalf("reading failed: %s", err)
}
+ if testing.Verbose() {
+ t.Logf("echo SHELL $SHELL && stty -a && exit:\n%s", buf)
+ }
+
+ shellLine := regexp.MustCompile("(?m)^SHELL (.*)$").FindStringSubmatch(buf.String())
+ if len(shellLine) != 2 {
+ t.Fatalf("missing output from echo SHELL $SHELL")
+ }
+ switch shell := filepath.Base(strings.TrimSpace(shellLine[1])); shell {
+ case "sh", "bash":
+ default:
+ t.Skipf("skipping test on non-Bourne shell %q", shell)
+ }
+
if sttyOutput := buf.String(); !strings.Contains(sttyOutput, "-echo ") {
- t.Fatalf("terminal mode failure: expected -echo in stty output, got %s", sttyOutput)
+ t.Fatal("terminal mode failure: expected -echo in stty output")
}
}