aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Crawshaw <crawshaw@golang.org>2017-01-13 07:18:40 -0500
committerDavid Crawshaw <crawshaw@golang.org>2017-01-13 20:08:06 +0000
commit593ea3b3606a16da39e38406e22e373eeb944287 (patch)
tree39beab9f5fc19c77e42ee717c0e08a92485217ee
parent0642b8a2f1837901f31066b679173e89325b6be3 (diff)
downloadgo-593ea3b3606a16da39e38406e22e373eeb944287.tar.gz
go-593ea3b3606a16da39e38406e22e373eeb944287.zip
cmd/go, misc: rework cwd handling for iOS tests
Another change in behvaior (bug) in LLDB. Despite the fact that LLDB can dump the symtab of our test binaries and show the function addresses, it can no longer call the functions. This means the chdir trick on signal is failing. This CL uses a new trick. For iOS, the exec script passes the change in directory as an argument, and it is processed early by the test harness generated by cmd/go. For the iOS builders. Change-Id: I8f5d0f831fe18de99f097761f89c5184d5bf2afb Reviewed-on: https://go-review.googlesource.com/35152 Reviewed-by: Elias Naur <elias.naur@gmail.com> Run-TryBot: David Crawshaw <crawshaw@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
-rw-r--r--misc/ios/go_darwin_arm_exec.go14
-rw-r--r--src/cmd/go/test.go22
2 files changed, 24 insertions, 12 deletions
diff --git a/misc/ios/go_darwin_arm_exec.go b/misc/ios/go_darwin_arm_exec.go
index 2a06528c1b..8bedc5dd95 100644
--- a/misc/ios/go_darwin_arm_exec.go
+++ b/misc/ios/go_darwin_arm_exec.go
@@ -204,6 +204,11 @@ func run(bin string, args []string) (err error) {
var opts options
opts, args = parseArgs(args)
+ // Pass the suffix for the current working directory as the
+ // first argument to the test. For iOS, cmd/go generates
+ // special handling of this argument.
+ args = append([]string{"cwdSuffix=" + pkgpath}, args...)
+
// ios-deploy invokes lldb to give us a shell session with the app.
s, err := newSession(appdir, args, opts)
if err != nil {
@@ -241,15 +246,6 @@ func run(bin string, args []string) (err error) {
s.doCmd("run", "stop reason = signal SIGUSR2", 20*time.Second)
- // Move the current working directory into the faux gopath.
- if pkgpath != "src" {
- s.do(`breakpoint delete 1`)
- s.do(`expr char* $mem = (char*)malloc(512)`)
- s.do(`expr $mem = (char*)getwd($mem, 512)`)
- s.do(`expr $mem = (char*)strcat($mem, "/` + pkgpath + `")`)
- s.do(`call (void)chdir($mem)`)
- }
-
startTestsLen := s.out.Len()
fmt.Fprintln(s.in, `process continue`)
diff --git a/src/cmd/go/test.go b/src/cmd/go/test.go
index f477a4a253..6482f0fd32 100644
--- a/src/cmd/go/test.go
+++ b/src/cmd/go/test.go
@@ -1532,12 +1532,28 @@ func coverRegisterFile(fileName string, counter []uint32, pos []uint32, numStmts
func main() {
{{if .IsIOS}}
// Send a SIGUSR2, which will be intercepted by LLDB to
- // tell the test harness that installation was successful,
- // and to give the exec script a chance set the current
- // working directory. See misc/ios/go_darwin_arm_exec.go.
+ // tell the test harness that installation was successful.
+ // See misc/ios/go_darwin_arm_exec.go.
signal.Notify(make(chan os.Signal), syscall.SIGUSR2)
syscall.Kill(0, syscall.SIGUSR2)
signal.Reset(syscall.SIGUSR2)
+
+ // The first argument supplied to an iOS test is an offset
+ // suffix for the current working directory.
+ // Process it here, and remove it from os.Args.
+ const hdr = "cwdSuffix="
+ if len(os.Args) < 2 || len(os.Args[1]) <= len(hdr) || os.Args[1][:len(hdr)] != hdr {
+ panic("iOS test not passed a working directory suffix")
+ }
+ suffix := os.Args[1][len(hdr):]
+ dir, err := os.Getwd()
+ if err != nil {
+ panic(err)
+ }
+ if err := os.Chdir(dir + "/" + suffix); err != nil {
+ panic(err)
+ }
+ os.Args = append([]string{os.Args[0]}, os.Args[2:]...)
{{end}}
{{if .CoverEnabled}}