mirror of
https://github.com/glebarez/go-sqlite.git
synced 2025-10-05 15:56:52 +08:00
all_test.go - remove the temp db between scripts to prevent not quite closed/deleted/race.
malloc5.test - skip tests requiring memstats collection pager1.test - skip 2 tests in non-functional sets. snapshot_fault.test - skip test w/failing forcedelete testdata/tcl/tester.tcl - fix get_pwd to return output of 'cd'
This commit is contained in:
@@ -628,6 +628,13 @@ outer:
|
|||||||
t.Fatalf("%s\n%v", out, err)
|
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")
|
a := strings.Split(string(out), "\n")
|
||||||
for _, v := range a {
|
for _, v := range a {
|
||||||
if strings.HasPrefix(v, "Summary:") {
|
if strings.HasPrefix(v, "Summary:") {
|
||||||
|
18
testdata/tcl/malloc5.test
vendored
18
testdata/tcl/malloc5.test
vendored
@@ -219,6 +219,12 @@ puts "Highwater mark: [sqlite3_memory_highwater]"
|
|||||||
#
|
#
|
||||||
set ::soft_limit [sqlite3_soft_heap_limit -1]
|
set ::soft_limit [sqlite3_soft_heap_limit -1]
|
||||||
execsql {PRAGMA cache_size=2000}
|
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 {
|
do_test malloc5-4.1 {
|
||||||
execsql {BEGIN;}
|
execsql {BEGIN;}
|
||||||
execsql {DELETE FROM abc;}
|
execsql {DELETE FROM abc;}
|
||||||
@@ -234,6 +240,7 @@ do_test malloc5-4.1 {
|
|||||||
puts -nonewline " (Highwater mark: $nMaxBytes) "
|
puts -nonewline " (Highwater mark: $nMaxBytes) "
|
||||||
expr $nMaxBytes > 1000000
|
expr $nMaxBytes > 1000000
|
||||||
} {1}
|
} {1}
|
||||||
|
|
||||||
do_test malloc5-4.2 {
|
do_test malloc5-4.2 {
|
||||||
db eval {PRAGMA cache_size=1}
|
db eval {PRAGMA cache_size=1}
|
||||||
db cache flush
|
db cache flush
|
||||||
@@ -245,6 +252,7 @@ do_test malloc5-4.2 {
|
|||||||
puts -nonewline " (Highwater mark: $nMaxBytes) "
|
puts -nonewline " (Highwater mark: $nMaxBytes) "
|
||||||
expr $nMaxBytes <= 210000
|
expr $nMaxBytes <= 210000
|
||||||
} {1}
|
} {1}
|
||||||
|
|
||||||
do_test malloc5-4.3 {
|
do_test malloc5-4.3 {
|
||||||
# Check that the content of table abc is at least roughly as expected.
|
# Check that the content of table abc is at least roughly as expected.
|
||||||
execsql {
|
execsql {
|
||||||
@@ -252,6 +260,8 @@ do_test malloc5-4.3 {
|
|||||||
}
|
}
|
||||||
} [list 10000 [expr int(10000.0 * 4999.5)] [expr int(10000.0 * 4999.5)]]
|
} [list 10000 [expr int(10000.0 * 4999.5)] [expr int(10000.0 * 4999.5)]]
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
# Restore the soft heap limit.
|
# Restore the soft heap limit.
|
||||||
sqlite3_soft_heap_limit $::soft_limit
|
sqlite3_soft_heap_limit $::soft_limit
|
||||||
|
|
||||||
@@ -344,6 +354,12 @@ do_test malloc5-6.2.1 {
|
|||||||
expr [nPage db] + [nPage db2]
|
expr [nPage db] + [nPage db2]
|
||||||
} {4}
|
} {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 {
|
do_test malloc5-6.2.2 {
|
||||||
# If we now try to reclaim some memory, it should come from the db2 cache.
|
# If we now try to reclaim some memory, it should come from the db2 cache.
|
||||||
sqlite3_release_memory 3000
|
sqlite3_release_memory 3000
|
||||||
@@ -358,6 +374,8 @@ do_test malloc5-6.2.3 {
|
|||||||
expr [nPage db] + [nPage db2]
|
expr [nPage db] + [nPage db2]
|
||||||
} {0}
|
} {0}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
do_test malloc5-6.3.1 {
|
do_test malloc5-6.3.1 {
|
||||||
# Now open a transaction and update 2 pages in the db2 cache. Then
|
# 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
|
# do a SELECT on the db cache so that all the db pages are more recently
|
||||||
|
20
testdata/tcl/pager1.test
vendored
20
testdata/tcl/pager1.test
vendored
@@ -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
|
# up the file system to contain two databases, two hot-journal files and
|
||||||
# a master-journal.
|
# 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 {
|
do_test pager1.4.2.1 {
|
||||||
testvfs tstvfs -default 1
|
testvfs tstvfs -default 1
|
||||||
tstvfs filter xDelete
|
tstvfs filter xDelete
|
||||||
@@ -450,7 +455,7 @@ do_test pager1.4.2.1 {
|
|||||||
tstvfs delete
|
tstvfs delete
|
||||||
} {}
|
} {}
|
||||||
|
|
||||||
if {$::tcl_platform(platform)!="windows"} {
|
|
||||||
do_test pager1.4.2.2 {
|
do_test pager1.4.2.2 {
|
||||||
faultsim_restore_and_reopen
|
faultsim_restore_and_reopen
|
||||||
execsql {
|
execsql {
|
||||||
@@ -1688,11 +1693,15 @@ proc xSyncCb {method filename args} {
|
|||||||
faultsim_delete_and_reopen
|
faultsim_delete_and_reopen
|
||||||
db func a_string a_string
|
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
|
# 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
|
# journal. Since the cache-size is only 10 pages, the journal contains
|
||||||
# frequent journal headers.
|
# frequent journal headers.
|
||||||
#
|
#
|
||||||
do_execsql_test pager1-13.1.1 {
|
do_execsql_test pager1-13.1.1 {
|
||||||
PRAGMA page_size = 1024;
|
PRAGMA page_size = 1024;
|
||||||
PRAGMA journal_mode = PERSIST;
|
PRAGMA journal_mode = PERSIST;
|
||||||
PRAGMA cache_size = 10;
|
PRAGMA cache_size = 10;
|
||||||
@@ -1708,15 +1717,14 @@ do_execsql_test pager1-13.1.1 {
|
|||||||
INSERT INTO t1 SELECT NULL, a_string(400) FROM t1; /* 128 */
|
INSERT INTO t1 SELECT NULL, a_string(400) FROM t1; /* 128 */
|
||||||
COMMIT;
|
COMMIT;
|
||||||
UPDATE t1 SET b = a_string(400);
|
UPDATE t1 SET b = a_string(400);
|
||||||
} {persist}
|
} {persist}
|
||||||
|
|
||||||
if {$::tcl_platform(platform)!="windows"} {
|
|
||||||
# Run transactions of increasing sizes. Eventually, one (or more than one)
|
# 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
|
# 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
|
# by the transaction in the block above lies immediately after the content
|
||||||
# journalled by the current transaction.
|
# journalled by the current transaction.
|
||||||
#
|
#
|
||||||
for {set nUp 1} {$nUp<64} {incr nUp} {
|
for {set nUp 1} {$nUp<64} {incr nUp} {
|
||||||
do_execsql_test pager1-13.1.2.$nUp.1 {
|
do_execsql_test pager1-13.1.2.$nUp.1 {
|
||||||
UPDATE t1 SET b = a_string(399) WHERE a <= $nUp
|
UPDATE t1 SET b = a_string(399) WHERE a <= $nUp
|
||||||
} {}
|
} {}
|
||||||
@@ -1732,7 +1740,7 @@ for {set nUp 1} {$nUp<64} {incr nUp} {
|
|||||||
execsql { PRAGMA integrity_check } db2
|
execsql { PRAGMA integrity_check } db2
|
||||||
} {ok}
|
} {ok}
|
||||||
db2 close
|
db2 close
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if {$::tcl_platform(platform)!="windows"} {
|
if {$::tcl_platform(platform)!="windows"} {
|
||||||
|
7
testdata/tcl/snapshot_fault.test
vendored
7
testdata/tcl/snapshot_fault.test
vendored
@@ -22,6 +22,12 @@ set testprefix snapshot_fault
|
|||||||
# reading a corrupt snapshot even if a second client fails while
|
# reading a corrupt snapshot even if a second client fails while
|
||||||
# checkpointing the db.
|
# 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 {
|
do_faultsim_test 1.0 -prep {
|
||||||
faultsim_delete_and_reopen
|
faultsim_delete_and_reopen
|
||||||
sqlite3 db2 test.db
|
sqlite3 db2 test.db
|
||||||
@@ -60,6 +66,7 @@ do_faultsim_test 1.0 -prep {
|
|||||||
|
|
||||||
sqlite3_snapshot_free $::snapshot
|
sqlite3_snapshot_free $::snapshot
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
# This test is similar to the previous one. Except, after the
|
# This test is similar to the previous one. Except, after the
|
||||||
|
2
testdata/tcl/tester.tcl
vendored
2
testdata/tcl/tester.tcl
vendored
@@ -181,7 +181,7 @@ proc get_pwd {} {
|
|||||||
set comSpec {C:\Windows\system32\cmd.exe}
|
set comSpec {C:\Windows\system32\cmd.exe}
|
||||||
}
|
}
|
||||||
return [string map [list \\ /] \
|
return [string map [list \\ /] \
|
||||||
[string trim [exec -- $comSpec /c echo cd ]]]
|
[string trim [exec -- $comSpec /c cd ]]]
|
||||||
} else {
|
} else {
|
||||||
return [pwd]
|
return [pwd]
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user