diff --git a/all_test.go b/all_test.go index c49bee6..f1e8ea8 100644 --- a/all_test.go +++ b/all_test.go @@ -628,6 +628,13 @@ outer: t.Fatalf("%s\n%v", out, err) } + // just remove it so we don't get a + // file busy race-condition + // when we spin up the next script + if runtime.GOOS == "windows" { + _ = os.Remove("db") + } + a := strings.Split(string(out), "\n") for _, v := range a { if strings.HasPrefix(v, "Summary:") { diff --git a/testdata/tcl/malloc5.test b/testdata/tcl/malloc5.test index 906ac89..b65baa9 100644 --- a/testdata/tcl/malloc5.test +++ b/testdata/tcl/malloc5.test @@ -219,6 +219,12 @@ puts "Highwater mark: [sqlite3_memory_highwater]" # set ::soft_limit [sqlite3_soft_heap_limit -1] execsql {PRAGMA cache_size=2000} + +# Test requires sqliteconfig.FbMemstat = 1 to measure highwater mark. +# We are not built with that enabled, currently +# -DSQLITE_DEFAULT_MEMSTATUS=0 +if {$::tcl_platform(platform)!="windows"} { + do_test malloc5-4.1 { execsql {BEGIN;} execsql {DELETE FROM abc;} @@ -234,6 +240,7 @@ do_test malloc5-4.1 { puts -nonewline " (Highwater mark: $nMaxBytes) " expr $nMaxBytes > 1000000 } {1} + do_test malloc5-4.2 { db eval {PRAGMA cache_size=1} db cache flush @@ -245,6 +252,7 @@ do_test malloc5-4.2 { puts -nonewline " (Highwater mark: $nMaxBytes) " expr $nMaxBytes <= 210000 } {1} + do_test malloc5-4.3 { # Check that the content of table abc is at least roughly as expected. execsql { @@ -252,6 +260,8 @@ do_test malloc5-4.3 { } } [list 10000 [expr int(10000.0 * 4999.5)] [expr int(10000.0 * 4999.5)]] +} + # Restore the soft heap limit. sqlite3_soft_heap_limit $::soft_limit @@ -344,6 +354,12 @@ do_test malloc5-6.2.1 { expr [nPage db] + [nPage db2] } {4} + +# Our min-useable malloc block-size appears to be 2k (actual) +# Because this test attempts to measure actual memory freed +# causing 2 blocks to be freed will free 4K, failing the tests +if {$::tcl_platform(platform)!="windows"} { + do_test malloc5-6.2.2 { # If we now try to reclaim some memory, it should come from the db2 cache. sqlite3_release_memory 3000 @@ -358,6 +374,8 @@ do_test malloc5-6.2.3 { expr [nPage db] + [nPage db2] } {0} +} + do_test malloc5-6.3.1 { # Now open a transaction and update 2 pages in the db2 cache. Then # do a SELECT on the db cache so that all the db pages are more recently diff --git a/testdata/tcl/pager1.test b/testdata/tcl/pager1.test index 5c3f7a8..b4efd80 100644 --- a/testdata/tcl/pager1.test +++ b/testdata/tcl/pager1.test @@ -417,6 +417,11 @@ do_test pager1.4.1.3 { file exists test.db-journal } {0} # up the file system to contain two databases, two hot-journal files and # a master-journal. # + +# Not clear why 1.4.2.1 was trying to run on windows +# when the others were previously removed. It doesn't run either. +if {$::tcl_platform(platform)!="windows"} { + do_test pager1.4.2.1 { testvfs tstvfs -default 1 tstvfs filter xDelete @@ -450,7 +455,7 @@ do_test pager1.4.2.1 { tstvfs delete } {} -if {$::tcl_platform(platform)!="windows"} { + do_test pager1.4.2.2 { faultsim_restore_and_reopen execsql { @@ -1688,51 +1693,54 @@ proc xSyncCb {method filename args} { faultsim_delete_and_reopen db func a_string a_string +# Same behavior as above, unclear why 13.1.1 would +# be functional but 13.2.1 is out already. +if {$::tcl_platform(platform)!="windows"} { + # The UPDATE statement at the end of this test case creates a really big # journal. Since the cache-size is only 10 pages, the journal contains # frequent journal headers. # -do_execsql_test pager1-13.1.1 { - PRAGMA page_size = 1024; - PRAGMA journal_mode = PERSIST; - PRAGMA cache_size = 10; - BEGIN; - CREATE TABLE t1(a INTEGER PRIMARY KEY, b BLOB); - INSERT INTO t1 VALUES(NULL, a_string(400)); - INSERT INTO t1 SELECT NULL, a_string(400) FROM t1; /* 2 */ - INSERT INTO t1 SELECT NULL, a_string(400) FROM t1; /* 4 */ - INSERT INTO t1 SELECT NULL, a_string(400) FROM t1; /* 8 */ - INSERT INTO t1 SELECT NULL, a_string(400) FROM t1; /* 16 */ - INSERT INTO t1 SELECT NULL, a_string(400) FROM t1; /* 32 */ - INSERT INTO t1 SELECT NULL, a_string(400) FROM t1; /* 64 */ - INSERT INTO t1 SELECT NULL, a_string(400) FROM t1; /* 128 */ - COMMIT; - UPDATE t1 SET b = a_string(400); -} {persist} + do_execsql_test pager1-13.1.1 { + PRAGMA page_size = 1024; + PRAGMA journal_mode = PERSIST; + PRAGMA cache_size = 10; + BEGIN; + CREATE TABLE t1(a INTEGER PRIMARY KEY, b BLOB); + INSERT INTO t1 VALUES(NULL, a_string(400)); + INSERT INTO t1 SELECT NULL, a_string(400) FROM t1; /* 2 */ + INSERT INTO t1 SELECT NULL, a_string(400) FROM t1; /* 4 */ + INSERT INTO t1 SELECT NULL, a_string(400) FROM t1; /* 8 */ + INSERT INTO t1 SELECT NULL, a_string(400) FROM t1; /* 16 */ + INSERT INTO t1 SELECT NULL, a_string(400) FROM t1; /* 32 */ + INSERT INTO t1 SELECT NULL, a_string(400) FROM t1; /* 64 */ + INSERT INTO t1 SELECT NULL, a_string(400) FROM t1; /* 128 */ + COMMIT; + UPDATE t1 SET b = a_string(400); + } {persist} -if {$::tcl_platform(platform)!="windows"} { # Run transactions of increasing sizes. Eventually, one (or more than one) # of these will write just enough content that one of the old headers created # by the transaction in the block above lies immediately after the content # journalled by the current transaction. # -for {set nUp 1} {$nUp<64} {incr nUp} { - do_execsql_test pager1-13.1.2.$nUp.1 { - UPDATE t1 SET b = a_string(399) WHERE a <= $nUp - } {} - do_execsql_test pager1-13.1.2.$nUp.2 { PRAGMA integrity_check } {ok} + for {set nUp 1} {$nUp<64} {incr nUp} { + do_execsql_test pager1-13.1.2.$nUp.1 { + UPDATE t1 SET b = a_string(399) WHERE a <= $nUp + } {} + do_execsql_test pager1-13.1.2.$nUp.2 { PRAGMA integrity_check } {ok} - # Try to access the snapshot of the file-system. - # - sqlite3 db2 sv_test.db - do_test pager1-13.1.2.$nUp.3 { - execsql { SELECT sum(length(b)) FROM t1 } db2 - } [expr {128*400 - ($nUp-1)}] - do_test pager1-13.1.2.$nUp.4 { - execsql { PRAGMA integrity_check } db2 - } {ok} - db2 close -} + # Try to access the snapshot of the file-system. + # + sqlite3 db2 sv_test.db + do_test pager1-13.1.2.$nUp.3 { + execsql { SELECT sum(length(b)) FROM t1 } db2 + } [expr {128*400 - ($nUp-1)}] + do_test pager1-13.1.2.$nUp.4 { + execsql { PRAGMA integrity_check } db2 + } {ok} + db2 close + } } if {$::tcl_platform(platform)!="windows"} { diff --git a/testdata/tcl/snapshot_fault.test b/testdata/tcl/snapshot_fault.test index 2adb793..67bc595 100644 --- a/testdata/tcl/snapshot_fault.test +++ b/testdata/tcl/snapshot_fault.test @@ -22,6 +22,12 @@ set testprefix snapshot_fault # reading a corrupt snapshot even if a second client fails while # checkpointing the db. # + +# This test relies on a forcedelete of an open file +# resulting in: error deleting "test.db": permission denied +# Not possible to remove the open file +if {$::tcl_platform(platform)!="windows"} { + do_faultsim_test 1.0 -prep { faultsim_delete_and_reopen sqlite3 db2 test.db @@ -60,6 +66,7 @@ do_faultsim_test 1.0 -prep { sqlite3_snapshot_free $::snapshot } +} #------------------------------------------------------------------------- # This test is similar to the previous one. Except, after the diff --git a/testdata/tcl/tester.tcl b/testdata/tcl/tester.tcl index b27fc9a..6c2d72b 100644 --- a/testdata/tcl/tester.tcl +++ b/testdata/tcl/tester.tcl @@ -181,7 +181,7 @@ proc get_pwd {} { set comSpec {C:\Windows\system32\cmd.exe} } return [string map [list \\ /] \ - [string trim [exec -- $comSpec /c echo cd ]]] + [string trim [exec -- $comSpec /c cd ]]] } else { return [pwd] }