Add tests to improve coverage of vdbesort.c.
FossilOrigin-Name: 87a15917d7d88285054e2a319506dd4a0cac9722
This commit is contained in:
parent
bf09093f64
commit
262765a74e
16
manifest
16
manifest
@ -1,5 +1,5 @@
|
||||
C Remove\sredundant\sparameter\sfrom\svdbeSorterInitMerge()\sin\svdbesort.c.
|
||||
D 2011-08-08T19:26:13.264
|
||||
C Add\stests\sto\simprove\scoverage\sof\svdbesort.c.
|
||||
D 2011-08-12T11:59:57.541
|
||||
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
|
||||
F Makefile.in c1d7a7f4fd8da6b1815032efca950e3d5125407e
|
||||
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
|
||||
@ -228,7 +228,7 @@ F src/test_superlock.c 2b97936ca127d13962c3605dbc9a4ef269c424cd
|
||||
F src/test_syscall.c 162c4ec0137a549c009bb9ecab550527743cfc5d
|
||||
F src/test_tclvar.c f4dc67d5f780707210d6bb0eb6016a431c04c7fa
|
||||
F src/test_thread.c fe9a7803fc1d69cccb60f016f28c1cedf2d9fcfa
|
||||
F src/test_vfs.c 956cb3f5cbd2a0d09129540e615bb0fb761c083d
|
||||
F src/test_vfs.c b0baec983bd6f872715a4b44c8f39104fec333af
|
||||
F src/test_vfstrace.c 0b884e06094a746da729119a2cabdc7aa790063d
|
||||
F src/test_wholenumber.c 6129adfbe7c7444f2e60cc785927f3aa74e12290
|
||||
F src/test_wsd.c 41cadfd9d97fe8e3e4e44f61a4a8ccd6f7ca8fe9
|
||||
@ -513,7 +513,7 @@ F test/index2.test ee83c6b5e3173a3d7137140d945d9a5d4fdfb9d6
|
||||
F test/index3.test 423a25c789fc8cc51aaf2a4370bbdde2d9e9eed7
|
||||
F test/index4.test c82a59c9ae2ac01804bdb100162dca057318f40f
|
||||
F test/indexedby.test be501e381b82b2f8ab406309ba7aac46e221f4ad
|
||||
F test/indexfault.test 758a11b2e0c00609c227fa10136e9edcd1200c7f
|
||||
F test/indexfault.test 20a9eb550fd72b7ade902b7046c819b42b849685
|
||||
F test/init.test 15c823093fdabbf7b531fe22cf037134d09587a7
|
||||
F test/insert.test aef273dd1cee84cc92407469e6bd1b3cdcb76908
|
||||
F test/insert2.test 4f3a04d168c728ed5ec2c88842e772606c7ce435
|
||||
@ -881,7 +881,7 @@ F test/vtab_alter.test 9e374885248f69e251bdaacf480b04a197f125e5
|
||||
F test/vtab_err.test 0d4d8eb4def1d053ac7c5050df3024fd47a3fbd8
|
||||
F test/vtab_shared.test 0eff9ce4f19facbe0a3e693f6c14b80711a4222d
|
||||
F test/wal.test 5617ad308bfdb8a8885220d8a261a6096a8d7e57
|
||||
F test/wal2.test aa0fb2314b3235be4503c06873e41ebfc0757782
|
||||
F test/wal2.test ceba91f0d82c4fd87f342aa5504eb1f8fa6418f3
|
||||
F test/wal3.test 5c396cc22497244d627306f4c1d360167353f8dd
|
||||
F test/wal4.test 3404b048fa5e10605facaf70384e6d2943412e30
|
||||
F test/wal5.test f06a0427e06db00347e32eb9fa99d6a5c0f2d088
|
||||
@ -955,7 +955,7 @@ F tool/symbols.sh caaf6ccc7300fd43353318b44524853e222557d5
|
||||
F tool/tostr.awk 11760e1b94a5d3dcd42378f3cc18544c06cfa576
|
||||
F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
|
||||
F tool/warnings.sh 2ebae31e1eb352696f3c2f7706a34c084b28c262
|
||||
P 0e6defa6aa540b413ea3f4bb6dcd86364d547067
|
||||
R a42b0b764e1daab6a572493624ec8887
|
||||
P eec8c0df075d3a54ad71a2854b170f3ed307d068
|
||||
R bafb9457f8118a5d4035b8ba0984f092
|
||||
U dan
|
||||
Z bf599f79a5376801fe18942866ce9ad0
|
||||
Z b426ea64e3d3bc7483e8f669138ad278
|
||||
|
@ -1 +1 @@
|
||||
eec8c0df075d3a54ad71a2854b170f3ed307d068
|
||||
87a15917d7d88285054e2a319506dd4a0cac9722
|
@ -123,6 +123,8 @@ struct Testvfs {
|
||||
#define TESTVFS_TRUNCATE_MASK 0x00002000
|
||||
#define TESTVFS_ACCESS_MASK 0x00004000
|
||||
#define TESTVFS_FULLPATHNAME_MASK 0x00008000
|
||||
#define TESTVFS_READ_MASK 0x00010000
|
||||
|
||||
#define TESTVFS_ALL_MASK 0x0001FFFF
|
||||
|
||||
|
||||
@ -325,8 +327,22 @@ static int tvfsRead(
|
||||
int iAmt,
|
||||
sqlite_int64 iOfst
|
||||
){
|
||||
TestvfsFd *p = tvfsGetFd(pFile);
|
||||
return sqlite3OsRead(p->pReal, zBuf, iAmt, iOfst);
|
||||
int rc = SQLITE_OK;
|
||||
TestvfsFd *pFd = tvfsGetFd(pFile);
|
||||
Testvfs *p = (Testvfs *)pFd->pVfs->pAppData;
|
||||
if( p->pScript && p->mask&TESTVFS_READ_MASK ){
|
||||
tvfsExecTcl(p, "xRead",
|
||||
Tcl_NewStringObj(pFd->zFilename, -1), pFd->pShmId, 0
|
||||
);
|
||||
tvfsResultCode(p, &rc);
|
||||
}
|
||||
if( rc==SQLITE_OK && p->mask&TESTVFS_READ_MASK && tvfsInjectIoerr(p) ){
|
||||
rc = SQLITE_IOERR;
|
||||
}
|
||||
if( rc==SQLITE_OK ){
|
||||
rc = sqlite3OsRead(pFd->pReal, zBuf, iAmt, iOfst);
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1030,6 +1046,7 @@ static int testvfs_obj_cmd(
|
||||
{ "xSync", TESTVFS_SYNC_MASK },
|
||||
{ "xDelete", TESTVFS_DELETE_MASK },
|
||||
{ "xWrite", TESTVFS_WRITE_MASK },
|
||||
{ "xRead", TESTVFS_READ_MASK },
|
||||
{ "xTruncate", TESTVFS_TRUNCATE_MASK },
|
||||
{ "xOpen", TESTVFS_OPEN_MASK },
|
||||
{ "xClose", TESTVFS_CLOSE_MASK },
|
||||
|
@ -17,6 +17,44 @@ source $testdir/malloc_common.tcl
|
||||
|
||||
set testprefix indexfault
|
||||
|
||||
# Set up the custom fault-injector. This is further configured by using
|
||||
# different values for $::custom_filter and different implementations
|
||||
# of Tcl proc [xCustom] for each test case.
|
||||
#
|
||||
proc install_custom_faultsim {} {
|
||||
set ::FAULTSIM(custom) [list \
|
||||
-injectinstall custom_injectinstall \
|
||||
-injectstart custom_injectstart \
|
||||
-injectstop custom_injectstop \
|
||||
-injecterrlist {{1 {disk I/O error}}} \
|
||||
-injectuninstall custom_injectuninstall \
|
||||
]
|
||||
proc custom_injectinstall {} {
|
||||
testvfs shmfault -default true
|
||||
shmfault filter $::custom_filter
|
||||
shmfault script xCustom
|
||||
}
|
||||
proc custom_injectuninstall {} {
|
||||
catch {db close}
|
||||
catch {db2 close}
|
||||
shmfault delete
|
||||
}
|
||||
set ::custom_ifail -1
|
||||
set ::custom_nfail -1
|
||||
proc custom_injectstart {iFail} {
|
||||
set ::custom_ifail $iFail
|
||||
set ::custom_nfail 0
|
||||
}
|
||||
proc custom_injectstop {} {
|
||||
set ::custom_ifail -1
|
||||
return $::custom_nfail
|
||||
}
|
||||
}
|
||||
proc uninstall_custom_faultsim {} {
|
||||
unset -nocomplain ::FAULTSIM(custom)
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# These tests - indexfault-1.* - Build an index on a smallish table with
|
||||
# all different kinds of fault-injection. The CREATE INDEX is run once
|
||||
@ -124,39 +162,14 @@ ifcapable memorymanage {
|
||||
# second temporary file.
|
||||
# 3.4: As 7.3, but with a low (50KB) soft-heap-limit.
|
||||
#
|
||||
# 3.5: After a certain amount of data has been read from the main database
|
||||
# file (and written into the temporary b-tree), sqlite3_release_memory()
|
||||
# is called to free as much memory as possible. This causes the temp
|
||||
# b-tree to be flushed to disk. So that before its contents can be
|
||||
# transfered to a PMA they must be read back from disk - creating extra
|
||||
# opportunities for IO errors.
|
||||
#
|
||||
|
||||
# Set up the custom fault-injector. This is further configured by using
|
||||
# different values for $::custom_filter and different implementations
|
||||
# of Tcl proc [xCustom] for each test case.
|
||||
#
|
||||
set FAULTSIM(custom) [list \
|
||||
-injectinstall custom_injectinstall \
|
||||
-injectstart custom_injectstart \
|
||||
-injectstop custom_injectstop \
|
||||
-injecterrlist {{1 {disk I/O error}}} \
|
||||
-injectuninstall custom_injectuninstall \
|
||||
]
|
||||
proc custom_injectinstall {} {
|
||||
testvfs shmfault -default true
|
||||
shmfault filter $::custom_filter
|
||||
shmfault script xCustom
|
||||
}
|
||||
proc custom_injectuninstall {} {
|
||||
catch {db close}
|
||||
catch {db2 close}
|
||||
shmfault delete
|
||||
}
|
||||
set ::custom_ifail -1
|
||||
set ::custom_nfail -1
|
||||
proc custom_injectstart {iFail} {
|
||||
set ::custom_ifail $iFail
|
||||
set ::custom_nfail 0
|
||||
}
|
||||
proc custom_injectstop {} {
|
||||
set ::custom_ifail -1
|
||||
return $::custom_nfail
|
||||
}
|
||||
install_custom_faultsim
|
||||
|
||||
# Set up a table to build indexes on. Save the setup using the
|
||||
# [faultsim_save_and_close] mechanism.
|
||||
@ -245,4 +258,80 @@ ifcapable memorymanage {
|
||||
sqlite3_soft_heap_limit $soft_limit
|
||||
}
|
||||
|
||||
uninstall_custom_faultsim
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# Test 4: After a certain amount of data has been read from the main database
|
||||
# file (and written into the temporary b-tree), sqlite3_release_memory() is
|
||||
# called to free as much memory as possible. This causes the temp b-tree to be
|
||||
# flushed to disk. So that before its contents can be transfered to a PMA they
|
||||
# must be read back from disk - creating extra opportunities for IO errors.
|
||||
#
|
||||
install_custom_faultsim
|
||||
|
||||
catch { db close }
|
||||
forcedelete test.db
|
||||
sqlite3 db test.db
|
||||
|
||||
do_execsql_test 4.0 {
|
||||
BEGIN;
|
||||
DROP TABLE IF EXISTS t1;
|
||||
CREATE TABLE t1(x);
|
||||
INSERT INTO t1 VALUES(randomblob(11000));
|
||||
INSERT INTO t1 SELECT randomblob(11001) FROM t1; -- 2
|
||||
INSERT INTO t1 SELECT randomblob(11002) FROM t1; -- 4
|
||||
INSERT INTO t1 SELECT randomblob(11003) FROM t1; -- 8
|
||||
INSERT INTO t1 SELECT randomblob(11004) FROM t1; -- 16
|
||||
INSERT INTO t1 SELECT randomblob(11005) FROM t1; -- 32
|
||||
INSERT INTO t1 SELECT randomblob(11005) FROM t1; -- 64
|
||||
COMMIT;
|
||||
}
|
||||
faultsim_save_and_close
|
||||
|
||||
testvfs tvfs
|
||||
tvfs script xRead
|
||||
tvfs filter xRead
|
||||
set ::nRead 0
|
||||
proc xRead {method file args} {
|
||||
if {[file tail $file] == "test.db"} { incr ::nRead }
|
||||
}
|
||||
|
||||
do_test 4.1 {
|
||||
sqlite3 db test.db -vfs tvfs
|
||||
execsql { CREATE INDEX i1 ON t1(x) }
|
||||
} {}
|
||||
|
||||
db close
|
||||
tvfs delete
|
||||
|
||||
set ::custom_filter xRead
|
||||
proc xCustom {method file args} {
|
||||
incr ::nReadCall
|
||||
if {$::nReadCall >= ($::nRead/5)} {
|
||||
if {$::nReadCall == ($::nRead/5)} {
|
||||
set nByte [sqlite3_release_memory [expr 64*1024*1024]]
|
||||
sqlite3_soft_heap_limit 20000
|
||||
}
|
||||
if {$file == ""} {
|
||||
incr ::custom_ifail -1
|
||||
if {$::custom_ifail==0} {
|
||||
incr ::custom_nfail
|
||||
return "SQLITE_IOERR"
|
||||
}
|
||||
}
|
||||
}
|
||||
return "SQLITE_OK"
|
||||
}
|
||||
|
||||
do_faultsim_test 4.2 -faults custom -prep {
|
||||
faultsim_restore_and_reopen
|
||||
set ::nReadCall 0
|
||||
sqlite3_soft_heap_limit 0
|
||||
} -body {
|
||||
execsql { CREATE INDEX i1 ON t1(x) }
|
||||
faultsim_test_result {0 {}}
|
||||
}
|
||||
|
||||
uninstall_custom_faultsim
|
||||
|
||||
finish_test
|
||||
|
@ -606,6 +606,7 @@ do_test wal2-6.4.1 {
|
||||
testvfs tvfs
|
||||
tvfs script tvfs_cb
|
||||
sqlite3 db test.db -vfs tvfs
|
||||
set {} {}
|
||||
} {}
|
||||
|
||||
set RECOVERY {
|
||||
|
Loading…
Reference in New Issue
Block a user