diff options
author | Cherry Zhang <cherryyz@google.com> | 2018-02-14 19:35:03 -0500 |
---|---|---|
committer | Cherry Zhang <cherryyz@google.com> | 2018-03-01 21:11:16 +0000 |
commit | 2baed3856deb9b077cc9b604c8247865bd3adec0 (patch) | |
tree | 3f1781307a691d729d568d5aec218ba2ea96021d /test/run.go | |
parent | 213a75171df1c1fb0ae76fe7c8ff877b1fa9c0b9 (diff) | |
download | go-2baed3856deb9b077cc9b604c8247865bd3adec0.tar.gz go-2baed3856deb9b077cc9b604c8247865bd3adec0.zip |
cmd/asm: fix assembling return jump
In RET instruction, the operand is the return jump's target,
which should be put in Prog.To.
Add an action "buildrundir" to the test driver, which builds
(compile+assemble+link) the code in a directory and runs the
resulting binary.
Fixes #23838.
Change-Id: I7ebe7eda49024b40a69a24857322c5ca9c67babb
Reviewed-on: https://go-review.googlesource.com/94175
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
Diffstat (limited to 'test/run.go')
-rw-r--r-- | test/run.go | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/test/run.go b/test/run.go index fd53095ab4..a991c92462 100644 --- a/test/run.go +++ b/test/run.go @@ -488,7 +488,7 @@ func (t *test) run() { action = "rundir" case "cmpout": action = "run" // the run case already looks for <dir>/<test>.out files - case "compile", "compiledir", "build", "builddir", "run", "buildrun", "runoutput", "rundir", "asmcheck": + case "compile", "compiledir", "build", "builddir", "buildrundir", "run", "buildrun", "runoutput", "rundir", "asmcheck": // nothing to do case "errorcheckandrundir": wantError = false // should be no error if also will run @@ -735,7 +735,7 @@ func (t *test) run() { t.err = err } - case "builddir": + case "builddir", "buildrundir": // Build an executable from all the .go and .s files in a subdirectory. useTmp = true longdir := filepath.Join(cwd, t.goDirName()) @@ -788,12 +788,23 @@ func (t *test) run() { t.err = err break } - cmd = []string{"go", "tool", "link", "all.a"} + cmd = []string{"go", "tool", "link", "-o", "a.exe", "all.a"} _, err = runcmd(cmd...) if err != nil { t.err = err break } + if action == "buildrundir" { + cmd = append(findExecCmd(), filepath.Join(t.tempDir, "a.exe")) + out, err := runcmd(cmd...) + if err != nil { + t.err = err + break + } + if strings.Replace(string(out), "\r\n", "\n", -1) != t.expectedOutput() { + t.err = fmt.Errorf("incorrect output\n%s", out) + } + } case "buildrun": // build binary, then run binary, instead of go run. Useful for timeout tests where failure mode is infinite loop. // TODO: not supported on NaCl |