aboutsummaryrefslogtreecommitdiff
path: root/src/pkg/database/sql
diff options
context:
space:
mode:
authorBrad Fitzpatrick <bradfitz@golang.org>2014-01-10 12:30:23 -0800
committerBrad Fitzpatrick <bradfitz@golang.org>2014-01-10 12:30:23 -0800
commit5f341df90d0c156e4e8af3fc6e6de336faa64aa5 (patch)
tree077d4bae4b6504c2f65869e27c626c26939c5406 /src/pkg/database/sql
parent258ed3f2265a41a46e936e884d8afd6e6f646973 (diff)
downloadgo-5f341df90d0c156e4e8af3fc6e6de336faa64aa5.tar.xz
database/sql: fix test on 32-bit
R=golang-codereviews TBR=golang-dev CC=golang-codereviews https://golang.org/cl/49920047
Diffstat (limited to 'src/pkg/database/sql')
-rw-r--r--src/pkg/database/sql/convert_test.go12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/pkg/database/sql/convert_test.go b/src/pkg/database/sql/convert_test.go
index aa0b6f116a..6e24830128 100644
--- a/src/pkg/database/sql/convert_test.go
+++ b/src/pkg/database/sql/convert_test.go
@@ -8,6 +8,7 @@ import (
"database/sql/driver"
"fmt"
"reflect"
+ "runtime"
"testing"
"time"
)
@@ -315,7 +316,14 @@ func TestRawBytesAllocs(t *testing.T) {
test("float64", float64(64), "64")
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)
}
@@ -323,7 +331,7 @@ func TestRawBytesAllocs(t *testing.T) {
n = testing.AllocsPerRun(100, func() {
test("string", "foo", "foo")
})
- if n > 1.5 {
+ if n > 1.5 && measureAllocs {
t.Fatalf("allocs = %v; want max 1", n)
}
}