From: Bryan C. Mills Date: Wed, 3 May 2023 02:06:11 +0000 (-0400) Subject: cmd/compile,cmd/link: skip tests that require DWARF symbols on ios X-Git-Tag: go1.21rc1~709 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=57cb47209c655bdd7fb6d7effd5375e9b0fe90cf;p=gostls13.git cmd/compile,cmd/link: skip tests that require DWARF symbols on ios The linker does not combine DWARF information into the binary on ios. This generalizes test skips that were already present for a similar reason on plan9. Fixes #59939. Change-Id: Ideda07c9f9a69fd102a7d9a83ea8e7b7c29d0da2 Reviewed-on: https://go-review.googlesource.com/c/go/+/491835 Run-TryBot: Bryan Mills TryBot-Bypass: Bryan Mills Reviewed-by: Cherry Mui Auto-Submit: Bryan Mills --- diff --git a/src/cmd/compile/internal/dwarfgen/scope_test.go b/src/cmd/compile/internal/dwarfgen/scope_test.go index 5eb06183d0..ae4a87c52a 100644 --- a/src/cmd/compile/internal/dwarfgen/scope_test.go +++ b/src/cmd/compile/internal/dwarfgen/scope_test.go @@ -7,6 +7,7 @@ package dwarfgen import ( "debug/dwarf" "fmt" + "internal/platform" "internal/testenv" "os" "path/filepath" @@ -215,8 +216,8 @@ func TestScopeRanges(t *testing.T) { testenv.MustHaveGoBuild(t) t.Parallel() - if runtime.GOOS == "plan9" { - t.Skip("skipping on plan9; no DWARF symbol table in executables") + if !platform.ExecutableHasDWARF(runtime.GOOS, runtime.GOARCH) { + t.Skipf("skipping on %s/%s: no DWARF symbol table in executables", runtime.GOOS, runtime.GOARCH) } src, f := gobuild(t, t.TempDir(), false, testfile) @@ -486,8 +487,8 @@ func TestEmptyDwarfRanges(t *testing.T) { testenv.MustHaveGoRun(t) t.Parallel() - if runtime.GOOS == "plan9" { - t.Skip("skipping on plan9; no DWARF symbol table in executables") + if !platform.ExecutableHasDWARF(runtime.GOOS, runtime.GOARCH) { + t.Skipf("skipping on %s/%s: no DWARF symbol table in executables", runtime.GOOS, runtime.GOARCH) } _, f := gobuild(t, t.TempDir(), true, []testline{{line: "package main"}, {line: "func main(){ println(\"hello\") }"}}) diff --git a/src/cmd/compile/internal/ssa/stmtlines_test.go b/src/cmd/compile/internal/ssa/stmtlines_test.go index dd3ce7c1d8..79bcab08a1 100644 --- a/src/cmd/compile/internal/ssa/stmtlines_test.go +++ b/src/cmd/compile/internal/ssa/stmtlines_test.go @@ -12,6 +12,7 @@ import ( "debug/macho" "debug/pe" "fmt" + "internal/platform" "internal/testenv" "internal/xcoff" "io" @@ -53,8 +54,8 @@ type Line struct { } func TestStmtLines(t *testing.T) { - if runtime.GOOS == "plan9" { - t.Skip("skipping on plan9; no DWARF symbol table in executables") + if !platform.ExecutableHasDWARF(runtime.GOOS, runtime.GOARCH) { + t.Skipf("skipping on %s/%s: no DWARF symbol table in executables", runtime.GOOS, runtime.GOARCH) } if runtime.GOOS == "aix" { diff --git a/src/cmd/link/dwarf_test.go b/src/cmd/link/dwarf_test.go index 2ff35e4897..124c91538c 100644 --- a/src/cmd/link/dwarf_test.go +++ b/src/cmd/link/dwarf_test.go @@ -55,8 +55,8 @@ func testDWARF(t *testing.T, buildmode string, expectDWARF bool, env ...string) testenv.MustHaveCGO(t) testenv.MustHaveGoBuild(t) - if runtime.GOOS == "plan9" { - t.Skip("skipping on plan9; no DWARF symbol table in executables") + if !platform.ExecutableHasDWARF(runtime.GOOS, runtime.GOARCH) { + t.Skipf("skipping on %s/%s: no DWARF symbol table in executables", runtime.GOOS, runtime.GOARCH) } t.Parallel() diff --git a/src/cmd/link/internal/ld/dwarf_test.go b/src/cmd/link/internal/ld/dwarf_test.go index 5e9b74f7d6..ad09737ea8 100644 --- a/src/cmd/link/internal/ld/dwarf_test.go +++ b/src/cmd/link/internal/ld/dwarf_test.go @@ -25,6 +25,13 @@ import ( "cmd/link/internal/dwtest" ) +func mustHaveDWARF(t testing.TB) { + if !platform.ExecutableHasDWARF(runtime.GOOS, runtime.GOARCH) { + t.Helper() + t.Skipf("skipping on %s/%s: no DWARF symbol table in executables", runtime.GOOS, runtime.GOARCH) + } +} + const ( DefaultOpt = "-gcflags=" NoOpt = "-gcflags=-l -N" @@ -36,9 +43,7 @@ func TestRuntimeTypesPresent(t *testing.T) { t.Parallel() testenv.MustHaveGoBuild(t) - if runtime.GOOS == "plan9" { - t.Skip("skipping on plan9; no DWARF symbol table in executables") - } + mustHaveDWARF(t) dir := t.TempDir() @@ -179,9 +184,7 @@ func TestEmbeddedStructMarker(t *testing.T) { t.Parallel() testenv.MustHaveGoBuild(t) - if runtime.GOOS == "plan9" { - t.Skip("skipping on plan9; no DWARF symbol table in executables") - } + mustHaveDWARF(t) const prog = ` package main @@ -273,9 +276,7 @@ func findMembers(rdr *dwarf.Reader) (map[string]bool, error) { } func TestSizes(t *testing.T) { - if runtime.GOOS == "plan9" { - t.Skip("skipping on plan9; no DWARF symbol table in executables") - } + mustHaveDWARF(t) // External linking may bring in C symbols with unknown size. Skip. testenv.MustInternalLink(t, false) @@ -322,9 +323,7 @@ func main() { } func TestFieldOverlap(t *testing.T) { - if runtime.GOOS == "plan9" { - t.Skip("skipping on plan9; no DWARF symbol table in executables") - } + mustHaveDWARF(t) t.Parallel() // This test grew out of issue 21094, where specific sudog DWARF types @@ -381,9 +380,7 @@ func TestSubprogramDeclFileLine(t *testing.T) { testenv.MustHaveGoBuild(t) t.Parallel() - if runtime.GOOS == "plan9" { - t.Skip("skipping on plan9; no DWARF symbol table in executables") - } + mustHaveDWARF(t) const prog = `package main %s @@ -447,9 +444,7 @@ func TestVarDeclLine(t *testing.T) { testenv.MustHaveGoBuild(t) t.Parallel() - if runtime.GOOS == "plan9" { - t.Skip("skipping on plan9; no DWARF symbol table in executables") - } + mustHaveDWARF(t) const prog = `package main %s @@ -514,9 +509,7 @@ func main() { func TestInlinedRoutineCallFileLine(t *testing.T) { testenv.MustHaveGoBuild(t) - if runtime.GOOS == "plan9" { - t.Skip("skipping on plan9; no DWARF symbol table in executables") - } + mustHaveDWARF(t) t.Parallel() @@ -648,9 +641,7 @@ func main() { func TestInlinedRoutineArgsVars(t *testing.T) { testenv.MustHaveGoBuild(t) - if runtime.GOOS == "plan9" { - t.Skip("skipping on plan9; no DWARF symbol table in executables") - } + mustHaveDWARF(t) t.Parallel() @@ -840,9 +831,7 @@ func TestAbstractOriginSanity(t *testing.T) { t.Skip("skipping test in short mode.") } - if runtime.GOOS == "plan9" { - t.Skip("skipping on plan9; no DWARF symbol table in executables") - } + mustHaveDWARF(t) if wd, err := os.Getwd(); err == nil { gopathdir := filepath.Join(wd, "testdata", "httptest") @@ -855,9 +844,7 @@ func TestAbstractOriginSanity(t *testing.T) { func TestAbstractOriginSanityIssue25459(t *testing.T) { testenv.MustHaveGoBuild(t) - if runtime.GOOS == "plan9" { - t.Skip("skipping on plan9; no DWARF symbol table in executables") - } + mustHaveDWARF(t) if runtime.GOARCH != "amd64" && runtime.GOARCH != "386" { t.Skip("skipping on not-amd64 not-386; location lists not supported") } @@ -873,9 +860,7 @@ func TestAbstractOriginSanityIssue25459(t *testing.T) { func TestAbstractOriginSanityIssue26237(t *testing.T) { testenv.MustHaveGoBuild(t) - if runtime.GOOS == "plan9" { - t.Skip("skipping on plan9; no DWARF symbol table in executables") - } + mustHaveDWARF(t) if wd, err := os.Getwd(); err == nil { gopathdir := filepath.Join(wd, "testdata", "issue26237") abstractOriginSanity(t, gopathdir, DefaultOpt) @@ -888,9 +873,7 @@ func TestRuntimeTypeAttrInternal(t *testing.T) { testenv.MustHaveGoBuild(t) testenv.MustInternalLink(t, false) - if runtime.GOOS == "plan9" { - t.Skip("skipping on plan9; no DWARF symbol table in executables") - } + mustHaveDWARF(t) testRuntimeTypeAttr(t, "-ldflags=-linkmode=internal") } @@ -900,9 +883,7 @@ func TestRuntimeTypeAttrExternal(t *testing.T) { testenv.MustHaveGoBuild(t) testenv.MustHaveCGO(t) - if runtime.GOOS == "plan9" { - t.Skip("skipping on plan9; no DWARF symbol table in executables") - } + mustHaveDWARF(t) // Explicitly test external linking, for dsymutil compatibility on Darwin. if runtime.GOARCH == "ppc64" { @@ -990,9 +971,7 @@ func TestIssue27614(t *testing.T) { testenv.MustHaveGoBuild(t) - if runtime.GOOS == "plan9" { - t.Skip("skipping on plan9; no DWARF symbol table in executables") - } + mustHaveDWARF(t) t.Parallel() @@ -1104,9 +1083,7 @@ func TestStaticTmp(t *testing.T) { testenv.MustHaveGoBuild(t) - if runtime.GOOS == "plan9" { - t.Skip("skipping on plan9; no DWARF symbol table in executables") - } + mustHaveDWARF(t) t.Parallel() @@ -1182,9 +1159,7 @@ func TestPackageNameAttr(t *testing.T) { testenv.MustHaveGoBuild(t) - if runtime.GOOS == "plan9" { - t.Skip("skipping on plan9; no DWARF symbol table in executables") - } + mustHaveDWARF(t) t.Parallel() @@ -1324,9 +1299,7 @@ func main() { func TestIssue38192(t *testing.T) { testenv.MustHaveGoBuild(t) - if runtime.GOOS == "plan9" { - t.Skip("skipping on plan9; no DWARF symbol table in executables") - } + mustHaveDWARF(t) t.Parallel() @@ -1434,9 +1407,7 @@ func TestIssue38192(t *testing.T) { func TestIssue39757(t *testing.T) { testenv.MustHaveGoBuild(t) - if runtime.GOOS == "plan9" { - t.Skip("skipping on plan9; no DWARF symbol table in executables") - } + mustHaveDWARF(t) t.Parallel() @@ -1546,9 +1517,7 @@ func TestIssue42484(t *testing.T) { testenv.MustHaveGoBuild(t) testenv.MustInternalLink(t, false) // Avoid spurious failures from external linkers. - if runtime.GOOS == "plan9" { - t.Skip("skipping on plan9; no DWARF symbol table in executables") - } + mustHaveDWARF(t) t.Parallel() @@ -1676,9 +1645,7 @@ func processParams(die *dwarf.Entry, ex *dwtest.Examiner) string { func TestOutputParamAbbrevAndAttr(t *testing.T) { testenv.MustHaveGoBuild(t) - if runtime.GOOS == "plan9" { - t.Skip("skipping on plan9; no DWARF symbol table in executables") - } + mustHaveDWARF(t) t.Parallel() // This test verifies that the compiler is selecting the correct @@ -1725,9 +1692,7 @@ func TestDictIndex(t *testing.T) { // have DIEs. testenv.MustHaveGoBuild(t) - if runtime.GOOS == "plan9" { - t.Skip("skipping on plan9; no DWARF symbol table in executables") - } + mustHaveDWARF(t) t.Parallel() const prog = ` @@ -1821,9 +1786,7 @@ func main() { func TestOptimizedOutParamHandling(t *testing.T) { testenv.MustHaveGoBuild(t) - if runtime.GOOS == "plan9" { - t.Skip("skipping on plan9; no DWARF symbol table in executables") - } + mustHaveDWARF(t) t.Parallel() // This test is intended to verify that the compiler emits DWARF @@ -1950,9 +1913,7 @@ func TestIssue54320(t *testing.T) { // emitted in the final binary testenv.MustHaveGoBuild(t) - if runtime.GOOS == "plan9" { - t.Skip("skipping on plan9; no DWARF symbol table in executables") - } + mustHaveDWARF(t) t.Parallel() @@ -2028,9 +1989,7 @@ func main() { func TestZeroSizedVariable(t *testing.T) { testenv.MustHaveGoBuild(t) - if runtime.GOOS == "plan9" { - t.Skip("skipping on plan9; no DWARF symbol table in executables") - } + mustHaveDWARF(t) t.Parallel() // This test verifies that the compiler emits DIEs for zero sized variables diff --git a/src/internal/platform/supported.go b/src/internal/platform/supported.go index 8eb0657d4c..1287838edb 100644 --- a/src/internal/platform/supported.go +++ b/src/internal/platform/supported.go @@ -241,7 +241,17 @@ func DefaultPIE(goos, goarch string, isRace bool) bool { return false } -// CgoSupported reports whether goos/goarch supports cgo.\n") +// CgoSupported reports whether goos/goarch supports cgo. func CgoSupported(goos, goarch string) bool { return osArchSupportsCgo[goos+"/"+goarch] } + +// ExecutableHasDWARF reports whether the linked executable includes DWARF +// symbols on goos/goarch. +func ExecutableHasDWARF(goos, goarch string) bool { + switch goos { + case "plan9", "ios": + return false + } + return true +}