mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
database/sql: fix test on 32-bit
R=golang-codereviews TBR=golang-dev CC=golang-codereviews https://golang.org/cl/49920047
This commit is contained in:
parent
258ed3f226
commit
5f341df90d
1 changed files with 10 additions and 2 deletions
|
|
@ -8,6 +8,7 @@ import (
|
||||||
"database/sql/driver"
|
"database/sql/driver"
|
||||||
"fmt"
|
"fmt"
|
||||||
"reflect"
|
"reflect"
|
||||||
|
"runtime"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
@ -315,7 +316,14 @@ func TestRawBytesAllocs(t *testing.T) {
|
||||||
test("float64", float64(64), "64")
|
test("float64", float64(64), "64")
|
||||||
test("bool", false, "false")
|
test("bool", false, "false")
|
||||||
})
|
})
|
||||||
if n > 0.5 {
|
|
||||||
|
// The numbers below are only valid for 64-bit interface word sizes,
|
||||||
|
// and gc. With 32-bit words there are more convT2E allocs, and
|
||||||
|
// with gccgo, only pointers currently go in interface data.
|
||||||
|
// So only care on amd64 gc for now.
|
||||||
|
measureAllocs := runtime.GOARCH == "amd64" && runtime.Compiler == "gc"
|
||||||
|
|
||||||
|
if n > 0.5 && measureAllocs {
|
||||||
t.Fatalf("allocs = %v; want 0", n)
|
t.Fatalf("allocs = %v; want 0", n)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -323,7 +331,7 @@ func TestRawBytesAllocs(t *testing.T) {
|
||||||
n = testing.AllocsPerRun(100, func() {
|
n = testing.AllocsPerRun(100, func() {
|
||||||
test("string", "foo", "foo")
|
test("string", "foo", "foo")
|
||||||
})
|
})
|
||||||
if n > 1.5 {
|
if n > 1.5 && measureAllocs {
|
||||||
t.Fatalf("allocs = %v; want max 1", n)
|
t.Fatalf("allocs = %v; want max 1", n)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue