aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorElias Naur <elias.naur@gmail.com>2016-03-23 16:17:44 +0100
committerElias Naur <elias.naur@gmail.com>2016-03-24 14:14:03 +0000
commit0bb62299b0a37b68fa3bb40a0fe449858e162809 (patch)
tree25b6d488f322885fe48f46176d473809094f0287
parent5f08e480f447a7f197f41686bf672d39b10c3518 (diff)
downloadgo-0bb62299b0a37b68fa3bb40a0fe449858e162809.tar.xz
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/21072 Reviewed-by: David Crawshaw <crawshaw@golang.org>
-rw-r--r--misc/ios/go_darwin_arm_exec.go23
1 files changed, 18 insertions, 5 deletions
diff --git a/misc/ios/go_darwin_arm_exec.go b/misc/ios/go_darwin_arm_exec.go
index 0392b9c200..6420dd1d94 100644
--- a/misc/ios/go_darwin_arm_exec.go
+++ b/misc/ios/go_darwin_arm_exec.go
@@ -160,10 +160,18 @@ func run(bin string, args []string) (err error) {
}
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() {
if r := recover(); r != nil {
if w, ok := r.(waitPanic); ok {
err = w.err
+ if !started {
+ fmt.Printf("lldb setup error: %v\n", err)
+ err = errRetry
+ }
return
}
panic(r)
@@ -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
+ started = true
+
s.doCmd("run", "stop reason = breakpoint", 20*time.Second)
// Move the current working directory into the faux gopath.
@@ -261,6 +271,10 @@ func newSession(appdir string, args []string, opts options) (*lldbSession, error
exited: make(chan error),
}
+ iosdPath, err := exec.LookPath("ios-deploy")
+ if err != nil {
+ return nil, err
+ }
s.cmd = exec.Command(
// lldb tries to be clever with terminals.
// So we wrap it in script(1) and be clever
@@ -269,7 +283,7 @@ func newSession(appdir string, args []string, opts options) (*lldbSession, error
"-q", "-t", "0",
"/dev/null",
- "ios-deploy",
+ iosdPath,
"--debug",
"-u",
"-r",
@@ -313,9 +327,8 @@ func newSession(appdir string, args []string, opts options) (*lldbSession, error
i2 := s.out.LastIndex([]byte(" connect"))
return i0 > 0 && i1 > 0 && i2 > 0
}
- if err := s.wait("lldb start", cond, 5*time.Second); err != nil {
- fmt.Printf("lldb start error: %v\n", err)
- return nil, errRetry
+ if err := s.wait("lldb start", cond, 10*time.Second); err != nil {
+ panic(waitPanic{err})
}
return s, nil
}
@@ -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 {
- doTimeout := 1*time.Second + extraTimeout
+ doTimeout := 2*time.Second + extraTimeout
doTimedout := time.After(doTimeout)
for {
select {