[amber] Make ota test work with different shells
It's possible to build fuchsia with a different shell, that may produce
different error messages statting a file. This makes the tests more
reliable to different error strings.
Test: Manually verified it worked with other shells
Change-Id: Idab7f54d497b7933af7ee26f12bbcb11402b9b13
diff --git a/go/src/amber/tests/ota/system_ota.go b/go/src/amber/tests/ota/system_ota.go
index 5178bbc..3808efd 100644
--- a/go/src/amber/tests/ota/system_ota.go
+++ b/go/src/amber/tests/ota/system_ota.go
@@ -17,6 +17,7 @@
"os"
"os/exec"
"path/filepath"
+ "regexp"
"strings"
"testing"
"time"
@@ -34,7 +35,7 @@
deviceHostname = flag.String("device-hostname", "", "device hostname")
localDevmgr []byte
- noSuchFile = []byte(": No such file or directory\n")
+ noSuchFile = regexp.MustCompile("(:No such file or directory$)|(^error: cannot stat )")
)
const (
@@ -168,7 +169,7 @@
return true
}
- if !bytes.HasSuffix(stderr, noSuchFile) {
+ if !noSuchFile.Match(stderr) {
t.Fatalf("error reading %q: %s", path, stderr)
}
@@ -218,11 +219,10 @@
func ssh(arg ...string) ([]byte, []byte, error) {
var a []string
+ a = append(a, "-o", "LogLevel=quiet", "-o", "StrictHostKeyChecking=no", "-o", "UserKnownHostsFile=/dev/null")
if *sshConfig == "" {
- a = make([]string, 0, len(arg)+1)
a = append(append(a, *deviceHostname), arg...)
} else {
- a = make([]string, 0, len(arg)+3)
a = append(append(a, "-F", *sshConfig, *deviceHostname), arg...)
}