Commit 746114df authored by gwenn's avatar gwenn

Skip some tests when cgocheck is enabled.

parent 40f42098
......@@ -15,4 +15,5 @@ install:
before_script:
- go get github.com/bmizerany/assert
script:
- GODEBUG=cgocheck=2 go test -v -tags all github.com/gwenn/gosqlite
- GODEBUG=cgocheck=0 go test -v -tags all github.com/gwenn/gosqlite
......@@ -15,6 +15,8 @@ import (
)
func TestInterrupt(t *testing.T) {
skipIfCgoCheckActive(t)
db := open(t)
defer checkClose(db, t)
db.CreateScalarFunction("interrupt", 0, false, nil, func(ctx *ScalarContext, nArg int) {
......@@ -85,6 +87,8 @@ func TestBusyTimeout(t *testing.T) {
}
func TestBusyHandler(t *testing.T) {
skipIfCgoCheckActive(t)
f, db1, db2 := openTwoConnSameDb(t)
defer os.Remove(f.Name())
defer checkClose(db1, t)
......
......@@ -5,8 +5,8 @@
package sqlite_test
import (
"testing"
. "github.com/gwenn/gosqlite"
"testing"
)
func checkCacheSize(t *testing.T, db *Conn, expectedSize, expectedMaxSize int) {
......
......@@ -17,6 +17,8 @@ import (
)
func TestCsvModule(t *testing.T) {
skipIfCgoCheckActive(t)
db := open(t)
defer checkClose(db, t)
err := LoadCsvModule(db)
......@@ -112,6 +114,8 @@ var csvModuleTests = []struct {
}
func TestCsvModuleArguments(t *testing.T) {
skipIfCgoCheckActive(t)
db := open(t)
defer checkClose(db, t)
err := LoadCsvModule(db)
......
......@@ -24,6 +24,8 @@ func half(ctx *ScalarContext, nArg int) {
}
func TestScalarFunction(t *testing.T) {
skipIfCgoCheckActive(t)
db := open(t)
defer checkClose(db, t)
err := db.CreateScalarFunction("half", 1, true, nil, half, nil)
......@@ -71,6 +73,8 @@ func reDestroy(ad interface{}) {
}
func TestRegexpFunction(t *testing.T) {
skipIfCgoCheckActive(t)
db := open(t)
defer checkClose(db, t)
err := db.CreateScalarFunction("regexp", 2, true, nil, re, reDestroy)
......@@ -106,6 +110,8 @@ func user(ctx *ScalarContext, nArg int) {
}
func TestUserFunction(t *testing.T) {
skipIfCgoCheckActive(t)
db := open(t)
defer checkClose(db, t)
err := db.CreateScalarFunction("user", 0, false, nil, user, nil)
......@@ -140,6 +146,8 @@ func sumFinal(ctx *AggregateContext) {
}
func TestSumFunction(t *testing.T) {
skipIfCgoCheckActive(t)
db := open(t)
defer checkClose(db, t)
err := db.CreateAggregateFunction("mysum", 1, nil, sumStep, sumFinal, nil)
......
......@@ -7,6 +7,7 @@ package sqlite_test
import (
"fmt"
"testing"
. "github.com/gwenn/gosqlite"
)
......@@ -44,6 +45,8 @@ func TestNoHook(t *testing.T) {
}
func TestCommitHook(t *testing.T) {
skipIfCgoCheckActive(t)
db := open(t)
defer checkClose(db, t)
......@@ -54,6 +57,8 @@ func TestCommitHook(t *testing.T) {
}
func TestRollbackHook(t *testing.T) {
skipIfCgoCheckActive(t)
db := open(t)
defer checkClose(db, t)
......@@ -64,6 +69,8 @@ func TestRollbackHook(t *testing.T) {
}
func TestUpdateHook(t *testing.T) {
skipIfCgoCheckActive(t)
db := open(t)
defer checkClose(db, t)
createTable(db, t)
......
......@@ -6,6 +6,7 @@ package sqlite_test
import (
"fmt"
"os"
"path"
"reflect"
"runtime"
......@@ -23,6 +24,12 @@ func checkNoError(t *testing.T, err error, format string) {
}
}
func skipIfCgoCheckActive(t *testing.T) {
if runtime.Version() >= "go1.6" && !strings.Contains(os.Getenv("GODEBUG"), "cgocheck=0") {
t.Skip("cgocheck")
}
}
func Must(b bool, err error) bool {
if err != nil {
panic(err)
......
......@@ -382,11 +382,11 @@ func (s *Stmt) BindByIndex(index int, value interface{}) error {
if i64 && len(value) > math.MaxInt32 {
return s.specificError("blob too big: %d at index %d", len(value), index)
}
var p *byte
if len(value) > 0 {
p = &value[0]
if len(value) == 0 {
rv = C.my_bind_blob(s.stmt, i, nil, 0)
} else {
rv = C.my_bind_blob(s.stmt, i, unsafe.Pointer(&value[0]), C.int(len(value)))
}
rv = C.my_bind_blob(s.stmt, i, unsafe.Pointer(p), C.int(len(value)))
case time.Time:
if NullIfZeroTime && value.IsZero() {
rv = C.sqlite3_bind_null(s.stmt, i)
......
......@@ -17,12 +17,12 @@ import (
func init() {
if os.Getenv("SQLITE_LOG") == "" {
err := ConfigLog(func(d interface{}, err error, msg string) {
fmt.Printf("%s: %s, %s\n", d, err, msg)
}, "SQLITE")
fmt.Printf("SQLITE: %s, %s\n", err, msg)
}, nil)
if err != nil {
panic(fmt.Sprintf("couldn't config log: '%s'", err))
}
err = ConfigLog(nil, "")
err = ConfigLog(nil, nil)
if err != nil {
panic(fmt.Sprintf("couldn't unset logger: '%s'", err))
}
......@@ -74,6 +74,8 @@ func TestNoTrace(t *testing.T) {
}
func TestTrace(t *testing.T) {
skipIfCgoCheckActive(t)
db := open(t)
defer checkClose(db, t)
db.Trace(trace, t)
......@@ -88,6 +90,8 @@ func TestTrace(t *testing.T) {
}
func TestProfile(t *testing.T) {
skipIfCgoCheckActive(t)
db := open(t)
defer checkClose(db, t)
db.Profile(profile, t)
......
......@@ -99,6 +99,8 @@ func (vc *testVTabCursor) Rowid() (int64, error) {
}
func TestCreateModule(t *testing.T) {
skipIfCgoCheckActive(t)
db := open(t)
defer checkClose(db, t)
intarray := []int{1, 2, 3}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment