aboutsummaryrefslogtreecommitdiff
path: root/misc
diff options
context:
space:
mode:
authorFilippo Valsorda <filippo@golang.org>2020-04-08 17:39:57 -0400
committerFilippo Valsorda <filippo@golang.org>2020-04-08 17:48:41 -0400
commite067ce5225300a87ae6fe3c48e73102f6fa9368d (patch)
tree3b9335e0023a30f50c3261545019a2f9bb1bab97 /misc
parent79284c28734bf854f44106835b5578ead75eb547 (diff)
parent9baafabac9a84813a336f068862207d2bb06d255 (diff)
downloadgo-e067ce5225300a87ae6fe3c48e73102f6fa9368d.tar.gz
go-e067ce5225300a87ae6fe3c48e73102f6fa9368d.zip
[dev.boringcrypto] all: merge master into dev.boringcrypto
Change-Id: I2dcec316fd08d91db4183fb9d3b9afde65cc248f
Diffstat (limited to 'misc')
-rwxr-xr-xmisc/cgo/fortran/test.bash2
-rw-r--r--misc/cgo/life/overlaydir_test.go11
-rw-r--r--misc/cgo/stdio/overlaydir_test.go11
-rw-r--r--misc/cgo/test/issue21897.go11
-rw-r--r--misc/cgo/test/issue21897b.go2
-rw-r--r--misc/cgo/test/issue8945.go16
-rw-r--r--misc/cgo/test/overlaydir_test.go11
-rw-r--r--misc/cgo/test/sigaltstack.go11
-rw-r--r--misc/cgo/test/test.go5
-rw-r--r--misc/cgo/test/testdata/issue24161_darwin_test.go8
-rw-r--r--misc/cgo/test/testdata/issue24161e0/main.go2
-rw-r--r--misc/cgo/test/testdata/issue24161e1/main.go2
-rw-r--r--misc/cgo/test/testdata/issue24161e2/main.go2
-rw-r--r--misc/cgo/test/testdata/issue9026/issue9026.go4
-rw-r--r--misc/cgo/test/testx.go12
-rw-r--r--misc/cgo/testasan/main.go7
-rw-r--r--misc/cgo/testcarchive/carchive_test.go239
-rw-r--r--misc/cgo/testcarchive/overlaydir_test.go11
-rw-r--r--misc/cgo/testcshared/cshared_test.go45
-rw-r--r--misc/cgo/testcshared/overlaydir_test.go11
-rwxr-xr-xmisc/cgo/testgodefs/test.bash24
-rw-r--r--misc/cgo/testgodefs/testdata/issue37479.go33
-rw-r--r--misc/cgo/testgodefs/testdata/issue37621.go23
-rw-r--r--misc/cgo/testgodefs/testdata/main.go8
-rw-r--r--misc/cgo/testgodefs/testgodefs_test.go85
-rw-r--r--misc/cgo/testplugin/overlaydir_test.go11
-rw-r--r--misc/cgo/testplugin/plugin_test.go2
-rw-r--r--misc/cgo/testshared/overlaydir_test.go11
-rw-r--r--misc/cgo/testshared/shared_test.go206
-rw-r--r--misc/cgo/testsigfwd/main.go1
-rw-r--r--misc/cgo/testso/overlaydir_test.go11
-rw-r--r--misc/cgo/testso/so_test.go4
-rw-r--r--misc/cgo/testsovar/overlaydir_test.go11
-rw-r--r--misc/cgo/testsovar/so_test.go4
-rw-r--r--misc/chrome/gophertool/background.js2
-rw-r--r--misc/reboot/overlaydir_test.go8
-rw-r--r--misc/trace/README.md77
-rw-r--r--misc/trace/trace_viewer_full.html1992
-rw-r--r--misc/trace/webcomponents.min.js14
-rw-r--r--misc/wasm/wasm_exec.js11
40 files changed, 2074 insertions, 887 deletions
diff --git a/misc/cgo/fortran/test.bash b/misc/cgo/fortran/test.bash
index 9498da0208f..2b61730815f 100755
--- a/misc/cgo/fortran/test.bash
+++ b/misc/cgo/fortran/test.bash
@@ -28,7 +28,7 @@ case "$FC" in
;;
esac
-if ! $FC helloworld/helloworld.f90 -o main.exe >& /dev/null; then
+if ! $FC helloworld/helloworld.f90 -o /dev/null >& /dev/null; then
echo "skipping Fortran test: could not build helloworld.f90 with $FC"
exit 0
fi
diff --git a/misc/cgo/life/overlaydir_test.go b/misc/cgo/life/overlaydir_test.go
index a25b125c7c3..034c836248d 100644
--- a/misc/cgo/life/overlaydir_test.go
+++ b/misc/cgo/life/overlaydir_test.go
@@ -21,12 +21,9 @@ func overlayDir(dstRoot, srcRoot string) error {
return err
}
- symBase, err := filepath.Rel(srcRoot, dstRoot)
+ srcRoot, err := filepath.Abs(srcRoot)
if err != nil {
- symBase, err = filepath.Abs(srcRoot)
- if err != nil {
- return err
- }
+ return err
}
return filepath.Walk(srcRoot, func(srcPath string, info os.FileInfo, err error) error {
@@ -52,11 +49,11 @@ func overlayDir(dstRoot, srcRoot string) error {
// Always copy directories (don't symlink them).
// If we add a file in the overlay, we don't want to add it in the original.
if info.IsDir() {
- return os.Mkdir(dstPath, perm|0200)
+ return os.MkdirAll(dstPath, perm|0200)
}
// If the OS supports symlinks, use them instead of copying bytes.
- if err := os.Symlink(filepath.Join(symBase, suffix), dstPath); err == nil {
+ if err := os.Symlink(srcPath, dstPath); err == nil {
return nil
}
diff --git a/misc/cgo/stdio/overlaydir_test.go b/misc/cgo/stdio/overlaydir_test.go
index 5d6858f9605..027ebf17c3f 100644
--- a/misc/cgo/stdio/overlaydir_test.go
+++ b/misc/cgo/stdio/overlaydir_test.go
@@ -21,12 +21,9 @@ func overlayDir(dstRoot, srcRoot string) error {
return err
}
- symBase, err := filepath.Rel(srcRoot, dstRoot)
+ srcRoot, err := filepath.Abs(srcRoot)
if err != nil {
- symBase, err = filepath.Abs(srcRoot)
- if err != nil {
- return err
- }
+ return err
}
return filepath.Walk(srcRoot, func(srcPath string, info os.FileInfo, err error) error {
@@ -52,11 +49,11 @@ func overlayDir(dstRoot, srcRoot string) error {
// Always copy directories (don't symlink them).
// If we add a file in the overlay, we don't want to add it in the original.
if info.IsDir() {
- return os.Mkdir(dstPath, perm|0200)
+ return os.MkdirAll(dstPath, perm|0200)
}
// If the OS supports symlinks, use them instead of copying bytes.
- if err := os.Symlink(filepath.Join(symBase, suffix), dstPath); err == nil {
+ if err := os.Symlink(srcPath, dstPath); err == nil {
return nil
}
diff --git a/misc/cgo/test/issue21897.go b/misc/cgo/test/issue21897.go
index 454a141827f..d13246bd84a 100644
--- a/misc/cgo/test/issue21897.go
+++ b/misc/cgo/test/issue21897.go
@@ -2,16 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-// We skip this test in race mode because, for unknown reasons,
-// linking against CoreFoundation on macOS 10.10 causes mmap to ignore
-// the hint address, which makes the Go allocator incompatible with
-// TSAN. See golang.org/issue/26475.
-//
-// TODO(austin): Once support for macOS 10.10 is dropped, remove the
-// race constraint (and the one in issue21897b.go). See
-// golang.org/issue/26513.
-
-// +build darwin,cgo,!internal,!race
+// +build darwin,cgo,!internal
package cgotest
diff --git a/misc/cgo/test/issue21897b.go b/misc/cgo/test/issue21897b.go
index e143bad086d..08b5f4d808e 100644
--- a/misc/cgo/test/issue21897b.go
+++ b/misc/cgo/test/issue21897b.go
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-// +build !darwin !cgo internal race
+// +build !darwin !cgo internal
package cgotest
diff --git a/misc/cgo/test/issue8945.go b/misc/cgo/test/issue8945.go
deleted file mode 100644
index 57a5b2db44b..00000000000
--- a/misc/cgo/test/issue8945.go
+++ /dev/null
@@ -1,16 +0,0 @@
-// Copyright 2014 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-// +build gccgo
-
-package cgotest
-
-//typedef void (*PFunc)();
-//PFunc success_cb;
-import "C"
-
-//export Test
-func Test() {
- _ = C.success_cb
-}
diff --git a/misc/cgo/test/overlaydir_test.go b/misc/cgo/test/overlaydir_test.go
index cad9577ca11..f651979b657 100644
--- a/misc/cgo/test/overlaydir_test.go
+++ b/misc/cgo/test/overlaydir_test.go
@@ -21,12 +21,9 @@ func overlayDir(dstRoot, srcRoot string) error {
return err
}
- symBase, err := filepath.Rel(srcRoot, dstRoot)
+ srcRoot, err := filepath.Abs(srcRoot)
if err != nil {
- symBase, err = filepath.Abs(srcRoot)
- if err != nil {
- return err
- }
+ return err
}
return filepath.Walk(srcRoot, func(srcPath string, info os.FileInfo, err error) error {
@@ -52,11 +49,11 @@ func overlayDir(dstRoot, srcRoot string) error {
// Always copy directories (don't symlink them).
// If we add a file in the overlay, we don't want to add it in the original.
if info.IsDir() {
- return os.Mkdir(dstPath, perm|0200)
+ return os.MkdirAll(dstPath, perm|0200)
}
// If the OS supports symlinks, use them instead of copying bytes.
- if err := os.Symlink(filepath.Join(symBase, suffix), dstPath); err == nil {
+ if err := os.Symlink(srcPath, dstPath); err == nil {
return nil
}
diff --git a/misc/cgo/test/sigaltstack.go b/misc/cgo/test/sigaltstack.go
index 2c9b81ced7a..7b3f4acbb75 100644
--- a/misc/cgo/test/sigaltstack.go
+++ b/misc/cgo/test/sigaltstack.go
@@ -14,15 +14,22 @@ package cgotest
#include <stdlib.h>
#include <string.h>
+#ifdef _AIX
+// On AIX, SIGSTKSZ is too small to handle Go sighandler.
+#define CSIGSTKSZ 0x4000
+#else
+#define CSIGSTKSZ SIGSTKSZ
+#endif
+
static stack_t oss;
-static char signalStack[SIGSTKSZ];
+static char signalStack[CSIGSTKSZ];
static void changeSignalStack(void) {
stack_t ss;
memset(&ss, 0, sizeof ss);
ss.ss_sp = signalStack;
ss.ss_flags = 0;
- ss.ss_size = SIGSTKSZ;
+ ss.ss_size = CSIGSTKSZ;
if (sigaltstack(&ss, &oss) < 0) {
perror("sigaltstack");
abort();
diff --git a/misc/cgo/test/test.go b/misc/cgo/test/test.go
index 68bfa908254..b0148995fe5 100644
--- a/misc/cgo/test/test.go
+++ b/misc/cgo/test/test.go
@@ -562,6 +562,11 @@ void issue8811Execute() {
issue8811Init();
}
+// issue 8945
+
+typedef void (*PFunc8945)();
+PFunc8945 func8945;
+
// issue 9557
struct issue9557_t {
diff --git a/misc/cgo/test/testdata/issue24161_darwin_test.go b/misc/cgo/test/testdata/issue24161_darwin_test.go
index 64f44428569..e60eb4e9178 100644
--- a/misc/cgo/test/testdata/issue24161_darwin_test.go
+++ b/misc/cgo/test/testdata/issue24161_darwin_test.go
@@ -2,14 +2,6 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-// See issue21897.go and golang.org/issue/26475 for why this is
-// skipped in race mode.
-//
-// TODO(austin): Once support for macOS 10.10 is dropped, remove the
-// race constraint. See golang.org/issue/26513.
-
-// +build !race
-
package cgotest
import (
diff --git a/misc/cgo/test/testdata/issue24161e0/main.go b/misc/cgo/test/testdata/issue24161e0/main.go
index cbc1deea78a..efe53458d87 100644
--- a/misc/cgo/test/testdata/issue24161e0/main.go
+++ b/misc/cgo/test/testdata/issue24161e0/main.go
@@ -12,7 +12,7 @@ package issue24161e0
#include <TargetConditionals.h>
#include <CoreFoundation/CoreFoundation.h>
#include <Security/Security.h>
-#if TARGET_OS_IPHONE == 0 && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 101200
+#if TARGET_OS_IPHONE == 0 && __MAC_OS_X_VERSION_MAX_ALLOWED < 101200
typedef CFStringRef SecKeyAlgorithm;
static CFDataRef SecKeyCreateSignature(SecKeyRef key, SecKeyAlgorithm algorithm, CFDataRef dataToSign, CFErrorRef *error){return NULL;}
#define kSecKeyAlgorithmECDSASignatureDigestX962SHA1 foo()
diff --git a/misc/cgo/test/testdata/issue24161e1/main.go b/misc/cgo/test/testdata/issue24161e1/main.go
index eb48fc0059d..82bf172b7d7 100644
--- a/misc/cgo/test/testdata/issue24161e1/main.go
+++ b/misc/cgo/test/testdata/issue24161e1/main.go
@@ -12,7 +12,7 @@ package issue24161e1
#include <TargetConditionals.h>
#include <CoreFoundation/CoreFoundation.h>
#include <Security/Security.h>
-#if TARGET_OS_IPHONE == 0 && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 101200
+#if TARGET_OS_IPHONE == 0 && __MAC_OS_X_VERSION_MAX_ALLOWED < 101200
typedef CFStringRef SecKeyAlgorithm;
static CFDataRef SecKeyCreateSignature(SecKeyRef key, SecKeyAlgorithm algorithm, CFDataRef dataToSign, CFErrorRef *error){return NULL;}
#define kSecKeyAlgorithmECDSASignatureDigestX962SHA1 foo()
diff --git a/misc/cgo/test/testdata/issue24161e2/main.go b/misc/cgo/test/testdata/issue24161e2/main.go
index 1951c863175..82d2ec1296c 100644
--- a/misc/cgo/test/testdata/issue24161e2/main.go
+++ b/misc/cgo/test/testdata/issue24161e2/main.go
@@ -12,7 +12,7 @@ package issue24161e2
#include <TargetConditionals.h>
#include <CoreFoundation/CoreFoundation.h>
#include <Security/Security.h>
-#if TARGET_OS_IPHONE == 0 && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 101200
+#if TARGET_OS_IPHONE == 0 && __MAC_OS_X_VERSION_MAX_ALLOWED < 101200
typedef CFStringRef SecKeyAlgorithm;
static CFDataRef SecKeyCreateSignature(SecKeyRef key, SecKeyAlgorithm algorithm, CFDataRef dataToSign, CFErrorRef *error){return NULL;}
#define kSecKeyAlgorithmECDSASignatureDigestX962SHA1 foo()
diff --git a/misc/cgo/test/testdata/issue9026/issue9026.go b/misc/cgo/test/testdata/issue9026/issue9026.go
index 0af86e64da4..ff269ca9eb0 100644
--- a/misc/cgo/test/testdata/issue9026/issue9026.go
+++ b/misc/cgo/test/testdata/issue9026/issue9026.go
@@ -4,9 +4,9 @@ package issue9026
// per-package counter used to create fresh identifiers.
/*
-typedef struct {} git_merge_file_input;
+typedef struct { int i; } git_merge_file_input;
-typedef struct {} git_merge_file_options;
+typedef struct { int j; } git_merge_file_options;
void git_merge_file(
git_merge_file_input *in,
diff --git a/misc/cgo/test/testx.go b/misc/cgo/test/testx.go
index bb1b50802b6..42979b5f4d5 100644
--- a/misc/cgo/test/testx.go
+++ b/misc/cgo/test/testx.go
@@ -102,6 +102,11 @@ static void issue7978c(uint32_t *sync) {
// #include'd twice. No runtime test; just make sure it compiles.
#include "issue8331.h"
+// issue 8945
+
+typedef void (*PFunc8945)();
+extern PFunc8945 func8945; // definition is in test.go
+
// issue 20910
void callMulti(void);
@@ -514,6 +519,13 @@ func test7978(t *testing.T) {
var issue8331Var C.issue8331
+// issue 8945
+
+//export Test8945
+func Test8945() {
+ _ = C.func8945
+}
+
// issue 20910
//export multi
diff --git a/misc/cgo/testasan/main.go b/misc/cgo/testasan/main.go
index 1837c6cc81d..bc77678c25a 100644
--- a/misc/cgo/testasan/main.go
+++ b/misc/cgo/testasan/main.go
@@ -36,14 +36,21 @@ thread(void *p)
import "C"
import (
+ "fmt"
+ "os"
+ "path/filepath"
"time"
)
func main() {
+ start := time.Now()
+
// ensure that we can function normally
var v [][]byte
for i := 0; i < 1000; i++ {
time.Sleep(10 * time.Microsecond)
v = append(v, make([]byte, 64<<10))
}
+
+ fmt.Printf("ok\t%s\t%s\n", filepath.Base(os.Args[0]), time.Since(start).Round(time.Millisecond))
}
diff --git a/misc/cgo/testcarchive/carchive_test.go b/misc/cgo/testcarchive/carchive_test.go
index cf2c6264dd1..82a1a5a54ce 100644
--- a/misc/cgo/testcarchive/carchive_test.go
+++ b/misc/cgo/testcarchive/carchive_test.go
@@ -36,7 +36,10 @@ var exeSuffix string
var GOOS, GOARCH, GOPATH string
var libgodir string
+var testWork bool // If true, preserve temporary directories.
+
func TestMain(m *testing.M) {
+ flag.BoolVar(&testWork, "testwork", false, "if true, log and preserve the test's temporary working directory")
flag.Parse()
if testing.Short() && os.Getenv("GO_BUILDER_NAME") == "" {
fmt.Printf("SKIP - short mode and $GO_BUILDER_NAME not set\n")
@@ -54,7 +57,11 @@ func testMain(m *testing.M) int {
if err != nil {
log.Panic(err)
}
- defer os.RemoveAll(GOPATH)
+ if testWork {
+ log.Println(GOPATH)
+ } else {
+ defer os.RemoveAll(GOPATH)
+ }
os.Setenv("GOPATH", GOPATH)
// Copy testdata into GOPATH/src/testarchive, along with a go.mod file
@@ -164,6 +171,38 @@ func cmdToRun(name string) []string {
return []string{executor, name}
}
+// genHeader writes a C header file for the C-exported declarations found in .go
+// source files in dir.
+//
+// TODO(golang.org/issue/35715): This should be simpler.
+func genHeader(t *testing.T, header, dir string) {
+ t.Helper()
+
+ // The 'cgo' command generates a number of additional artifacts,
+ // but we're only interested in the header.
+ // Shunt the rest of the outputs to a temporary directory.
+ objDir, err := ioutil.TempDir(GOPATH, "_obj")
+ if err != nil {
+ t.Fatal(err)
+ }
+ defer os.RemoveAll(objDir)
+
+ files, err := filepath.Glob(filepath.Join(dir, "*.go"))
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ cmd := exec.Command("go", "tool", "cgo",
+ "-objdir", objDir,
+ "-exportheader", header)
+ cmd.Args = append(cmd.Args, files...)
+ t.Log(cmd.Args)
+ if out, err := cmd.CombinedOutput(); err != nil {
+ t.Logf("%s", out)
+ t.Fatal(err)
+ }
+}
+
func testInstall(t *testing.T, exe, libgoa, libgoh string, buildcmd ...string) {
t.Helper()
cmd := exec.Command(buildcmd[0], buildcmd[1:]...)
@@ -172,10 +211,12 @@ func testInstall(t *testing.T, exe, libgoa, libgoh string, buildcmd ...string) {
t.Logf("%s", out)
t.Fatal(err)
}
- defer func() {
- os.Remove(libgoa)
- os.Remove(libgoh)
- }()
+ if !testWork {
+ defer func() {
+ os.Remove(libgoa)
+ os.Remove(libgoh)
+ }()
+ }
ccArgs := append(cc, "-o", exe, "main.c")
if GOOS == "windows" {
@@ -191,7 +232,9 @@ func testInstall(t *testing.T, exe, libgoa, libgoh string, buildcmd ...string) {
t.Logf("%s", out)
t.Fatal(err)
}
- defer os.Remove(exe)
+ if !testWork {
+ defer os.Remove(exe)
+ }
binArgs := append(cmdToRun(exe), "arg1", "arg2")
cmd = exec.Command(binArgs[0], binArgs[1:]...)
@@ -227,17 +270,27 @@ func checkLineComments(t *testing.T, hdrname string) {
}
func TestInstall(t *testing.T) {
- defer os.RemoveAll(filepath.Join(GOPATH, "pkg"))
+ if !testWork {
+ defer os.RemoveAll(filepath.Join(GOPATH, "pkg"))
+ }
libgoa := "libgo.a"
if runtime.Compiler == "gccgo" {
libgoa = "liblibgo.a"
}
+ // Generate the p.h header file.
+ //
+ // 'go install -i -buildmode=c-archive ./libgo' would do that too, but that
+ // would also attempt to install transitive standard-library dependencies to
+ // GOROOT, and we cannot assume that GOROOT is writable. (A non-root user may
+ // be running this test in a GOROOT owned by root.)
+ genHeader(t, "p.h", "./p")
+
testInstall(t, "./testp1"+exeSuffix,
filepath.Join(libgodir, libgoa),
filepath.Join(libgodir, "libgo.h"),
- "go", "install", "-i", "-buildmode=c-archive", "./libgo")
+ "go", "install", "-buildmode=c-archive", "./libgo")
// Test building libgo other than installing it.
// Header files are now present.
@@ -259,12 +312,14 @@ func TestEarlySignalHandler(t *testing.T) {
t.Skip("skipping signal test on Windows")
}
- defer func() {
- os.Remove("libgo2.a")
- os.Remove("libgo2.h")
- os.Remove("testp")
- os.RemoveAll(filepath.Join(GOPATH, "pkg"))
- }()
+ if !testWork {
+ defer func() {
+ os.Remove("libgo2.a")
+ os.Remove("libgo2.h")
+ os.Remove("testp")
+ os.RemoveAll(filepath.Join(GOPATH, "pkg"))
+ }()
+ }
cmd := exec.Command("go", "build", "-buildmode=c-archive", "-o", "libgo2.a", "./libgo2")
if out, err := cmd.CombinedOutput(); err != nil {
@@ -297,12 +352,14 @@ func TestEarlySignalHandler(t *testing.T) {
func TestSignalForwarding(t *testing.T) {
checkSignalForwardingTest(t)
- defer func() {
- os.Remove("libgo2.a")
- os.Remove("libgo2.h")
- os.Remove("testp")
- os.RemoveAll(filepath.Join(GOPATH, "pkg"))
- }()
+ if !testWork {
+ defer func() {
+ os.Remove("libgo2.a")
+ os.Remove("libgo2.h")
+ os.Remove("testp")
+ os.RemoveAll(filepath.Join(GOPATH, "pkg"))
+ }()
+ }
cmd := exec.Command("go", "build", "-buildmode=c-archive", "-o", "libgo2.a", "./libgo2")
if out, err := cmd.CombinedOutput(); err != nil {
@@ -345,12 +402,14 @@ func TestSignalForwardingExternal(t *testing.T) {
}
checkSignalForwardingTest(t)
- defer func() {
- os.Remove("libgo2.a")
- os.Remove("libgo2.h")
- os.Remove("testp")
- os.RemoveAll(filepath.Join(GOPATH, "pkg"))
- }()
+ if !testWork {
+ defer func() {
+ os.Remove("libgo2.a")
+ os.Remove("libgo2.h")
+ os.Remove("testp")
+ os.RemoveAll(filepath.Join(GOPATH, "pkg"))
+ }()
+ }
cmd := exec.Command("go", "build", "-buildmode=c-archive", "-o", "libgo2.a", "./libgo2")
if out, err := cmd.CombinedOutput(); err != nil {
@@ -460,12 +519,14 @@ func TestOsSignal(t *testing.T) {
t.Skip("skipping signal test on Windows")
}
- defer func() {
- os.Remove("libgo3.a")
- os.Remove("libgo3.h")
- os.Remove("testp")
- os.RemoveAll(filepath.Join(GOPATH, "pkg"))
- }()
+ if !testWork {
+ defer func() {
+ os.Remove("libgo3.a")
+ os.Remove("libgo3.h")
+ os.Remove("testp")
+ os.RemoveAll(filepath.Join(GOPATH, "pkg"))
+ }()
+ }
cmd := exec.Command("go", "build", "-buildmode=c-archive", "-o", "libgo3.a", "./libgo3")
if out, err := cmd.CombinedOutput(); err != nil {
@@ -495,12 +556,14 @@ func TestSigaltstack(t *testing.T) {
t.Skip("skipping signal test on Windows")
}
- defer func() {
- os.Remove("libgo4.a")
- os.Remove("libgo4.h")
- os.Remove("testp")
- os.RemoveAll(filepath.Join(GOPATH, "pkg"))
- }()
+ if !testWork {
+ defer func() {
+ os.Remove("libgo4.a")
+ os.Remove("libgo4.h")
+ os.Remove("testp")
+ os.RemoveAll(filepath.Join(GOPATH, "pkg"))
+ }()
+ }
cmd := exec.Command("go", "build", "-buildmode=c-archive", "-o", "libgo4.a", "./libgo4")
if out, err := cmd.CombinedOutput(); err != nil {
@@ -544,13 +607,15 @@ func TestExtar(t *testing.T) {
t.Skip("shell scripts are not executable on iOS hosts")
}
- defer func() {
- os.Remove("libgo4.a")
- os.Remove("libgo4.h")
- os.Remove("testar")
- os.Remove("testar.ran")
- os.RemoveAll(filepath.Join(GOPATH, "pkg"))
- }()
+ if !testWork {
+ defer func() {
+ os.Remove("libgo4.a")
+ os.Remove("libgo4.h")
+ os.Remove("testar")
+ os.Remove("testar.ran")
+ os.RemoveAll(filepath.Join(GOPATH, "pkg"))
+ }()
+ }
os.Remove("testar")
dir, err := os.Getwd()
@@ -584,12 +649,22 @@ func TestPIE(t *testing.T) {
t.Skipf("skipping PIE test on %s", GOOS)
}
- defer func() {
- os.Remove("testp" + exeSuffix)
- os.RemoveAll(filepath.Join(GOPATH, "pkg"))
- }()
+ if !testWork {
+ defer func() {
+ os.Remove("testp" + exeSuffix)
+ os.RemoveAll(filepath.Join(GOPATH, "pkg"))
+ }()
+ }
+
+ // Generate the p.h header file.
+ //
+ // 'go install -i -buildmode=c-archive ./libgo' would do that too, but that
+ // would also attempt to install transitive standard-library dependencies to
+ // GOROOT, and we cannot assume that GOROOT is writable. (A non-root user may
+ // be running this test in a GOROOT owned by root.)
+ genHeader(t, "p.h", "./p")
- cmd := exec.Command("go", "install", "-i", "-buildmode=c-archive", "./libgo")
+ cmd := exec.Command("go", "install", "-buildmode=c-archive", "./libgo")
if out, err := cmd.CombinedOutput(); err != nil {
t.Logf("%s", out)
t.Fatal(err)
@@ -669,11 +744,13 @@ func TestSIGPROF(t *testing.T) {
t.Parallel()
- defer func() {
- os.Remove("testp6" + exeSuffix)
- os.