mirror of https://github.com/sqlite/sqlite
Improve the coverage of wal.c provided by the "coverage-wal" test permutation.
FossilOrigin-Name: 6231485114eb07b258cd0e6e163ca05f7e9cf5664e071808fcb1329b33e4c4f5
This commit is contained in:
parent
6a509d56bc
commit
8d69a58119
15
manifest
15
manifest
|
@ -1,5 +1,5 @@
|
|||
C Catch\sanother\scase\sof\sa\scorrupted\sstructure\srecord\sin\sfts5.
|
||||
D 2018-12-22T19:54:17.603
|
||||
C Improve\sthe\scoverage\sof\swal.c\sprovided\sby\sthe\s"coverage-wal"\stest\spermutation.
|
||||
D 2018-12-22T20:32:28.027
|
||||
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
|
||||
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
|
||||
F Makefile.in d8b254f8bb81bab43c340d70d17dc3babab40fcc8a348c8255881f780a45fee6
|
||||
|
@ -566,7 +566,7 @@ F src/test_syscall.c 1073306ba2e9bfc886771871a13d3de281ed3939
|
|||
F src/test_tclsh.c 06317648b0d85a85fd823f7973b55535c59a3156c1ef59394fe511f932cfa78d
|
||||
F src/test_tclvar.c 33ff42149494a39c5fbb0df3d25d6fafb2f668888e41c0688d07273dcb268dfc
|
||||
F src/test_thread.c 911d15fb14e19c0c542bdc8aabf981c2f10a4858
|
||||
F src/test_vfs.c 112f1f9271c33c211812e0e681830a84262dac065da58579ff49f9cefec97d4f
|
||||
F src/test_vfs.c 4e31a7b98a401431c55590a0ac05f001f520f716d0707ec916b4022b8937fd06
|
||||
F src/test_vfstrace.c bab9594adc976cbe696ff3970728830b4c5ed698
|
||||
F src/test_windirent.c a895e2c068a06644eef91a7f0a32182445a893b9a0f33d0cdb4283dca2486ac1
|
||||
F src/test_windirent.h 90dfbe95442c9762357fe128dc7ae3dc199d006de93eb33ba3972e0a90484215
|
||||
|
@ -1187,7 +1187,7 @@ F test/parser1.test 6ccdf5e459a5dc4673d3273dc311a7e9742ca952dd0551a6a6320d27035c
|
|||
F test/pcache.test c8acbedd3b6fd0f9a7ca887a83b11d24a007972b
|
||||
F test/pcache2.test af7f3deb1a819f77a6d0d81534e97d1cf62cd442
|
||||
F test/percentile.test 4243af26b8f3f4555abe166f723715a1f74c77ff
|
||||
F test/permutations.test cf0b4e498db1d0143c19641d4420df7cc27fab2c95ed0abd2c7c5753beab25b8
|
||||
F test/permutations.test 1f244543fbf05f3ef9a4596d7e7fe5d832b6d973c53a87189515e3c15db562a5
|
||||
F test/pg_common.tcl 301ac19c1a52fd55166d26db929b3b89165c634d52b5f8ad76ea8cb06960db30
|
||||
F test/pragma.test c267bf02742c823a191960895b3d52933cebd7beee26757d1ed694f213fcd867
|
||||
F test/pragma2.test e5d5c176360c321344249354c0c16aec46214c9f
|
||||
|
@ -1632,6 +1632,7 @@ F test/walrofault.test c70cb6e308c443867701856cce92ad8288cd99488fa52afab77cca6cf
|
|||
F test/walshared.test 0befc811dcf0b287efae21612304d15576e35417
|
||||
F test/walslow.test c05c68d4dc2700a982f89133ce103a1a84cc285f
|
||||
F test/walthread.test 14b20fcfa6ae152f5d8e12f5dc8a8a724b7ef189f5d8ef1e2ceab79f2af51747
|
||||
F test/walvfs.test 0e24b923a772f4f118bd717cbce5a4f3ca072c36d0bb1775e59802e6415e5f1b
|
||||
F test/where.test 8215d220633f08da331781cf9ede7fb7aed50eb113473c10acd39a643fd258ba
|
||||
F test/where2.test 478d2170637b9211f593120648858593bf2445a1
|
||||
F test/where3.test 2341a294e17193a6b1699ea7f192124a5286ca6acfcc3f4b06d16c931fbcda2c
|
||||
|
@ -1791,7 +1792,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
|
|||
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
|
||||
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
|
||||
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
|
||||
P 1daaba9fb46706af8ed0669a661c304df999a69cf639d29d93208f422c515d8c
|
||||
R 5960228be3c9531216b806a862f5738c
|
||||
P fb17fea4b9779fbd3adb6ff9500da83a6ca4fa7cba379aa70074e4328814a7f2
|
||||
R 5ce80528daf81279c922499c0aa02e3a
|
||||
U dan
|
||||
Z ddba0f88396ce302c3a65c1bd58721ed
|
||||
Z 726829f36755ef843b888b06987bbace
|
||||
|
|
|
@ -1 +1 @@
|
|||
fb17fea4b9779fbd3adb6ff9500da83a6ca4fa7cba379aa70074e4328814a7f2
|
||||
6231485114eb07b258cd0e6e163ca05f7e9cf5664e071808fcb1329b33e4c4f5
|
|
@ -228,11 +228,12 @@ static int tvfsResultCode(Testvfs *p, int *pRc){
|
|||
int eCode;
|
||||
const char *zCode;
|
||||
} aCode[] = {
|
||||
{ SQLITE_OK, "SQLITE_OK" },
|
||||
{ SQLITE_ERROR, "SQLITE_ERROR" },
|
||||
{ SQLITE_IOERR, "SQLITE_IOERR" },
|
||||
{ SQLITE_LOCKED, "SQLITE_LOCKED" },
|
||||
{ SQLITE_BUSY, "SQLITE_BUSY" },
|
||||
{ SQLITE_OK, "SQLITE_OK" },
|
||||
{ SQLITE_ERROR, "SQLITE_ERROR" },
|
||||
{ SQLITE_IOERR, "SQLITE_IOERR" },
|
||||
{ SQLITE_LOCKED, "SQLITE_LOCKED" },
|
||||
{ SQLITE_BUSY, "SQLITE_BUSY" },
|
||||
{ SQLITE_READONLY, "SQLITE_READONLY" },
|
||||
};
|
||||
|
||||
const char *z;
|
||||
|
@ -865,7 +866,7 @@ static int tvfsShmOpen(sqlite3_file *pFile){
|
|||
pFd->pNext = pBuffer->pFile;
|
||||
pBuffer->pFile = pFd;
|
||||
pFd->pShm = pBuffer;
|
||||
return SQLITE_OK;
|
||||
return rc;
|
||||
}
|
||||
|
||||
static void tvfsAllocPage(TestvfsBuffer *p, int iPage, int pgsz){
|
||||
|
|
|
@ -430,10 +430,15 @@ lappend ::testsuitelist xxx
|
|||
test_suite "coverage-wal" -description {
|
||||
Coverage tests for file wal.c.
|
||||
} -files {
|
||||
wal.test wal2.test wal3.test walmode.test
|
||||
walbak.test walhook.test walcrash2.test walcksum.test
|
||||
walfault.test walbig.test walnoshm.test
|
||||
wal5.test
|
||||
wal.test wal2.test wal3.test wal4.test wal5.test
|
||||
wal64k.test wal6.test wal7.test wal8.test wal9.test
|
||||
walbak.test walbig.test walblock.test walcksum.test walcrash2.test
|
||||
walcrash3.test walcrash4.test walcrash.test walfault.test walhook.test
|
||||
walmode.test walnoshm.test waloverwrite.test walpersist.test
|
||||
walprotocol2.test walprotocol.test walro2.test walrofault.test
|
||||
walro.test walshared.test walslow.test walvfs.test
|
||||
|
||||
nockpt.test
|
||||
}
|
||||
|
||||
test_suite "coverage-pager" -description {
|
||||
|
|
|
@ -0,0 +1,187 @@
|
|||
# 2018 December 23
|
||||
#
|
||||
# The author disclaims copyright to this source code. In place of
|
||||
# a legal notice, here is a blessing:
|
||||
#
|
||||
# May you do good and not evil.
|
||||
# May you find forgiveness for yourself and forgive others.
|
||||
# May you share freely, never taking more than you give.
|
||||
#
|
||||
#***********************************************************************
|
||||
# This file implements regression tests for SQLite library. The
|
||||
# focus of this file is testing the operation of the library in
|
||||
# "PRAGMA journal_mode=WAL" mode.
|
||||
#
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
source $testdir/lock_common.tcl
|
||||
source $testdir/malloc_common.tcl
|
||||
source $testdir/wal_common.tcl
|
||||
set testprefix walvfs
|
||||
|
||||
ifcapable !wal {finish_test ; return }
|
||||
|
||||
db close
|
||||
testvfs tvfs
|
||||
tvfs script xSync
|
||||
tvfs filter xSync
|
||||
set ::sync_count 0
|
||||
proc xSync {method file args} {
|
||||
if {[file tail $file]=="test.db-wal"} {
|
||||
incr ::sync_count
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# Test that if IOCAP_SEQUENTIAL is set, the wal-header is not synced to
|
||||
# disk immediately after it is written.
|
||||
#
|
||||
sqlite3 db test.db -vfs tvfs
|
||||
do_execsql_test 1.0 {
|
||||
PRAGMA auto_vacuum = 0;
|
||||
PRAGMA journal_mode = wal;
|
||||
PRAGMA synchronous = normal;
|
||||
CREATE TABLE t1(a, b, c);
|
||||
INSERT INTO t1 VALUES(1, 2, 3);
|
||||
INSERT INTO t1 VALUES(4, 5, 6);
|
||||
INSERT INTO t1 VALUES(7, 8, 9);
|
||||
PRAGMA wal_checkpoint;
|
||||
} {wal 0 5 5}
|
||||
|
||||
set ::sync_count 0
|
||||
do_test 1.1 {
|
||||
execsql { INSERT INTO t1 VALUES(10, 11, 12) }
|
||||
set ::sync_count
|
||||
} 1
|
||||
|
||||
db close
|
||||
tvfs devchar sequential
|
||||
sqlite3 db test.db -vfs tvfs
|
||||
do_execsql_test 1.2 {
|
||||
PRAGMA synchronous = normal;
|
||||
INSERT INTO t1 VALUES(13, 14, 15);
|
||||
INSERT INTO t1 VALUES(16, 17, 18);
|
||||
PRAGMA wal_checkpoint;
|
||||
} {0 4 4}
|
||||
|
||||
set ::sync_count 0
|
||||
do_test 1.3 {
|
||||
execsql { INSERT INTO t1 VALUES(10, 11, 12) }
|
||||
set ::sync_count
|
||||
} 0
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# Test that "PRAGMA journal_size_limit" works in wal mode.
|
||||
#
|
||||
reset_db
|
||||
do_execsql_test 2.0 {
|
||||
PRAGMA journal_size_limit = 10000;
|
||||
CREATE TABLE t1(x);
|
||||
PRAGMA journal_mode = wal;
|
||||
WITH s(i) AS (
|
||||
SELECT 1 UNION ALL SELECT i+1 FROM s LIMIT 20
|
||||
)
|
||||
INSERT INTO t1 SELECT randomblob(750) FROM s;
|
||||
} {10000 wal}
|
||||
do_test 2.1 {
|
||||
expr [file size test.db-wal]>12000
|
||||
} {1}
|
||||
do_test 2.2 {
|
||||
execsql {
|
||||
PRAGMA wal_checkpoint;
|
||||
INSERT INTO t1 VALUES(randomblob(750));
|
||||
}
|
||||
file size test.db-wal
|
||||
} {10000}
|
||||
do_test 2.3 {
|
||||
execsql {
|
||||
PRAGMA journal_size_limit = 8000;
|
||||
PRAGMA wal_checkpoint;
|
||||
INSERT INTO t1 VALUES(randomblob(750));
|
||||
}
|
||||
file size test.db-wal
|
||||
} {8000}
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# Test that a checkpoint may be interrupted using sqlite3_interrupt().
|
||||
#
|
||||
reset_db
|
||||
db close
|
||||
sqlite3 db test.db -vfs tvfs
|
||||
tvfs filter {}
|
||||
|
||||
do_execsql_test 3.0 {
|
||||
CREATE TABLE t1(x);
|
||||
PRAGMA journal_mode = wal;
|
||||
WITH s(i) AS (
|
||||
SELECT 1 UNION ALL SELECT i+1 FROM s LIMIT 20
|
||||
)
|
||||
INSERT INTO t1 SELECT randomblob(750) FROM s;
|
||||
} {wal}
|
||||
|
||||
tvfs filter xWrite
|
||||
tvfs script xWrite
|
||||
set ::cnt 2
|
||||
proc xWrite {method file args} {
|
||||
if {[file tail $file]=="test.db"} {
|
||||
incr ::cnt -1
|
||||
if {$::cnt==0} {
|
||||
sqlite3_interrupt db
|
||||
}
|
||||
}
|
||||
return SQLITE_OK
|
||||
}
|
||||
|
||||
do_catchsql_test 3.1 {
|
||||
PRAGMA wal_checkpoint
|
||||
} {1 interrupted}
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
reset_db
|
||||
db close
|
||||
do_test 4.0 {
|
||||
sqlite3 db test.db -vfs tvfs
|
||||
execsql {
|
||||
CREATE TABLE t1(x);
|
||||
PRAGMA journal_mode = wal;
|
||||
WITH s(i) AS (
|
||||
SELECT 1 UNION ALL SELECT i+1 FROM s LIMIT 20
|
||||
)
|
||||
INSERT INTO t1 SELECT randomblob(750) FROM s;
|
||||
} db
|
||||
} {wal}
|
||||
db close
|
||||
|
||||
tvfs filter xShmMap
|
||||
tvfs script xShmMap
|
||||
proc xShmMap {method file args} {
|
||||
return SQLITE_READONLY
|
||||
}
|
||||
sqlite3 db test.db -vfs tvfs
|
||||
do_catchsql_test 4.1 {
|
||||
SELECT count(*) FROM t1
|
||||
} {1 {attempt to write a readonly database}}
|
||||
|
||||
set ::cnt 5
|
||||
tvfs filter {xShmMap xShmLock}
|
||||
proc xShmMap {method file name args} {
|
||||
switch -- $method {
|
||||
xShmMap { return SQLITE_READONLY }
|
||||
xShmLock {
|
||||
if {$args == "{0 1 lock shared}"} {
|
||||
incr ::cnt -1
|
||||
if {$::cnt>0} { return SQLITE_BUSY }
|
||||
}
|
||||
}
|
||||
}
|
||||
return SQLITE_OK
|
||||
}
|
||||
do_catchsql_test 4.2 {
|
||||
SELECT count(*) FROM t1
|
||||
} {1 {attempt to write a readonly database}}
|
||||
|
||||
db close
|
||||
tvfs delete
|
||||
finish_test
|
Loading…
Reference in New Issue