From: drh Date: Fri, 6 Apr 2007 18:23:17 +0000 (+0000) Subject: Additional coverage testing. (CVS 3823) X-Git-Tag: version-3.6.10~2347 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=bb5f18d2ca13704d3a7e7b8ce51a677304a62f3d;p=thirdparty%2Fsqlite.git Additional coverage testing. (CVS 3823) FossilOrigin-Name: 26b2e1aede3f776134b2d6e941d17a907843e650 --- diff --git a/manifest b/manifest index 4f7ab1221b..da3a4a8665 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Binary\sfile\sI/O\sinfrastructure\sadded\sand\sused\sto\sincrease\stest\scoverage\nfor\sdetection\sof\scorrupt\sdatabase\sfiles.\s(CVS\s3822) -D 2007-04-06T15:02:13 +C Additional\scoverage\stesting.\s(CVS\s3823) +D 2007-04-06T18:23:18 F Makefile.in 8cab54f7c9f5af8f22fd97ddf1ecfd1e1860de62 F Makefile.linux-gcc 2d8574d1ba75f129aba2019f0b959db380a90935 F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028 @@ -82,11 +82,11 @@ F src/os_os2.c 2ce97909b926a598823f97338027dbec1dcf4165 F src/os_os2.h e5f17dd69333632bbc3112881ea407c37d245eb3 F src/os_test.c 49833426101f99aee4bb5f6a44b7c4b2029fda1c F src/os_test.h 903c93554c23d88f34f667f1979e4a1cee792af3 -F src/os_unix.c 13c6f73a7b0c2c6c131c97ea26274db101b594cd +F src/os_unix.c 426b4c03c304ad78746d65d9ba101e0b72e18e23 F src/os_unix.h 5768d56d28240d3fe4537fac08cc85e4fb52279e F src/os_win.c c9a99524d6b2bdec636264cad1b67553925e3309 F src/os_win.h 41a946bea10f61c158ce8645e7646b29d44f122b -F src/pager.c 642f804b20a71933fb83b13a1ce93cb4dd1390f7 +F src/pager.c e1ee86ae8d09c84bcd91900ade250776d83e3c72 F src/pager.h e79a24cf200b8771366217f5bca414f5b7823f42 F src/parse.y b6cfbadb6d5b21b5087d30698ee5af0ebb098767 F src/pragma.c 3b992b5b2640d6ae25cef05aa6a42cd1d6c43234 @@ -261,6 +261,7 @@ F test/loadext2.test 4472af96306b127b378a1b2026fe15ed5863f9cf F test/lock.test 6825aea0b5885578b1b63a3b178803842c4ee9f1 F test/lock2.test d83ba79d3c4fffdb5b926c7d8ca7a36c34288a55 F test/lock3.test 615111293cf32aa2ed16d01c6611737651c96fb9 +F test/lock4.test c0a56659708bc45d134a18116bf01dd9ff765408 F test/main.test e7212ce1023957c7209778cc87fa932bd79ba89a F test/malloc.test d868a6b98b07928b00bca3d9874daf6885c86150 F test/malloc2.test 4ed7d719542c4570dec9c2ebe2bbdf3a9f3b0d05 @@ -382,7 +383,7 @@ F test/where4.test b68496500bff496e83e76ae4ffb493b99064eac6 F tool/diffdb.c 7524b1b5df217c20cd0431f6789851a4e0cb191b F tool/fragck.tcl 5265a95126abcf6ab357f7efa544787e5963f439 F tool/lemon.c c8c8b25ab1ac8156b3ad83ba4ea1bf00d5e07f5a -F tool/lempar.c 20851553530657c766dfb1358b0d443ed2d9c26f +F tool/lempar.c 8f998bf8d08e2123149c2cc5d0597cd5d5d1abdd F tool/memleak.awk 4e7690a51bf3ed757e611273d43fe3f65b510133 F tool/memleak2.awk 9cc20c8e8f3c675efac71ea0721ee6874a1566e8 F tool/memleak3.tcl 7707006ee908cffff210c98158788d85bb3fcdbf @@ -454,7 +455,7 @@ F www/tclsqlite.tcl bb0d1357328a42b1993d78573e587c6dcbc964b9 F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0 F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b F www/whentouse.tcl 97e2b5cd296f7d8057e11f44427dea8a4c2db513 -P 8e2559b4da6329d7c21925d0850f7f91a3731975 -R bf361c806ccd54df8932ace1ba12eaf6 +P 479b3d965b19c3ec4cb72542718751debf8ff75c +R c44625c6b92ea887ac4e549d47a5b6a4 U drh -Z e15d206887ea8f19e691b97bb3aee05c +Z 81bb1941e9b9712f600f3f1f2f806f0c diff --git a/manifest.uuid b/manifest.uuid index 4d740e88a3..753ecfb543 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -479b3d965b19c3ec4cb72542718751debf8ff75c \ No newline at end of file +26b2e1aede3f776134b2d6e941d17a907843e650 \ No newline at end of file diff --git a/src/os_unix.c b/src/os_unix.c index 18ae4b76c0..281348b79d 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -919,11 +919,7 @@ static int unixOpenDirectory( const char *zDirname ){ unixFile *pFile = (unixFile*)id; - if( pFile==0 ){ - /* Do not open the directory if the corresponding file is not already - ** open. */ - return SQLITE_CANTOPEN; - } + assert( pFile!=0 ); SET_THREADID(pFile); assert( pFile->dirfd<0 ); pFile->dirfd = open(zDirname, O_RDONLY|O_BINARY, 0); @@ -1000,10 +996,13 @@ static int seekAndRead(unixFile *id, void *pBuf, int cnt){ TIMER_START; #if defined(USE_PREAD) got = pread(id->h, pBuf, cnt, id->offset); + SimulateIOError( got = -1 ); #elif defined(USE_PREAD64) got = pread64(id->h, pBuf, cnt, id->offset); + SimulateIOError( got = -1 ); #else newOffset = lseek(id->h, id->offset, SEEK_SET); + SimulateIOError( newOffset-- ); if( newOffset!=id->offset ){ return -1; } @@ -1026,7 +1025,6 @@ static int unixRead(OsFile *id, void *pBuf, int amt){ int got; assert( id ); got = seekAndRead((unixFile*)id, pBuf, amt); - SimulateIOError( got = -1 ); if( got==amt ){ return SQLITE_OK; }else if( got<0 ){ diff --git a/src/pager.c b/src/pager.c index 83d458bc50..874333c745 100644 --- a/src/pager.c +++ b/src/pager.c @@ -18,7 +18,7 @@ ** file simultaneously, or one process from reading the database while ** another is writing. ** -** @(#) $Id: pager.c,v 1.323 2007/04/05 17:15:53 danielk1977 Exp $ +** @(#) $Id: pager.c,v 1.324 2007/04/06 18:23:18 drh Exp $ */ #ifndef SQLITE_OMIT_DISKIO #include "sqliteInt.h" @@ -2508,8 +2508,12 @@ static PgHdr *pager_get_all_dirty_pages(Pager *pPager){ */ static int hasHotJournal(Pager *pPager){ if( !pPager->useJournal ) return 0; - if( !sqlite3OsFileExists(pPager->zJournal) ) return 0; - if( sqlite3OsCheckReservedLock(pPager->fd) ) return 0; + if( !sqlite3OsFileExists(pPager->zJournal) ){ + return 0; + } + if( sqlite3OsCheckReservedLock(pPager->fd) ){ + return 0; + } if( sqlite3PagerPagecount(pPager)==0 ){ sqlite3OsDelete(pPager->zJournal); return 0; diff --git a/test/lock4.test b/test/lock4.test new file mode 100644 index 0000000000..e82cbb1bdb --- /dev/null +++ b/test/lock4.test @@ -0,0 +1,93 @@ +# 2007 April 6 +# +# 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 script is database locks. +# +# $Id: lock4.test,v 1.3 2007/04/06 18:23:19 drh Exp $ + + +set testdir [file dirname $argv0] +source $testdir/tester.tcl + +# Initialize the test.db database so that it is non-empty +# +do_test lock4-1.1 { + db eval {CREATE TABLE t1(x)} + file delete -force test2.db test2.db-journal + sqlite3 db2 test2.db + db2 eval {CREATE TABLE t2(x)} + db2 close + list [file size test.db] [file size test2.db] +} {2048 2048} + +# Create a script to drive a separate process that will +# +# 1. Create a second database test2.db +# 2. Get an exclusive lock on test2.db +# 3. Add an entry to test.db in table t1, waiting as necessary. +# 4. Commit the change to test2.db. +# +# Meanwhile, this process will: +# +# A. Get an exclusive lock on test.db +# B. Attempt to read from test2.db but get an SQLITE_BUSY error. +# C. Commit the changes to test.db thus alloing the other process +# to continue. +# +do_test lock4-1.2 { + set out [open test2-script.tcl w] + puts $out "set sqlite_pending_byte [set sqlite_pending_byte]" + puts $out { + sqlite3 db2 test2.db + db2 eval { + BEGIN; + INSERT INTO t2 VALUES(2); + } + sqlite3 db test.db + db timeout 1000000 + db eval { + INSERT INTO t1 VALUES(2); + } + db2 eval COMMIT + exit + } + close $out + db eval { + BEGIN; + INSERT INTO t1 VALUES(1); + } + exec [info nameofexec] ./test2-script.tcl & + while {![file exists test2.db-journal]} { + after 10 + } + sqlite3 db2 test2.db + catchsql { + INSERT INTO t2 VALUES(1) + } db2 +} {1 {database is locked}} +do_test lock4-1.3 { + db eval { + COMMIT; + } + while {[file exists test2.db-journal]} { + after 10 + } + db2 eval { + SELECT * FROM t2 + } +} {2} + + +do_test lock4-999.1 { + rename db2 {} +} {} + +finish_test diff --git a/tool/lempar.c b/tool/lempar.c index 6eb8387a87..97d146d4c5 100644 --- a/tool/lempar.c +++ b/tool/lempar.c @@ -210,21 +210,6 @@ static const char *const yyRuleName[] = { }; #endif /* NDEBUG */ -/* -** This function returns the symbolic name associated with a token -** value. -*/ -const char *ParseTokenName(int tokenType){ -#ifndef NDEBUG - if( tokenType>0 && tokenType<(sizeof(yyTokenName)/sizeof(yyTokenName[0])) ){ - return yyTokenName[tokenType]; - }else{ - return "Unknown"; - } -#else - return ""; -#endif -} #if YYSTACKDEPTH<=0 /*