Skip to content

Commit 91c6f64

Browse files
committed
tests
1 parent b24cdfa commit 91c6f64

11 files changed

Lines changed: 78 additions & 101 deletions

File tree

config.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ func (c *Conn) ConfigLog(cb func(code ExtendedErrorCode, msg string)) error {
7171
return nil
7272
}
7373

74-
func (e *env) Xgo_log(_, iCode, zMsg int32) {
74+
func (e env) Xgo_log(_, iCode, zMsg int32) {
7575
if c, ok := e.DB.(*Conn); ok && c.log != nil {
7676
msg := e.ReadString(ptr_t(zMsg), _MAX_LENGTH)
7777
c.log(xErrorCode(iCode), msg)
@@ -213,7 +213,7 @@ func (c *Conn) SetAuthorizer(cb func(action AuthorizerActionCode, name3rd, name4
213213
return nil
214214
}
215215

216-
func (e *env) Xgo_authorizer(pDB, action, zName3rd, zName4th, zSchema, zInner int32) (rc int32) {
216+
func (e env) Xgo_authorizer(pDB, action, zName3rd, zName4th, zSchema, zInner int32) (rc int32) {
217217
if c, ok := e.DB.(*Conn); ok && c.handle == ptr_t(pDB) && c.authorizer != nil {
218218
var name3rd, name4th, schema, inner string
219219
if zName3rd != 0 {
@@ -245,7 +245,7 @@ func (c *Conn) Trace(mask TraceEvent, cb func(evt TraceEvent, arg1 any, arg2 any
245245
return nil
246246
}
247247

248-
func (e *env) Xgo_trace(evt, pDB, pArg1, pArg2 int32) int32 {
248+
func (e env) Xgo_trace(evt, pDB, pArg1, pArg2 int32) int32 {
249249
if c, ok := e.DB.(*Conn); ok && c.handle == ptr_t(pDB) && c.trace != nil {
250250
var arg1, arg2 any
251251
if TraceEvent(evt) == TRACE_CLOSE {
@@ -312,7 +312,7 @@ func (c *Conn) WALHook(cb func(db *Conn, schema string, pages int) error) {
312312
c.wal = cb
313313
}
314314

315-
func (e *env) Xgo_wal_hook(_, pDB, zSchema, pages int32) int32 {
315+
func (e env) Xgo_wal_hook(_, pDB, zSchema, pages int32) int32 {
316316
if c, ok := e.DB.(*Conn); ok && c.handle == ptr_t(pDB) && c.wal != nil {
317317
schema := e.ReadString(ptr_t(zSchema), _MAX_NAME)
318318
err := c.wal(c, schema, int(pages))
@@ -334,7 +334,7 @@ func (c *Conn) AutoVacuumPages(cb func(schema string, dbPages, freePages, bytesP
334334
return c.error(rc)
335335
}
336336

337-
func (e *env) Xgo_autovacuum_pages(pApp, zSchema, nDbPage, nFreePage, nBytePerPage int32) int32 {
337+
func (e env) Xgo_autovacuum_pages(pApp, zSchema, nDbPage, nFreePage, nBytePerPage int32) int32 {
338338
fn := e.GetHandle(ptr_t(pApp)).(func(schema string, dbPages, freePages, bytesPerPage uint) uint)
339339
schema := e.ReadString(ptr_t(zSchema), _MAX_NAME)
340340
return int32(fn(schema, uint(uint32(nDbPage)), uint(uint32(nFreePage)), uint(uint32(nBytePerPage))))

conn.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ func (c *Conn) SetInterrupt(ctx context.Context) (old context.Context) {
347347
return old
348348
}
349349

350-
func (e *env) Xgo_progress_handler(_ int32) (interrupt int32) {
350+
func (e env) Xgo_progress_handler(_ int32) (interrupt int32) {
351351
if c, ok := e.DB.(*Conn); ok {
352352
if c.gosched++; c.gosched%16 == 0 {
353353
runtime.Gosched()
@@ -368,7 +368,7 @@ func (c *Conn) BusyTimeout(timeout time.Duration) error {
368368
return c.error(rc)
369369
}
370370

371-
func (e *env) Xgo_busy_timeout(count, tmout int32) (retry int32) {
371+
func (e env) Xgo_busy_timeout(count, tmout int32) (retry int32) {
372372
// https://fractaledmind.github.io/2024/04/15/sqlite-on-rails-the-how-and-why-of-optimal-performance/
373373
if c, ok := e.DB.(*Conn); ok && c.interrupt.Err() == nil {
374374
switch {
@@ -403,7 +403,7 @@ func (c *Conn) BusyHandler(cb func(ctx context.Context, count int) (retry bool))
403403
return nil
404404
}
405405

406-
func (e *env) Xgo_busy_handler(pDB, count int32) (retry int32) {
406+
func (e env) Xgo_busy_handler(pDB, count int32) (retry int32) {
407407
if c, ok := e.DB.(*Conn); ok && c.handle == ptr_t(pDB) && c.busy != nil {
408408
if interrupt := c.interrupt; interrupt.Err() == nil &&
409409
c.busy(interrupt, int(count)) {

func.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -175,41 +175,41 @@ func (c *Conn) OverloadFunction(name string, nArg int) error {
175175
return c.error(rc)
176176
}
177177

178-
func (e *env) Xgo_destroy(pApp int32) {
178+
func (e env) Xgo_destroy(pApp int32) {
179179
e.DelHandle(ptr_t(pApp))
180180
}
181181

182-
func (e *env) Xgo_collation_needed(pArg, pDB, eTextRep, zName int32) {
182+
func (e env) Xgo_collation_needed(pArg, pDB, eTextRep, zName int32) {
183183
if c, ok := e.DB.(*Conn); ok && c.handle == ptr_t(pDB) && c.collation != nil {
184184
name := e.ReadString(ptr_t(zName), _MAX_NAME)
185185
c.collation(c, name)
186186
}
187187
}
188188

189-
func (e *env) Xgo_compare(pApp, nKey1, pKey1, nKey2, pKey2 int32) int32 {
189+
func (e env) Xgo_compare(pApp, nKey1, pKey1, nKey2, pKey2 int32) int32 {
190190
fn := e.GetHandle(ptr_t(pApp)).(CollatingFunction)
191191
return int32(fn(
192192
e.Slice(ptr_t(pKey1), int64(nKey1)),
193193
e.Slice(ptr_t(pKey2), int64(nKey2))))
194194
}
195195

196-
func (e *env) Xgo_func(pCtx, pApp, nArg, pArg int32) {
196+
func (e env) Xgo_func(pCtx, pApp, nArg, pArg int32) {
197197
db := e.DB.(*Conn)
198198
args := callbackArgs(db, nArg, ptr_t(pArg))
199199
defer returnArgs(args)
200200
fn := db.wrp.GetHandle(ptr_t(pApp)).(ScalarFunction)
201201
fn(Context{db, ptr_t(pCtx)}, *args...)
202202
}
203203

204-
func (e *env) Xgo_step(pCtx, pAgg, pApp, nArg, pArg int32) {
204+
func (e env) Xgo_step(pCtx, pAgg, pApp, nArg, pArg int32) {
205205
db := e.DB.(*Conn)
206206
args := callbackArgs(db, nArg, ptr_t(pArg))
207207
defer returnArgs(args)
208208
fn, _ := callbackAggregate(db, ptr_t(pAgg), ptr_t(pApp))
209209
fn.Step(Context{db, ptr_t(pCtx)}, *args...)
210210
}
211211

212-
func (e *env) Xgo_value(pCtx, pAgg, pApp, final int32) {
212+
func (e env) Xgo_value(pCtx, pAgg, pApp, final int32) {
213213
db := e.DB.(*Conn)
214214
fn, handle := callbackAggregate(db, ptr_t(pAgg), ptr_t(pApp))
215215
fn.Value(Context{db, ptr_t(pCtx)})
@@ -229,7 +229,7 @@ func (e *env) Xgo_value(pCtx, pAgg, pApp, final int32) {
229229
}
230230
}
231231

232-
func (e *env) Xgo_inverse(pCtx, pAgg, nArg, pArg int32) {
232+
func (e env) Xgo_inverse(pCtx, pAgg, nArg, pArg int32) {
233233
db := e.DB.(*Conn)
234234
args := callbackArgs(db, nArg, ptr_t(pArg))
235235
defer returnArgs(args)

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module github.com/ncruces/go-sqlite3
33
go 1.24.0
44

55
require (
6-
github.com/ncruces/go-sqlite3-wasm v0.0.0-20260310124923-e9f6573b07f1
6+
github.com/ncruces/go-sqlite3-wasm v0.0.0-20260312160048-b96020e92601
77
github.com/ncruces/julianday v1.0.0
88
github.com/ncruces/sort v0.1.6
99
github.com/ncruces/wbt v1.0.0

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ github.com/dchest/siphash v1.2.3 h1:QXwFc8cFOR2dSa/gE6o/HokBMWtLUaNDVd+22aKHeEA=
22
github.com/dchest/siphash v1.2.3/go.mod h1:0NvQU092bT0ipiFN++/rXm69QG9tVxLAlQHIXMPAkHc=
33
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
44
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
5-
github.com/ncruces/go-sqlite3-wasm v0.0.0-20260310124923-e9f6573b07f1 h1:nym9A7xjRY5E2COhiN+KsN7UyVdBslWNYivLIuLrv5c=
6-
github.com/ncruces/go-sqlite3-wasm v0.0.0-20260310124923-e9f6573b07f1/go.mod h1:CLtq3B4C0mgdclnRUUkn4pLYYo1MsugQNXWjjAIxoPo=
5+
github.com/ncruces/go-sqlite3-wasm v0.0.0-20260312160048-b96020e92601 h1:XHbLfN7k+bFuWz9OWfZVert0feJUAs/ngRewsn3EW4I=
6+
github.com/ncruces/go-sqlite3-wasm v0.0.0-20260312160048-b96020e92601/go.mod h1:CLtq3B4C0mgdclnRUUkn4pLYYo1MsugQNXWjjAIxoPo=
77
github.com/ncruces/julianday v1.0.0 h1:fH0OKwa7NWvniGQtxdJRxAgkBMolni2BjDHaWTxqt7M=
88
github.com/ncruces/julianday v1.0.0/go.mod h1:Dusn2KvZrrovOMJuOt0TNXL6tB7U2E8kvza5fFc9G7g=
99
github.com/ncruces/sort v0.1.6 h1:TrsJfGRH1AoWoaeB4/+gCohot9+cA6u/INaH5agIhNk=

txn.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ func (c *Conn) UpdateHook(cb func(action AuthorizerActionCode, schema, table str
264264
c.update = cb
265265
}
266266

267-
func (e *env) Xgo_commit_hook(pDB int32) (rollback int32) {
267+
func (e env) Xgo_commit_hook(pDB int32) (rollback int32) {
268268
if c, ok := e.DB.(*Conn); ok && c.handle == ptr_t(pDB) && c.commit != nil {
269269
if !c.commit() {
270270
rollback = 1
@@ -273,13 +273,13 @@ func (e *env) Xgo_commit_hook(pDB int32) (rollback int32) {
273273
return rollback
274274
}
275275

276-
func (e *env) Xgo_rollback_hook(pDB int32) {
276+
func (e env) Xgo_rollback_hook(pDB int32) {
277277
if c, ok := e.DB.(*Conn); ok && c.handle == ptr_t(pDB) && c.rollback != nil {
278278
c.rollback()
279279
}
280280
}
281281

282-
func (e *env) Xgo_update_hook(pDB, action, zSchema, zTabName int32, rowid int64) {
282+
func (e env) Xgo_update_hook(pDB, action, zSchema, zTabName int32, rowid int64) {
283283
if c, ok := e.DB.(*Conn); ok && c.handle == ptr_t(pDB) && c.update != nil {
284284
schema := e.ReadString(ptr_t(zSchema), _MAX_NAME)
285285
table := e.ReadString(ptr_t(zTabName), _MAX_NAME)

vfs/tests/mptest/mptest_test.go

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
//go:build mptest
2-
31
package mptest
42

53
import (
@@ -11,6 +9,7 @@ import (
119

1210
_ "github.com/ncruces/go-sqlite3"
1311
"github.com/ncruces/go-sqlite3/internal/sqlite3_wrap"
12+
"github.com/ncruces/go-sqlite3/internal/testutil"
1413
"github.com/ncruces/go-sqlite3/vfs"
1514
_ "github.com/ncruces/go-sqlite3/vfs/adiantum"
1615
"github.com/ncruces/go-sqlite3/vfs/memdb"
@@ -20,21 +19,15 @@ import (
2019
_ "github.com/ncruces/go-sqlite3/vfs/xts"
2120
)
2221

23-
const (
24-
ptrlen = sqlite3_wrap.PtrLen
25-
intlen = sqlite3_wrap.IntLen
26-
)
22+
const ptrlen = sqlite3_wrap.PtrLen
2723

28-
type (
29-
ptr_t = sqlite3_wrap.Ptr_t
30-
res_t = sqlite3_wrap.Res_t
31-
)
24+
type ptr_t = sqlite3_wrap.Ptr_t
3225

3326
//go:linkname createWrapper github.com/ncruces/go-sqlite3.createWrapper
3427
func createWrapper(ctx context.Context) (*sqlite3_wrap.Wrapper, error)
3528

3629
func runTest(t *testing.T, args ...string) {
37-
wrp, err := createWrapper(t.Context())
30+
wrp, err := createWrapper(testutil.Context(t))
3831
if err != nil {
3932
t.Fatal(err)
4033
}
@@ -45,8 +38,8 @@ func runTest(t *testing.T, args ...string) {
4538
wrp.Write32(argv+ptr_t(i)*ptrlen, uint32(wrp.NewString(a)))
4639
}
4740

48-
if c := wrp.X__main_argc_argv(int32(len(args)), int32(argv)); c != 0 {
49-
t.Error("exit error:", c)
41+
if c := wrp.Xmain_mptest(int32(len(args)), int32(argv)); c != 0 {
42+
t.Error("exit error: ", c)
5043
}
5144
}
5245

vfs/tests/speedtest1/speedtest1_test.go

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
//go:build speedtest1
2-
31
package speedtest1
42

53
import (
@@ -21,15 +19,9 @@ import (
2119
_ "github.com/ncruces/go-sqlite3/vfs/xts"
2220
)
2321

24-
const (
25-
ptrlen = sqlite3_wrap.PtrLen
26-
intlen = sqlite3_wrap.IntLen
27-
)
22+
const ptrlen = sqlite3_wrap.PtrLen
2823

29-
type (
30-
ptr_t = sqlite3_wrap.Ptr_t
31-
res_t = sqlite3_wrap.Res_t
32-
)
24+
type ptr_t = sqlite3_wrap.Ptr_t
3325

3426
//go:linkname createWrapper github.com/ncruces/go-sqlite3.createWrapper
3527
func createWrapper(ctx context.Context) (*sqlite3_wrap.Wrapper, error)
@@ -79,7 +71,7 @@ func runBenchmark(b *testing.B, args ...string) {
7971
wrp.Write32(argv+ptr_t(i)*ptrlen, uint32(wrp.NewString(a)))
8072
}
8173

82-
wrp.X__main_argc_argv(int32(len(args)), int32(argv))
74+
wrp.Xmain_speedtest1(int32(len(args)), int32(argv))
8375
}
8476

8577
func Benchmark_speedtest1(b *testing.B) {

0 commit comments

Comments
 (0)