Commit 0bb62299 authored by Elias Naur's avatar Elias Naur

misc/ios: deflake tests on darwin/arm{,arm64}

A retry mechanism is in place to combat the inherent flakiness of
launching iOS test binaries. Before it covered just the starting of
lldb; expand it to cover the setup steps as well. Note that the
running of the binary itself is (still) not retried, to avoid
covering over genuine bugs.

On my test device (iPhone 5S, iOS 9.3) starting lldb can take longer
than 10 seconds, so increase the timeout for that.
Furthermore, some basic steps such as setting breakpoints in lldb
can take longer than the 1 second timeout. Increase that timeout
as well, to 2 seconds.

Finally, improve the error message for when ios-deploy is not
installed.

For #14318

Change-Id: Iba41d1bd9d023575b9454cb577b08f8cae081c2a
Reviewed-on: https://go-review.googlesource.com/21072Reviewed-by: default avatarDavid Crawshaw <crawshaw@golang.org>
parent 5f08e480
...@@ -160,10 +160,18 @@ func run(bin string, args []string) (err error) { ...@@ -160,10 +160,18 @@ func run(bin string, args []string) (err error) {
} }
defer os.Chdir(oldwd) defer os.Chdir(oldwd)
// Setting up lldb is flaky. The test binary itself runs when
// started is set to true. Everything before that is considered
// part of the setup and is retried.
started := false
defer func() { defer func() {
if r := recover(); r != nil { if r := recover(); r != nil {
if w, ok := r.(waitPanic); ok { if w, ok := r.(waitPanic); ok {
err = w.err err = w.err
if !started {
fmt.Printf("lldb setup error: %v\n", err)
err = errRetry
}
return return
} }
panic(r) panic(r)
...@@ -210,6 +218,8 @@ func run(bin string, args []string) (err error) { ...@@ -210,6 +218,8 @@ func run(bin string, args []string) (err error) {
s.do(`breakpoint set -n getwd`) // in runtime/cgo/gcc_darwin_arm.go s.do(`breakpoint set -n getwd`) // in runtime/cgo/gcc_darwin_arm.go
started = true
s.doCmd("run", "stop reason = breakpoint", 20*time.Second) s.doCmd("run", "stop reason = breakpoint", 20*time.Second)
// Move the current working directory into the faux gopath. // Move the current working directory into the faux gopath.
...@@ -261,6 +271,10 @@ func newSession(appdir string, args []string, opts options) (*lldbSession, error ...@@ -261,6 +271,10 @@ func newSession(appdir string, args []string, opts options) (*lldbSession, error
exited: make(chan error), exited: make(chan error),
} }
iosdPath, err := exec.LookPath("ios-deploy")
if err != nil {
return nil, err
}
s.cmd = exec.Command( s.cmd = exec.Command(
// lldb tries to be clever with terminals. // lldb tries to be clever with terminals.
// So we wrap it in script(1) and be clever // So we wrap it in script(1) and be clever
...@@ -269,7 +283,7 @@ func newSession(appdir string, args []string, opts options) (*lldbSession, error ...@@ -269,7 +283,7 @@ func newSession(appdir string, args []string, opts options) (*lldbSession, error
"-q", "-t", "0", "-q", "-t", "0",
"/dev/null", "/dev/null",
"ios-deploy", iosdPath,
"--debug", "--debug",
"-u", "-u",
"-r", "-r",
...@@ -313,9 +327,8 @@ func newSession(appdir string, args []string, opts options) (*lldbSession, error ...@@ -313,9 +327,8 @@ func newSession(appdir string, args []string, opts options) (*lldbSession, error
i2 := s.out.LastIndex([]byte(" connect")) i2 := s.out.LastIndex([]byte(" connect"))
return i0 > 0 && i1 > 0 && i2 > 0 return i0 > 0 && i1 > 0 && i2 > 0
} }
if err := s.wait("lldb start", cond, 5*time.Second); err != nil { if err := s.wait("lldb start", cond, 10*time.Second); err != nil {
fmt.Printf("lldb start error: %v\n", err) panic(waitPanic{err})
return nil, errRetry
} }
return s, nil return s, nil
} }
...@@ -335,7 +348,7 @@ func (s *lldbSession) doCmd(cmd string, waitFor string, extraTimeout time.Durati ...@@ -335,7 +348,7 @@ func (s *lldbSession) doCmd(cmd string, waitFor string, extraTimeout time.Durati
} }
func (s *lldbSession) wait(reason string, cond func(out *buf) bool, extraTimeout time.Duration) error { func (s *lldbSession) wait(reason string, cond func(out *buf) bool, extraTimeout time.Duration) error {
doTimeout := 1*time.Second + extraTimeout doTimeout := 2*time.Second + extraTimeout
doTimedout := time.After(doTimeout) doTimedout := time.After(doTimeout)
for { for {
select { select {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment