aboutsummaryrefslogtreecommitdiff
path: root/go/patch/go4.patch
blob: 1c96c0932a777e262941ca0fbf1d92bb7b954dc9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
runtime, crypto/x509: add -target flag.

--- src/crypto/x509/x509_test.go
+++ src/crypto/x509/x509_test.go
@@ -19,6 +19,7 @@ import (
 	"encoding/hex"
 	"encoding/pem"
 	"fmt"
+	"flag"
 	"internal/testenv"
 	"math/big"
 	"net"
@@ -28,6 +29,8 @@ import (
 	"time"
 )
 
+var target = flag.String("target", "", "if non empty, use 'go_target' to compile test files and 'go_target_exec' to run the binaries")
+
 func TestParsePKCS1PrivateKey(t *testing.T) {
 	block, _ := pem.Decode([]byte(pemPrivateKey))
 	priv, err := ParsePKCS1PrivateKey(block.Bytes)
@@ -862,7 +865,13 @@ func TestParsePEMCRL(t *testing.T) {
 func TestImports(t *testing.T) {
 	testenv.MustHaveGoRun(t)
 
-	if err := exec.Command("go", "run", "x509_test_import.go").Run(); err != nil {
+	var cmd *exec.Cmd
+	if *target == "" {
+		cmd = exec.Command("go", "run", "x509_test_import.go")
+	} else {
+		cmd = exec.Command("go_"+*target, "run", "-exec", "go_"+*target+"_exec", "x509_test_import.go")
+	}
+	if err := cmd.Run(); err != nil {
 		t.Errorf("failed to run x509_test_import.go: %s", err)
 	}
 }
--- src/runtime/crash_test.go
+++ src/runtime/crash_test.go
@@ -5,6 +5,7 @@
 package runtime_test
 
 import (
+	"flag"
 	"fmt"
 	"internal/testenv"
 	"io/ioutil"
@@ -18,6 +19,25 @@ import (
 	"testing"
 )
 
+var target = flag.String("target", "", "if non empty, use 'go_target' to compile test files and 'go_target_exec' to run the binaries")
+
+func goCmd() string {
+	if *target != "" {
+		return "go_" + *target
+	}
+	return "go"
+}
+
+func goExecCmd(name string, arg ...string) *exec.Cmd {
+	var cmd []string
+	if *target != "" {
+		cmd = append(cmd, "go_"+*target+"_exec")
+	}
+	cmd = append(cmd, name)
+	cmd = append(cmd, arg...)
+	return exec.Command(cmd[0], cmd[1:]...)
+}
+
 var toRemove []string
 
 func TestMain(m *testing.M) {
@@ -65,7 +85,7 @@ func runTestProg(t *testing.T, binary, name string) string {
 	if err != nil {
 		t.Fatal(err)
 	}
-	got, _ := testEnv(exec.Command(exe, name)).CombinedOutput()
+	got, _ := testEnv(goExecCmd(exe, name)).CombinedOutput()
 	return string(got)
 }
 
@@ -92,7 +112,7 @@ func buildTestProg(t *testing.T, binary string) (string, error) {
 	}
 
 	exe := filepath.Join(testprog.dir, binary+".exe")
-	cmd := exec.Command("go", "build", "-o", exe)
+	cmd := exec.Command(goCmd(), "build", "-o", exe)
 	cmd.Dir = "testdata/" + binary
 	out, err := testEnv(cmd).CombinedOutput()
 	if err != nil {
--- src/runtime/crash_unix_test.go
+++ src/runtime/crash_unix_test.go
@@ -157,7 +157,7 @@ func TestSignalExitStatus(t *testing.T) {
 	if err != nil {
 		t.Fatal(err)
 	}
-	err = testEnv(exec.Command(exe, "SignalExitStatus")).Run()
+	err = testEnv(goExecCmd(exe, "SignalExitStatus")).Run()
 	if err == nil {
 		t.Error("test program succeeded unexpectedly")
 	} else if ee, ok := err.(*exec.ExitError); !ok {