]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile,cmd/link: skip tests that require DWARF symbols on ios
authorBryan C. Mills <bcmills@google.com>
Wed, 3 May 2023 02:06:11 +0000 (22:06 -0400)
committerBryan Mills <bcmills@google.com>
Wed, 3 May 2023 17:05:14 +0000 (17:05 +0000)
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 <bcmills@google.com>
TryBot-Bypass: Bryan Mills <bcmills@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>

src/cmd/compile/internal/dwarfgen/scope_test.go
src/cmd/compile/internal/ssa/stmtlines_test.go
src/cmd/link/dwarf_test.go
src/cmd/link/internal/ld/dwarf_test.go
src/internal/platform/supported.go

index 5eb06183d04826473c64134426a9a576362842e6..ae4a87c52a2828b44095c38151ab034e6d8d9f65 100644 (file)
@@ -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\") }"}})
index dd3ce7c1d87d8c1768a9649f5efc8ffc6c1a7c9d..79bcab08a1e6988267381c4a5283cb8afb350daf 100644 (file)
@@ -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" {
index 2ff35e489710fbdf9c872460caa52a01f3b33ddb..124c91538cc804b88d2f4ad358f70a58e4278a58 100644 (file)
@@ -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()
index 5e9b74f7d691fc72078f674cbe5cdbb95051b794..ad09737ea864d7d81b11c2af9278a54481b7450f 100644 (file)
@@ -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<T> 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
index 8eb0657d4c9817b2881aed1f29fbce6a84c77881..1287838edb81cce433ea13e9e38542eeafbe457a 100644 (file)
@@ -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
+}