Add tests to syscall.test and sysfault.test.

FossilOrigin-Name: 3d2de011814002e2e25b7645f94ff8fc7aab9cdd
This commit is contained in:
dan 2011-03-29 18:28:35 +00:00
parent 60939d0ade
commit 5ef47bf002
5 changed files with 130 additions and 18 deletions

View File

@ -1,5 +1,5 @@
C Fix\sa\sproblem\swhereby\sfollowing\san\sIO\serror\sin\sCommitPhaseTwo()\sof\sa\smulti-file\stransaction\sthe\sb-tree\slayer\scould\sbe\sleft\sin\sTRANS_WRITE\sstate,\scausing\sproblems\slater\son. C Add\stests\sto\ssyscall.test\sand\ssysfault.test.
D 2011-03-29T15:40:55.407 D 2011-03-29T18:28:35.749
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
F Makefile.in 27701a1653595a1f2187dc61c8117e00a6c1d50f F Makefile.in 27701a1653595a1f2187dc61c8117e00a6c1d50f
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@ -220,7 +220,7 @@ F src/test_schema.c 8c06ef9ddb240c7a0fcd31bc221a6a2aade58bf0
F src/test_server.c bbba05c144b5fc4b52ff650a4328027b3fa5fcc6 F src/test_server.c bbba05c144b5fc4b52ff650a4328027b3fa5fcc6
F src/test_stat.c f682704b5d1ba8e1d4e7e882a6d7922e2dcf066c F src/test_stat.c f682704b5d1ba8e1d4e7e882a6d7922e2dcf066c
F src/test_superlock.c 2b97936ca127d13962c3605dbc9a4ef269c424cd F src/test_superlock.c 2b97936ca127d13962c3605dbc9a4ef269c424cd
F src/test_syscall.c bbdc88d0a5e42d0c35eaff8ae7ec86e8867f5543 F src/test_syscall.c d12e8cd163cd33b66d0a3d1b8daaf136d09d65c2
F src/test_tclvar.c f4dc67d5f780707210d6bb0eb6016a431c04c7fa F src/test_tclvar.c f4dc67d5f780707210d6bb0eb6016a431c04c7fa
F src/test_thread.c bedd05cad673dba53326f3aa468cc803038896c0 F src/test_thread.c bedd05cad673dba53326f3aa468cc803038896c0
F src/test_vfs.c 2ed8853c1e51ac6f9ea091f7ce4e0d618bba8b86 F src/test_vfs.c 2ed8853c1e51ac6f9ea091f7ce4e0d618bba8b86
@ -672,8 +672,8 @@ F test/subselect.test d24fd8757daf97dafd2e889c73ea4c4272dcf4e4
F test/substr.test 18f57c4ca8a598805c4d64e304c418734d843c1a F test/substr.test 18f57c4ca8a598805c4d64e304c418734d843c1a
F test/superlock.test 5d7a4954b0059c903f82c7b67867bc5451a7c082 F test/superlock.test 5d7a4954b0059c903f82c7b67867bc5451a7c082
F test/sync.test ded6b39d8d8ca3c0c5518516c6371b3316d3e3a3 F test/sync.test ded6b39d8d8ca3c0c5518516c6371b3316d3e3a3
F test/syscall.test 5ae4b3d4f2aca2ef3c3a777f619e0c6b0cf592aa F test/syscall.test 125d9781d914c408e8629053b5f914dc920ab3eb
F test/sysfault.test 359ea90a58788c867ac0f9cb52431f56ed975672 F test/sysfault.test be42aa42f89a82305cf3807047d419595e430480
F test/table.test 04ba066432430657712d167ebf28080fe878d305 F test/table.test 04ba066432430657712d167ebf28080fe878d305
F test/tableapi.test 2674633fa95d80da917571ebdd759a14d9819126 F test/tableapi.test 2674633fa95d80da917571ebdd759a14d9819126
F test/tclsqlite.test 8c154101e704170c2be10f137a5499ac2c6da8d3 F test/tclsqlite.test 8c154101e704170c2be10f137a5499ac2c6da8d3
@ -919,7 +919,7 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
P bc6cce81565b17f886478bd51500bba2ed11ec1d P dbe569a099c2855480e35c0cc4d9332821ad80da
R 4ba5c752b69008d11d64e0bac5b06138 R 3d53fb9ad6916c3f10485806a35396e6
U dan U dan
Z d0374b5c64afa57baa2ab5bac0bd8f73 Z cababf145f4f0436acd3441acb25d038

View File

@ -1 +1 @@
dbe569a099c2855480e35c0cc4d9332821ad80da 3d2de011814002e2e25b7645f94ff8fc7aab9cdd

View File

@ -253,7 +253,7 @@ static int ts_stat(const char *zPath, struct stat *p){
** A wrapper around fstat(). ** A wrapper around fstat().
*/ */
static int ts_fstat(int fd, struct stat *p){ static int ts_fstat(int fd, struct stat *p){
if( tsIsFail() ){ if( tsIsFailErrno("fstat") ){
return -1; return -1;
} }
return orig_fstat(fd, p); return orig_fstat(fd, p);
@ -534,6 +534,8 @@ static int test_syscall_errno(
{ "EACCES", EACCES }, { "EACCES", EACCES },
{ "EINTR", EINTR }, { "EINTR", EINTR },
{ "EIO", EIO }, { "EIO", EIO },
{ "EOVERFLOW", EOVERFLOW },
{ "ENOMEM", ENOMEM },
{ 0, 0 } { 0, 0 }
}; };

View File

@ -103,9 +103,97 @@ foreach jrnl [list wal delete] {
} }
} {1 2 5 6 3 4 7 8} } {1 2 5 6 3 4 7 8}
} }
} }
#-------------------------------------------------------------------------
# This test verifies that closing database handles does not drop locks
# held by other database handles in the same process on the same file.
#
# The os_unix.c module has to take precautions to prevent this as the
# close() system call drops locks held by other file-descriptors on the
# same file. From the Linux man page:
#
# close() closes a file descriptor, so that it no longer refers to any file
# and may be reused. Any record locks (see fcntl(2)) held on the file it
# was associated with, and owned by the process, are removed (regardless
# of the file descriptor that was used to obtain the lock).
#
catch { db close }
forcedelete test.db test.db2
do_multiclient_test tn {
code1 {
sqlite3 dbX1 test.db
sqlite3 dbX2 test.db
}
do_test syscall-5.$tn.1 {
sql1 {
CREATE TABLE t1(a, b);
INSERT INTO t1 VALUES(1, 2);
BEGIN;
INSERT INTO t1 VALUES(3, 4);
}
} {}
do_test syscall-5.$tn.2 { sql2 { SELECT * FROM t1 } } {1 2}
do_test syscall-5.$tn.3 {
csql2 { INSERT INTO t1 VALUES(5, 6) }
} {1 {database is locked}}
do_test syscall-5.$tn.4 {
code1 {
dbX1 close
dbX2 close
}
} {}
do_test syscall-5.$tn.5 {
csql2 { INSERT INTO t1 VALUES(5, 6) }
} {1 {database is locked}}
do_test syscall-5.$tn.6 { sql1 { COMMIT } } {}
do_test syscall-5.$tn.7 {
csql2 { INSERT INTO t1 VALUES(5, 6) }
} {0 {}}
}
catch {db close}
do_test 6.1 {
sqlite3 db1 test.db1
sqlite3 db2 test.db2
sqlite3 db3 test.db3
sqlite3 dbM ""
db2 close
db3 close
dbM close
db1 close
} {}
do_test 6.2 {
sqlite3 db test.db
execsql {
PRAGMA temp_store = file;
PRAGMA main.cache_size = 10;
PRAGMA temp.cache_size = 10;
CREATE TABLE temp.tt(a, b);
INSERT INTO tt VALUES(randomblob(500), randomblob(600));
INSERT INTO tt SELECT randomblob(500), randomblob(600) FROM tt;
INSERT INTO tt SELECT randomblob(500), randomblob(600) FROM tt;
INSERT INTO tt SELECT randomblob(500), randomblob(600) FROM tt;
INSERT INTO tt SELECT randomblob(500), randomblob(600) FROM tt;
INSERT INTO tt SELECT randomblob(500), randomblob(600) FROM tt;
INSERT INTO tt SELECT randomblob(500), randomblob(600) FROM tt;
INSERT INTO tt SELECT randomblob(500), randomblob(600) FROM tt;
INSERT INTO tt SELECT randomblob(500), randomblob(600) FROM tt;
}
db close
} {}
finish_test finish_test

View File

@ -43,13 +43,8 @@ proc vfsfault_injectstop {} { test_syscall fault }
faultsim_save_and_close faultsim_save_and_close
proc vfsfault_install {} {
test_syscall install {open getcwd}
}
do_faultsim_test 1 -faults vfsfault-* -prep { set open_and_write_body {
faultsim_restore
} -body {
sqlite3 db test.db sqlite3 db test.db
db eval { db eval {
CREATE TABLE t1(a, b); CREATE TABLE t1(a, b);
@ -60,12 +55,36 @@ do_faultsim_test 1 -faults vfsfault-* -prep {
CREATE TEMP TABLE t2(x); CREATE TEMP TABLE t2(x);
INSERT INTO t2 VALUES('y'); INSERT INTO t2 VALUES('y');
} }
} -test { }
proc vfsfault_install {} { test_syscall install {open getcwd} }
do_faultsim_test 1 -faults vfsfault-* -prep {
faultsim_restore
} -body $open_and_write_body -test {
faultsim_test_result {0 {wal 1 2 3 4}} \ faultsim_test_result {0 {wal 1 2 3 4}} \
{1 {unable to open database file}} \ {1 {unable to open database file}} \
{1 {attempt to write a readonly database}} {1 {attempt to write a readonly database}}
} }
# Errors in the fstat() function when opening and writing a file.
#
foreach {tn errno errlist} {
1 ENOMEM {{disk I/O error}}
2 EOVERFLOW {{disk I/O error} {large file support is disabled}}
} {
proc vfsfault_install {} { test_syscall install fstat }
set errs [list]
foreach e $errlist { lappend errs [list 1 $e] }
do_faultsim_test 1.2.$tn -faults vfsfault-* -prep {
faultsim_restore
} -body "
test_syscall errno fstat $errno
$open_and_write_body
" -test "
faultsim_test_result {0 {wal 1 2 3 4}} $errs
"
}
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# Check that a single EINTR error does not affect processing. # Check that a single EINTR error does not affect processing.
# #
@ -139,6 +158,9 @@ do_faultsim_test 2.2 -faults vfsfault-* -prep {
{1 {disk I/O error}} {1 {disk I/O error}}
} }
#-------------------------------------------------------------------------
#
finish_test finish_test