aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/debug_test.go
diff options
context:
space:
mode:
authorFilippo Valsorda <filippo@golang.org>2021-05-12 19:23:21 +0200
committerFilippo Valsorda <filippo@golang.org>2021-05-13 12:59:22 -0400
commited1f812cefc3ece4b21241ba4cba0272cd2484ed (patch)
tree2e336c94eb9797488234c0cb86b123c1c5f2932b /src/runtime/debug_test.go
parentad1b6f3ee00ce2592503efec7a9793c4786f6274 (diff)
parent9d0819b27ca248f9949e7cf6bf7cb9fe7cf574e8 (diff)
downloadgo-ed1f812cefc3ece4b21241ba4cba0272cd2484ed.tar.xz
[dev.boringcrypto] all: merge commit 9d0819b27c (CL 314609) into dev.boringcrypto
There used to be two BoringCrypto-specific behaviors related to cipher suites in crypto/tls: 1. in FIPS-only mode, only a restricted set of AES ciphers is allowed 2. NOT in FIPS-only mode, AES would be prioritized over ChaCha20 even if AES hardware was not available The motivation of (2) is unclear, and BoringSSL doesn't have equivalent logic. This merge drops (2), and keeps (1). Note that the list of FIPS-only ciphers does not have priority semantics anymore, but the default logic still sorts them the same way as they used to be. Change-Id: I50544011085cfa2b087f323aebf5338c0bd2dd33
Diffstat (limited to 'src/runtime/debug_test.go')
-rw-r--r--src/runtime/debug_test.go64
1 files changed, 47 insertions, 17 deletions
diff --git a/src/runtime/debug_test.go b/src/runtime/debug_test.go
index a0b3f84382..f74383457f 100644
--- a/src/runtime/debug_test.go
+++ b/src/runtime/debug_test.go
@@ -9,14 +9,16 @@
// spends all of its time in the race runtime, which isn't a safe
// point.
-// +build amd64
-// +build linux
-// +build !race
+//go:build amd64 && linux && !race
+// +build amd64,linux,!race
package runtime_test
import (
"fmt"
+ "internal/abi"
+ "internal/goexperiment"
+ "math"
"os"
"regexp"
"runtime"
@@ -116,21 +118,49 @@ func TestDebugCall(t *testing.T) {
g, after := startDebugCallWorker(t)
defer after()
+ type stackArgs struct {
+ x0 int
+ x1 float64
+ y0Ret int
+ y1Ret float64
+ }
+
// Inject a call into the debugCallWorker goroutine and test
// basic argument and result passing.
- var args struct {
- x int
- yRet int
+ fn := func(x int, y float64) (y0Ret int, y1Ret float64) {
+ return x + 1, y + 1.0
}
- fn := func(x int) (yRet int) {
- return x + 1
+ var args *stackArgs
+ var regs abi.RegArgs
+ intRegs := regs.Ints[:]
+ floatRegs := regs.Floats[:]
+ fval := float64(42.0)
+ if goexperiment.RegabiArgs {
+ intRegs[0] = 42
+ floatRegs[0] = math.Float64bits(fval)
+ } else {
+ args = &stackArgs{
+ x0: 42,
+ x1: 42.0,
+ }
}
- args.x = 42
- if _, err := runtime.InjectDebugCall(g, fn, &args, debugCallTKill, false); err != nil {
+ if _, err := runtime.InjectDebugCall(g, fn, &regs, args, debugCallTKill, false); err != nil {
t.Fatal(err)
}
- if args.yRet != 43 {
- t.Fatalf("want 43, got %d", args.yRet)
+ var result0 int
+ var result1 float64
+ if goexperiment.RegabiArgs {
+ result0 = int(intRegs[0])
+ result1 = math.Float64frombits(floatRegs[0])
+ } else {
+ result0 = args.y0Ret
+ result1 = args.y1Ret
+ }
+ if result0 != 43 {
+ t.Errorf("want 43, got %d", result0)
+ }
+ if result1 != fval+1 {
+ t.Errorf("want 43, got %f", result1)
}
}
@@ -155,7 +185,7 @@ func TestDebugCallLarge(t *testing.T) {
args.in[i] = i
want[i] = i + 1
}
- if _, err := runtime.InjectDebugCall(g, fn, &args, debugCallTKill, false); err != nil {
+ if _, err := runtime.InjectDebugCall(g, fn, nil, &args, debugCallTKill, false); err != nil {
t.Fatal(err)
}
if want != args.out {
@@ -168,7 +198,7 @@ func TestDebugCallGC(t *testing.T) {
defer after()
// Inject a call that performs a GC.
- if _, err := runtime.InjectDebugCall(g, runtime.GC, nil, debugCallTKill, false); err != nil {
+ if _, err := runtime.InjectDebugCall(g, runtime.GC, nil, nil, debugCallTKill, false); err != nil {
t.Fatal(err)
}
}
@@ -179,7 +209,7 @@ func TestDebugCallGrowStack(t *testing.T) {
// Inject a call that grows the stack. debugCallWorker checks
// for stack pointer breakage.
- if _, err := runtime.InjectDebugCall(g, func() { growStack(nil) }, nil, debugCallTKill, false); err != nil {
+ if _, err := runtime.InjectDebugCall(g, func() { growStack(nil) }, nil, nil, debugCallTKill, false); err != nil {
t.Fatal(err)
}
}
@@ -215,7 +245,7 @@ func TestDebugCallUnsafePoint(t *testing.T) {
runtime.Gosched()
}
- _, err := runtime.InjectDebugCall(g, func() {}, nil, debugCallTKill, true)
+ _, err := runtime.InjectDebugCall(g, func() {}, nil, nil, debugCallTKill, true)
if msg := "call not at safe point"; err == nil || err.Error() != msg {
t.Fatalf("want %q, got %s", msg, err)
}
@@ -239,7 +269,7 @@ func TestDebugCallPanic(t *testing.T) {
}()
g := <-ready
- p, err := runtime.InjectDebugCall(g, func() { panic("test") }, nil, debugCallTKill, false)
+ p, err := runtime.InjectDebugCall(g, func() { panic("test") }, nil, nil, debugCallTKill, false)
if err != nil {
t.Fatal(err)
}