mirror of
https://github.com/golang/go
synced 2024-11-15 11:10:22 -07:00
[release-branch.go1] debug/gosym: in test, use temp binary name in /tmp, and clean up.
««« backport 5e1544310d03 debug/gosym: in test, use temp binary name in /tmp, and clean up. This fixes all.bash on shared machines. R=golang-dev, rsc CC=golang-dev https://golang.org/cl/5992078 »»»
This commit is contained in:
parent
763858faca
commit
8ac275bb01
@ -7,14 +7,19 @@ package gosym
|
|||||||
import (
|
import (
|
||||||
"debug/elf"
|
"debug/elf"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
"path/filepath"
|
||||||
"runtime"
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
var pclinetestBinary string
|
var (
|
||||||
|
pclineTempDir string
|
||||||
|
pclinetestBinary string
|
||||||
|
)
|
||||||
|
|
||||||
func dotest() bool {
|
func dotest() bool {
|
||||||
// For now, only works on ELF platforms.
|
// For now, only works on ELF platforms.
|
||||||
@ -24,10 +29,18 @@ func dotest() bool {
|
|||||||
if pclinetestBinary != "" {
|
if pclinetestBinary != "" {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
var err error
|
||||||
|
pclineTempDir, err = ioutil.TempDir("", "pclinetest")
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
if strings.Contains(pclineTempDir, " ") {
|
||||||
|
panic("unexpected space in tempdir")
|
||||||
|
}
|
||||||
// This command builds pclinetest from pclinetest.asm;
|
// This command builds pclinetest from pclinetest.asm;
|
||||||
// the resulting binary looks like it was built from pclinetest.s,
|
// the resulting binary looks like it was built from pclinetest.s,
|
||||||
// but we have renamed it to keep it away from the go tool.
|
// but we have renamed it to keep it away from the go tool.
|
||||||
pclinetestBinary = os.TempDir() + "/pclinetest"
|
pclinetestBinary = filepath.Join(pclineTempDir, "pclinetest")
|
||||||
command := fmt.Sprintf("go tool 6a -o %s.6 pclinetest.asm && go tool 6l -E main -o %s %s.6",
|
command := fmt.Sprintf("go tool 6a -o %s.6 pclinetest.asm && go tool 6l -E main -o %s %s.6",
|
||||||
pclinetestBinary, pclinetestBinary, pclinetestBinary)
|
pclinetestBinary, pclinetestBinary, pclinetestBinary)
|
||||||
cmd := exec.Command("sh", "-c", command)
|
cmd := exec.Command("sh", "-c", command)
|
||||||
@ -170,6 +183,7 @@ func TestPCLine(t *testing.T) {
|
|||||||
if !dotest() {
|
if !dotest() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
defer os.RemoveAll(pclineTempDir)
|
||||||
|
|
||||||
f, tab := crack(pclinetestBinary, t)
|
f, tab := crack(pclinetestBinary, t)
|
||||||
text := f.Section(".text")
|
text := f.Section(".text")
|
||||||
|
Loading…
Reference in New Issue
Block a user