Skip to content

Commit 0a55a16

Browse files
minuxrsc
authored andcommitted
cmd/objdump: enable tests on ppc64/ppc64le
Fixes #9039. Change-Id: I7d213b4f8e4cda73ea7687fb97dbd22e58163949 Reviewed-on: https://go-review.googlesource.com/9683 Run-TryBot: Russ Cox <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Russ Cox <[email protected]>
1 parent 94cf54e commit 0a55a16

File tree

1 file changed

+27
-3
lines changed

1 file changed

+27
-3
lines changed

src/cmd/objdump/objdump_test.go

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
package main
66

77
import (
8+
"flag"
89
"go/build"
910
"internal/testenv"
1011
"io/ioutil"
@@ -49,6 +50,16 @@ var armNeed = []string{
4950
"RET",
5051
}
5152

53+
var ppcNeed = []string{
54+
"fmthello.go:6",
55+
"TEXT main.main(SB)",
56+
"BR main.main(SB)",
57+
"BL fmt.Println(SB)",
58+
"RET",
59+
}
60+
61+
var target = flag.String("target", "", "test disassembly of `goos/goarch` binary")
62+
5263
// objdump is fully cross platform: it can handle binaries
5364
// from any known operating system and architecture.
5465
// We could in principle add binaries to testdata and check
@@ -62,6 +73,19 @@ func testDisasm(t *testing.T, flags ...string) {
6273
tmp, exe := buildObjdump(t)
6374
defer os.RemoveAll(tmp)
6475

76+
goarch := runtime.GOARCH
77+
if *target != "" {
78+
f := strings.Split(*target, "/")
79+
if len(f) != 2 {
80+
t.Fatalf("-target argument must be goos/goarch")
81+
}
82+
defer os.Setenv("GOOS", os.Getenv("GOOS"))
83+
defer os.Setenv("GOARCH", os.Getenv("GOARCH"))
84+
os.Setenv("GOOS", f[0])
85+
os.Setenv("GOARCH", f[1])
86+
goarch = f[1]
87+
}
88+
6589
hello := filepath.Join(tmp, "hello.exe")
6690
args := []string{"build", "-o", hello}
6791
args = append(args, flags...)
@@ -74,11 +98,13 @@ func testDisasm(t *testing.T, flags ...string) {
7498
"fmthello.go:6",
7599
"TEXT main.main(SB)",
76100
}
77-
switch runtime.GOARCH {
101+
switch goarch {
78102
case "amd64", "386":
79103
need = append(need, x86Need...)
80104
case "arm":
81105
need = append(need, armNeed...)
106+
case "ppc64", "ppc64le":
107+
need = append(need, ppcNeed...)
82108
}
83109

84110
out, err = exec.Command(exe, "-s", "main.main", hello).CombinedOutput()
@@ -101,8 +127,6 @@ func testDisasm(t *testing.T, flags ...string) {
101127

102128
func TestDisasm(t *testing.T) {
103129
switch runtime.GOARCH {
104-
case "ppc64", "ppc64le":
105-
t.Skipf("skipping on %s, issue 9039", runtime.GOARCH)
106130
case "arm64":
107131
t.Skipf("skipping on %s, issue 10106", runtime.GOARCH)
108132
case "mips64", "mips64le":

0 commit comments

Comments
 (0)