Skip to content

Commit c63aa96

Browse files
committed
update
Change-Id: I0cec341301c103b4c9a505906f00adfb72571b0d
1 parent 81fe51c commit c63aa96

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

src/crypto/rand/rand_test.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ import (
88
"bytes"
99
"compress/flate"
1010
"io"
11+
"runtime"
12+
"std/crypto/internal/boring"
13+
"std/runtime"
1114
"testing"
1215
)
1316

@@ -62,7 +65,11 @@ func benchmarkRead(b *testing.B, size int) {
6265
}
6366

6467
func TestReadAllocs(t *testing.T) {
65-
allocs := testing.AllocsPerRun(100, func() {
68+
if boring.Enabled || (runtime.GOOS == "js" && runtime.GOARCH == "wasm") {
69+
t.Skip("zero-allocs unsupported")
70+
}
71+
72+
allocs := testing.AllocsPerRun(1000, func() {
6673
buf := make([]byte, 32)
6774
Read(buf)
6875
})

src/crypto/rand/rand_unix.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,12 @@ const urandomDevice = "/dev/urandom"
2525

2626
var randReader = &reader{}
2727

28+
func init() {
29+
if boring.Enabled {
30+
Reader = boring.RandReader
31+
}
32+
}
33+
2834
// A reader satisfies reads by reading from urandomDevice
2935
type reader struct {
3036
f hideAgainFileReader

0 commit comments

Comments
 (0)