cmd/link/internal/ld: rm os.Getwd from dwarf_test

Calls to os.Getwd were needed to set the cwd for go build to an absolute
path. Since CL 401340 os/exec takes care of setting PWD to a
filepath.Abs(cmd.Dir), so it looks like an absolute path is not
really required.

Change-Id: Ib3abffc9087a3329d8f40f81eb65f1b2c1a03a9c
Reviewed-on: https://go-review.googlesource.com/c/go/+/610038
Auto-Submit: Ian Lance Taylor <iant@golang.org>
Commit-Queue: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
This commit is contained in:
Kir Kolyshkin 2024-09-03 19:46:46 -07:00 committed by Gopher Robot
parent de0aafa3c7
commit 9ba8ac253e
1 changed files with 7 additions and 43 deletions

View File

@ -838,13 +838,7 @@ func TestAbstractOriginSanity(t *testing.T) {
}
mustHaveDWARF(t)
if wd, err := os.Getwd(); err == nil {
gopathdir := filepath.Join(wd, "testdata", "httptest")
abstractOriginSanity(t, gopathdir, OptAllInl4)
} else {
t.Fatalf("os.Getwd() failed %v", err)
}
abstractOriginSanity(t, "testdata/httptest", OptAllInl4)
}
func TestAbstractOriginSanityIssue25459(t *testing.T) {
@ -855,24 +849,14 @@ func TestAbstractOriginSanityIssue25459(t *testing.T) {
t.Skip("skipping on not-amd64 not-386; location lists not supported")
}
if wd, err := os.Getwd(); err == nil {
gopathdir := filepath.Join(wd, "testdata", "issue25459")
abstractOriginSanity(t, gopathdir, DefaultOpt)
} else {
t.Fatalf("os.Getwd() failed %v", err)
}
abstractOriginSanity(t, "testdata/issue25459", DefaultOpt)
}
func TestAbstractOriginSanityIssue26237(t *testing.T) {
testenv.MustHaveGoBuild(t)
mustHaveDWARF(t)
if wd, err := os.Getwd(); err == nil {
gopathdir := filepath.Join(wd, "testdata", "issue26237")
abstractOriginSanity(t, gopathdir, DefaultOpt)
} else {
t.Fatalf("os.Getwd() failed %v", err)
}
abstractOriginSanity(t, "testdata/issue26237", DefaultOpt)
}
func TestRuntimeTypeAttrInternal(t *testing.T) {
@ -1229,12 +1213,7 @@ func TestMachoIssue32233(t *testing.T) {
t.Skip("skipping; test only interesting on darwin")
}
wd, err := os.Getwd()
if err != nil {
t.Fatalf("where am I? %v", err)
}
pdir := filepath.Join(wd, "testdata", "issue32233", "main")
f := gobuildTestdata(t, pdir, DefaultOpt)
f := gobuildTestdata(t, "testdata/issue32233/main", DefaultOpt)
f.Close()
}
@ -1309,12 +1288,7 @@ func TestIssue38192(t *testing.T) {
// Build a test program that contains a translation unit whose
// text (from am assembly source) contains only a single instruction.
wd, err := os.Getwd()
if err != nil {
t.Fatalf("where am I? %v", err)
}
pdir := filepath.Join(wd, "testdata", "issue38192")
f := gobuildTestdata(t, pdir, DefaultOpt)
f := gobuildTestdata(t, "testdata/issue38192", DefaultOpt)
defer f.Close()
// Open the resulting binary and examine the DWARF it contains.
@ -1426,12 +1400,7 @@ func TestIssue39757(t *testing.T) {
// compiler/runtime in ways that aren't happening now, so this
// might be something to check for if it does start failing.
wd, err := os.Getwd()
if err != nil {
t.Fatalf("where am I? %v", err)
}
pdir := filepath.Join(wd, "testdata", "issue39757")
f := gobuildTestdata(t, pdir, DefaultOpt)
f := gobuildTestdata(t, "testdata/issue39757", DefaultOpt)
defer f.Close()
syms, err := f.Symbols()
@ -1522,12 +1491,7 @@ func TestIssue42484(t *testing.T) {
t.Parallel()
wd, err := os.Getwd()
if err != nil {
t.Fatalf("where am I? %v", err)
}
pdir := filepath.Join(wd, "testdata", "issue42484")
f := gobuildTestdata(t, pdir, NoOpt)
f := gobuildTestdata(t, "testdata/issue42484", NoOpt)
var lastAddr uint64
var lastFile string