Add test cases to test file walvfs.test.
FossilOrigin-Name: d697f6f3ca47350dad30feb529914fc5254fa662ece783408eea963d912918c1
This commit is contained in:
parent
c310c53e01
commit
76e4990b25
16
manifest
16
manifest
@ -1,5 +1,5 @@
|
||||
C Always\sinclude\sOP_Explain\sopcodes\sin\sthe\sbytecode\swhen\sSQLITE_DEBUG\sis\senabled.
|
||||
D 2018-12-24T18:10:39.923
|
||||
C Add\stest\scases\sto\stest\sfile\swalvfs.test.
|
||||
D 2018-12-24T18:51:13.175
|
||||
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 9a53b40290db75833db58295485b955276daed99a2e57d7215719e175c0cfae0
|
||||
F src/test_vfs.c 4c02cd8457e29fab36ab4101535fa6ba380299bae35cd594def9d3df9b1de946
|
||||
F src/test_vfstrace.c bab9594adc976cbe696ff3970728830b4c5ed698
|
||||
F src/test_windirent.c a895e2c068a06644eef91a7f0a32182445a893b9a0f33d0cdb4283dca2486ac1
|
||||
F src/test_windirent.h 90dfbe95442c9762357fe128dc7ae3dc199d006de93eb33ba3972e0a90484215
|
||||
@ -1633,7 +1633,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/walvfs.test 355811484f6da8f0cc32778ccfcbc2f1cc75bd885a485342b58fe87646407f96
|
||||
F test/where.test 8215d220633f08da331781cf9ede7fb7aed50eb113473c10acd39a643fd258ba
|
||||
F test/where2.test 478d2170637b9211f593120648858593bf2445a1
|
||||
F test/where3.test 2341a294e17193a6b1699ea7f192124a5286ca6acfcc3f4b06d16c931fbcda2c
|
||||
@ -1793,7 +1793,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 883337ffdb434b6856ceaada121c0be67e2fdec7b447675f45e85568ef28d7d9
|
||||
R 30c0748c57381b7fce019bae78e42ebf
|
||||
U drh
|
||||
Z f9647d8e5459acd909fc869c310491a1
|
||||
P d8c1235c02b745138ac2b12e8bbb00dda4cac321176be92a2fa9547be029b3d0
|
||||
R 68289dc241c776c10a427c8244019d09
|
||||
U dan
|
||||
Z 338aa73ca0930a2df5334e416db5641f
|
||||
|
@ -1 +1 @@
|
||||
d8c1235c02b745138ac2b12e8bbb00dda4cac321176be92a2fa9547be029b3d0
|
||||
d697f6f3ca47350dad30feb529914fc5254fa662ece783408eea963d912918c1
|
@ -1616,10 +1616,63 @@ static int SQLITE_TCLAPI test_vfs_shmlock(
|
||||
return TCL_OK;
|
||||
}
|
||||
|
||||
static int SQLITE_TCLAPI test_vfs_set_readmark(
|
||||
void * clientData,
|
||||
Tcl_Interp *interp,
|
||||
int objc,
|
||||
Tcl_Obj *CONST objv[]
|
||||
){
|
||||
sqlite3 *db = 0;
|
||||
int rc = SQLITE_OK;
|
||||
const char *zDbname = 0;
|
||||
int iSlot = 0;
|
||||
int iVal = -1;
|
||||
sqlite3_file *pFd;
|
||||
void volatile *pShm = 0;
|
||||
u32 *aShm;
|
||||
int iOff;
|
||||
|
||||
if( objc!=4 && objc!=5 ){
|
||||
Tcl_WrongNumArgs(interp, 1, objv, "DB DBNAME SLOT ?VALUE?");
|
||||
return TCL_ERROR;
|
||||
}
|
||||
|
||||
zDbname = Tcl_GetString(objv[2]);
|
||||
if( getDbPointer(interp, Tcl_GetString(objv[1]), &db)
|
||||
|| Tcl_GetIntFromObj(interp, objv[3], &iSlot)
|
||||
|| (objc==5 && Tcl_GetIntFromObj(interp, objv[4], &iVal))
|
||||
){
|
||||
return TCL_ERROR;
|
||||
}
|
||||
|
||||
sqlite3_file_control(db, zDbname, SQLITE_FCNTL_FILE_POINTER, (void*)&pFd);
|
||||
if( pFd==0 ){
|
||||
return TCL_ERROR;
|
||||
}
|
||||
rc = pFd->pMethods->xShmMap(pFd, 0, 32*1024, 0, &pShm);
|
||||
if( rc!=SQLITE_OK ){
|
||||
Tcl_SetObjResult(interp, Tcl_NewStringObj(sqlite3ErrName(rc), -1));
|
||||
return TCL_ERROR;
|
||||
}
|
||||
if( pShm==0 ){
|
||||
Tcl_AppendResult(interp, "*-shm is not yet mapped", 0);
|
||||
return TCL_ERROR;
|
||||
}
|
||||
aShm = (u32*)pShm;
|
||||
iOff = 12*2+1+iSlot;
|
||||
|
||||
if( objc==5 ){
|
||||
aShm[iOff] = iVal;
|
||||
}
|
||||
Tcl_SetObjResult(interp, Tcl_NewIntObj(aShm[iOff]));
|
||||
|
||||
return TCL_OK;
|
||||
}
|
||||
|
||||
int Sqlitetestvfs_Init(Tcl_Interp *interp){
|
||||
Tcl_CreateObjCommand(interp, "testvfs", testvfs_cmd, 0, 0);
|
||||
Tcl_CreateObjCommand(interp, "vfs_shmlock", test_vfs_shmlock, 0, 0);
|
||||
Tcl_CreateObjCommand(interp, "vfs_set_readmark", test_vfs_set_readmark, 0, 0);
|
||||
return TCL_OK;
|
||||
}
|
||||
|
||||
|
@ -182,6 +182,99 @@ do_catchsql_test 4.2 {
|
||||
SELECT count(*) FROM t1
|
||||
} {1 {attempt to write a readonly database}}
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
reset_db
|
||||
db close
|
||||
sqlite3 db test.db -vfs tvfs
|
||||
tvfs filter {}
|
||||
do_execsql_test 5.0 {
|
||||
PRAGMA auto_vacuum = 0;
|
||||
PRAGMA page_size = 1024;
|
||||
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}
|
||||
|
||||
do_execsql_test 5.1 {
|
||||
SELECT count(*) FROM t1
|
||||
} {20}
|
||||
|
||||
do_test 5.2 {
|
||||
vfs_set_readmark db main 1 100
|
||||
vfs_set_readmark db main 2 100
|
||||
vfs_set_readmark db main 3 100
|
||||
vfs_set_readmark db main 4 100
|
||||
} {100}
|
||||
|
||||
do_execsql_test 5.3 {
|
||||
SELECT count(*) FROM t1
|
||||
} {20}
|
||||
|
||||
do_test 5.3 {
|
||||
list [vfs_set_readmark db main 1] \
|
||||
[vfs_set_readmark db main 2] \
|
||||
[vfs_set_readmark db main 3] \
|
||||
[vfs_set_readmark db main 4]
|
||||
} {24 100 100 100}
|
||||
|
||||
tvfs script xShmLock
|
||||
tvfs filter xShmLock
|
||||
set ::cnt 20
|
||||
proc xShmLock {args} {
|
||||
incr ::cnt -1
|
||||
if {$::cnt>0} { return SQLITE_BUSY }
|
||||
return SQLITE_OK
|
||||
}
|
||||
|
||||
do_test 5.4 {
|
||||
vfs_set_readmark db main 1 100
|
||||
execsql { SELECT count(*) FROM t1 }
|
||||
} {20}
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# Cause an SQLITE_PROTOCOL while attempting to restart the wal file.
|
||||
reset_db
|
||||
tvfs filter {}
|
||||
db close
|
||||
sqlite3 db test.db -vfs tvfs
|
||||
do_execsql_test 6.0 {
|
||||
PRAGMA auto_vacuum = 0;
|
||||
PRAGMA page_size = 1024;
|
||||
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}
|
||||
|
||||
do_test 6.1 {
|
||||
execsql { PRAGMA wal_checkpoint }
|
||||
set {} {}
|
||||
} {}
|
||||
|
||||
tvfs filter xShmLock
|
||||
set ::flag 0
|
||||
proc xShmLock {method file handle spec} {
|
||||
if {$::flag && [lrange $spec 2 end]=="lock shared"} {
|
||||
return SQLITE_BUSY
|
||||
}
|
||||
if {$spec=="3 1 unlock shared"} {
|
||||
set ::flag 1
|
||||
}
|
||||
return SQLITE_OK
|
||||
}
|
||||
|
||||
puts "# WARNING: This next test takes around 12 seconds"
|
||||
do_catchsql_test 6.2 {
|
||||
INSERT INTO t1 VALUES(1);
|
||||
} {1 {locking protocol}}
|
||||
|
||||
db close
|
||||
tvfs delete
|
||||
finish_test
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user