arm, x86: port minor fixes from main repo
The most important change is exporting plan9Syntax as GoSyntax
for use by cmd/objdump.
Also make tests more forgiving of not having the necessary
binaries for external tests: skip the test rather than failing it.
Change-Id: I30aaa614618d370b1002e4247905cd982c5f5175
Reviewed-on: https://go-review.googlesource.com/13974
Reviewed-by: Ian Lance Taylor <iant@golang.org>
diff --git a/arm/armasm/decode_test.go b/arm/armasm/decode_test.go
index 3d9da07..e2d9127 100644
--- a/arm/armasm/decode_test.go
+++ b/arm/armasm/decode_test.go
@@ -55,8 +55,8 @@
switch syntax {
case "gnu":
out = GNUSyntax(inst)
- case "plan9":
- out = plan9Syntax(inst, 0, nil, nil)
+ case "plan9": // [sic]
+ out = GoSyntax(inst, 0, nil, nil)
default:
t.Errorf("unknown syntax %q", syntax)
continue
diff --git a/arm/armasm/ext_test.go b/arm/armasm/ext_test.go
index d824f0a..98192b3 100644
--- a/arm/armasm/ext_test.go
+++ b/arm/armasm/ext_test.go
@@ -178,7 +178,7 @@
t.Logf("%d test cases, %d expected mismatches, %d failures; %.0f cases/second", totalTests, totalSkips, totalErrors, float64(totalTests)/time.Since(start).Seconds())
if err := <-errc; err != nil {
- t.Fatal("external disassembler: %v", err)
+ t.Fatalf("external disassembler: %v", err)
}
}
@@ -216,7 +216,7 @@
var zeros = []byte{0, 0, 0, 0}
-// pad pads the code sequenc with pops.
+// pad pads the code sequence with pops.
func pad(enc []byte) []byte {
if len(enc) < 4 {
enc = append(enc[:len(enc):len(enc)], zeros[:4-len(enc)]...)
@@ -247,8 +247,8 @@
// text = ARMSyntax(inst)
case "gnu":
text = GNUSyntax(inst)
- //case "plan9":
- // text = plan9Syntax(inst, 0, nil)
+ //case "plan9": // [sic]
+ // text = GoSyntax(inst, 0, nil)
default:
text = "error: unknown syntax " + syntax
}
diff --git a/arm/armasm/objdumpext_test.go b/arm/armasm/objdumpext_test.go
index 52497a5..74fb47d 100644
--- a/arm/armasm/objdumpext_test.go
+++ b/arm/armasm/objdumpext_test.go
@@ -26,10 +26,10 @@
}
func testObjdumpArch(t *testing.T, generate func(func([]byte)), arch Mode) {
+ if testing.Short() {
+ t.Skip("skipping objdump test in short mode")
+ }
if _, err := os.Stat(objdumpPath); err != nil {
- if !testing.Short() {
- t.Fatal(err)
- }
t.Skip(err)
}
diff --git a/arm/armasm/plan9x.go b/arm/armasm/plan9x.go
index 73173fd..fae0ca6 100644
--- a/arm/armasm/plan9x.go
+++ b/arm/armasm/plan9x.go
@@ -12,7 +12,7 @@
"strings"
)
-// plan9Syntax returns the Go assembler syntax for the instruction.
+// GoSyntax returns the Go assembler syntax for the instruction.
// The syntax was originally defined by Plan 9.
// The pc is the program counter of the instruction, used for expanding
// PC-relative addresses into absolute ones.
@@ -21,7 +21,7 @@
// address of the symbol containing the target, if any; otherwise it returns "", 0.
// The reader r should read from the text segment using text addresses
// as offsets; it is used to display pc-relative loads as constant loads.
-func plan9Syntax(inst Inst, pc uint64, symname func(uint64) (string, uint64), text io.ReaderAt) string {
+func GoSyntax(inst Inst, pc uint64, symname func(uint64) (string, uint64), text io.ReaderAt) string {
if symname == nil {
symname = func(uint64) (string, uint64) { return "", 0 }
}
diff --git a/x86/x86asm/decode_test.go b/x86/x86asm/decode_test.go
index 7db2460..b6098b8 100644
--- a/x86/x86asm/decode_test.go
+++ b/x86/x86asm/decode_test.go
@@ -57,8 +57,8 @@
out = GNUSyntax(inst)
case "intel":
out = IntelSyntax(inst)
- case "plan9":
- out = plan9Syntax(inst, 0, nil)
+ case "plan9": // [sic]
+ out = GoSyntax(inst, 0, nil)
default:
t.Errorf("unknown syntax %q", syntax)
continue
diff --git a/x86/x86asm/ext_test.go b/x86/x86asm/ext_test.go
index 8c1e00e..eadfd71 100644
--- a/x86/x86asm/ext_test.go
+++ b/x86/x86asm/ext_test.go
@@ -177,9 +177,8 @@
t.Logf("%d test cases, %d expected mismatches, %d failures; %.0f cases/second", totalTests, totalSkips, totalErrors, float64(totalTests)/time.Since(start).Seconds())
if err := <-errc; err != nil {
- t.Fatal("external disassembler: %v", err)
+ t.Fatalf("external disassembler: %v", err)
}
-
}
const start = 0x8000 // start address of text
@@ -225,7 +224,7 @@
0x5f, 0x5f, 0x5f, 0x5f, 0x5f, 0x5f, 0x5f, 0x5f,
}
-// pad pads the code sequenc with pops.
+// pad pads the code sequence with pops.
func pad(enc []byte) []byte {
return append(enc[:len(enc):len(enc)], pops...)
}
@@ -252,8 +251,8 @@
text = GNUSyntax(inst)
case "intel":
text = IntelSyntax(inst)
- case "plan9":
- text = plan9Syntax(inst, 0, nil)
+ case "plan9": // [sic]
+ text = GoSyntax(inst, 0, nil)
default:
text = "error: unknown syntax " + syntax
}
diff --git a/x86/x86asm/objdumpext_test.go b/x86/x86asm/objdumpext_test.go
index 37a5513..f720dc6 100644
--- a/x86/x86asm/objdumpext_test.go
+++ b/x86/x86asm/objdumpext_test.go
@@ -32,9 +32,8 @@
if testing.Short() {
t.Skip("skipping objdump test in short mode")
}
-
if _, err := os.Stat(objdumpPath); err != nil {
- t.Fatal(err)
+ t.Skip(err)
}
testExtDis(t, "gnu", arch, objdump, generate, allowedMismatchObjdump)
diff --git a/x86/x86asm/plan9ext_test.go b/x86/x86asm/plan9ext_test.go
index 21f5bfd..9bd296c 100644
--- a/x86/x86asm/plan9ext_test.go
+++ b/x86/x86asm/plan9ext_test.go
@@ -20,9 +20,8 @@
if testing.Short() {
t.Skip("skipping libmach test in short mode")
}
-
if _, err := os.Stat(plan9Path); err != nil {
- t.Fatal(err)
+ t.Skip(err)
}
testExtDis(t, "plan9", arch, plan9, generate, allowedMismatchPlan9)
diff --git a/x86/x86asm/plan9x.go b/x86/x86asm/plan9x.go
index ccbdea4..afe6a92 100644
--- a/x86/x86asm/plan9x.go
+++ b/x86/x86asm/plan9x.go
@@ -9,14 +9,14 @@
"strings"
)
-// plan9Syntax returns the Go assembler syntax for the instruction.
+// GoSyntax returns the Go assembler syntax for the instruction.
// The syntax was originally defined by Plan 9.
// The pc is the program counter of the instruction, used for expanding
// PC-relative addresses into absolute ones.
// The symname function queries the symbol table for the program
// being disassembled. Given a target address it returns the name and base
// address of the symbol containing the target, if any; otherwise it returns "", 0.
-func plan9Syntax(inst Inst, pc uint64, symname func(uint64) (string, uint64)) string {
+func GoSyntax(inst Inst, pc uint64, symname func(uint64) (string, uint64)) string {
if symname == nil {
symname = func(uint64) (string, uint64) { return "", 0 }
}
diff --git a/x86/x86asm/xedext_test.go b/x86/x86asm/xedext_test.go
index d7aa8e3..e27cdc0 100644
--- a/x86/x86asm/xedext_test.go
+++ b/x86/x86asm/xedext_test.go
@@ -16,11 +16,10 @@
func testXedArch(t *testing.T, arch int, generate func(func([]byte))) {
if testing.Short() {
- t.Skip("skipping libmach test in short mode")
+ t.Skip("skipping xed test in short mode")
}
-
if _, err := os.Stat(xedPath); err != nil {
- t.Fatal(err)
+ t.Skip(err)
}
testExtDis(t, "intel", arch, xed, generate, allowedMismatchXed)