[dev.link] all: merge branch 'master' into dev.link

NOT apply CL 238779, which is for sym.Symbols.

Clean merge other than that.

Change-Id: I535e9580fcf7d6f382bd684c3d53f11f90d0b6ed
This commit is contained in:
Cherry Zhang 2020-06-19 16:14:40 -04:00
commit 5e526e67e7
70 changed files with 2089 additions and 2929 deletions

View file

@ -722,3 +722,37 @@ func TestIndexMismatch(t *testing.T) {
t.Errorf("did not see expected error message. out:\n%s", out)
}
}
func TestPErsrc(t *testing.T) {
// Test that PE rsrc section is handled correctly (issue 39658).
testenv.MustHaveGoBuild(t)
if runtime.GOARCH != "amd64" || runtime.GOOS != "windows" {
t.Skipf("this is a windows/amd64-only test")
}
tmpdir, err := ioutil.TempDir("", "TestPErsrc")
if err != nil {
t.Fatal(err)
}
defer os.RemoveAll(tmpdir)
pkgdir := filepath.Join("testdata", "testPErsrc")
exe := filepath.Join(tmpdir, "a.exe")
cmd := exec.Command(testenv.GoToolPath(t), "build", "-o", exe)
cmd.Dir = pkgdir
// cmd.Env = append(os.Environ(), "GOOS=windows", "GOARCH=amd64") // uncomment if debugging in a cross-compiling environment
out, err := cmd.CombinedOutput()
if err != nil {
t.Fatalf("building failed: %v, output:\n%s", err, out)
}
// Check that the binary contains the rsrc data
b, err := ioutil.ReadFile(exe)
if err != nil {
t.Fatalf("reading output failed: %v", err)
}
if !bytes.Contains(b, []byte("Hello Gophers!")) {
t.Fatalf("binary does not contain expected content")
}
}