(t *testing.T, intelSyntax bool)
| 271 | } |
| 272 | |
| 273 | func testDisasm(t *testing.T, intelSyntax bool) { |
| 274 | _, llvmObjdump, buObjdump := findObjdump([]string{""}) |
| 275 | if !llvmObjdump && !buObjdump { |
| 276 | t.Skip("cannot disasm: no objdump tool available") |
| 277 | } |
| 278 | |
| 279 | bu := &Binutils{} |
| 280 | var testexe string |
| 281 | switch runtime.GOOS { |
| 282 | case "linux": |
| 283 | testexe = "exe_linux_64" |
| 284 | case "darwin": |
| 285 | testexe = "exe_mac_64" |
| 286 | case "windows": |
| 287 | testexe = "exe_windows_64.exe" |
| 288 | default: |
| 289 | t.Skipf("unsupported OS %q", runtime.GOOS) |
| 290 | } |
| 291 | |
| 292 | insts, err := bu.Disasm(filepath.Join("testdata", testexe), 0, math.MaxUint64, intelSyntax) |
| 293 | if err != nil { |
| 294 | t.Fatalf("Disasm: unexpected error %v", err) |
| 295 | } |
| 296 | mainCount := 0 |
| 297 | for _, x := range insts { |
| 298 | // macOS symbols have a leading underscore. |
| 299 | if x.Function == "main" || x.Function == "_main" { |
| 300 | mainCount++ |
| 301 | } |
| 302 | } |
| 303 | if mainCount == 0 { |
| 304 | t.Error("Disasm: found no main instructions") |
| 305 | } |
| 306 | } |
| 307 | |
| 308 | func TestDisasm(t *testing.T) { |
| 309 | if (runtime.GOOS != "linux" && runtime.GOOS != "darwin" && runtime.GOOS != "windows") || runtime.GOARCH != "amd64" { |
no test coverage detected
searching dependent graphs…