]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Make sure mutexes are fully enabled for thread001.test. Take steps to
authordrh <drh@noemail.net>
Mon, 19 Jan 2009 17:40:12 +0000 (17:40 +0000)
committerdrh <drh@noemail.net>
Mon, 19 Jan 2009 17:40:12 +0000 (17:40 +0000)
ensure that the thread tests run during regression testing. (CVS 6193)

FossilOrigin-Name: 6242f113eb40d472b78685c296fecf9f749a11cd

manifest
manifest.uuid
src/test1.c
src/test_mutex.c
src/test_thread.c
test/thread001.test
test/thread_common.tcl

index 777a5bb8927802722af71b49bbb63123226bfb6c..e8cf145e26f97e17a90ad251fc384b9de77b511d 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Fix\sa\sbug\sthat\swas\spreventing\sSQLite\sfrom\sreleasing\slocks\sproperly\sunder\sobscure\scircumstances.\s(CVS\s6192)
-D 2009-01-17T16:59:41
+C Make\ssure\smutexes\sare\sfully\senabled\sfor\sthread001.test.\s\sTake\ssteps\sto\nensure\sthat\sthe\sthread\stests\srun\sduring\sregression\stesting.\s(CVS\s6193)
+D 2009-01-19T17:40:12
 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
 F Makefile.in 05461a9b5803d5ad10c79f989801e9fd2cc3e592
 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
@@ -163,7 +163,7 @@ F src/sqliteLimit.h ffe93f5a0c4e7bd13e70cd7bf84cfb5c3465f45d
 F src/status.c 237b193efae0cf6ac3f0817a208de6c6c6ef6d76
 F src/table.c 23db1e5f27c03160987c122a078b4bb51ef0b2f8
 F src/tclsqlite.c 7d77c3899d0244804d2773c9157e783788627762
-F src/test1.c 84221fbafc2f02e3a9285def0b3ed401f5cde258
+F src/test1.c 58c0026d8764635efe8e7e7cea61e41faecef597
 F src/test2.c 87d2ee3aa13321f1bba55dc9c675b56d97dbc6b4
 F src/test3.c 88a246b56b824275300e6c899634fbac1dc94b14
 F src/test4.c f79ab52d27ff49b784b631a42e2ccd52cfd5c84c
@@ -183,14 +183,14 @@ F src/test_journal.c 0f4b9a929fae2be5bee0230f29204227c3d76c71
 F src/test_loadext.c 97dc8800e46a46ed002c2968572656f37e9c0dd9
 F src/test_malloc.c cf348d78704340f72f8ab9f9327a6d4a0d71d351
 F src/test_md5.c 461a8ba9f4498f5f76dec8cb28322b3225dd070a
-F src/test_mutex.c 66c4ab4e0396a440ddb17cd9b58a05305144f05d
+F src/test_mutex.c 5f772b1b9952e1e559e3d54e63bc7ec6f98fecd0
 F src/test_onefile.c fad2e1b589a840002b8f967ae24397c3ec4a090b
 F src/test_osinst.c 9a70a61e127f9e72bcfca000b20368b1c5367873
 F src/test_pcache.c 29464896d9c67832e4eef916c0682b98d7283d00
 F src/test_schema.c 4b4bf7bb329326458c491b0e6facd4c8c4c5b479
 F src/test_server.c f0a403b5f699c09bd2b1236b6f69830fd6221f6b
 F src/test_tclvar.c 9e42fa59d3d2f064b7ab8628e7ab2dc8a9fe93d4
-F src/test_thread.c d74fc445e0dba0e00806117eb449b307c0b146bf
+F src/test_thread.c 2575a163700ea442b15c009e2e4b0138ddf4f869
 F src/test_wsd.c c297d7d6b8a990239e1bd25935e81d612d8ae31d
 F src/tokenize.c aaa5fa6a4536a9dd7c855a3f66f32508f1612138
 F src/trigger.c ca6d78f7c1314053800386ca64361e487774fda3
@@ -546,12 +546,12 @@ F test/tclsqlite.test 30636c3151ccc2d553aa09020b885054141a1963
 F test/tempdb.test b88ac8a19823cf771d742bf61eef93ef337c06b1
 F test/temptable.test 19b851b9e3e64d91e9867619b2a3f5fffee6e125
 F test/tester.tcl 57b8ad3e60bd14e93c88c9b8f1106221e677d17e
-F test/thread001.test dda1d39cea954d7d43f520891d77a93d3325ab58
+F test/thread001.test 71dca5edec5e44b56a9043da1ce7651c12216fe1
 F test/thread002.test 84c03a9fc4f7a5f92eefe551266afa840c2eb6ae
 F test/thread003.test e17754799649c2b732c295620dca041c32f01e16
 F test/thread1.test 862dd006d189e8b0946935db17399dcac2f8ef91
 F test/thread2.test 91f105374f18a66e73a3254c28fe7c77af69bdea
-F test/thread_common.tcl 8a9d7a4500dfdbbd36679c977831b62c130b76b1
+F test/thread_common.tcl 047f80288b5e1e86bed181097d67e640f1a54a74
 F test/threadtest1.c 6029d9c5567db28e6dc908a0c63099c3ba6c383b
 F test/threadtest2.c ace893054fa134af3fc8d6e7cfecddb8e3acefb9
 F test/tkt1435.test f8c52c41de6e5ca02f1845f3a46e18e25cadac00
@@ -697,7 +697,7 @@ F tool/speedtest16.c c8a9c793df96db7e4933f0852abb7a03d48f2e81
 F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
 F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
-P 2d79aaab134c8a09722cb0466d45e04002bce54f
-R fe1cb874d09c63891e7d7d8934e00ed2
-U danielk1977
-Z 2df5fb48b7bbf02bff054e8b941b04c7
+P 502c66df8b5fc5ec8e3d94202030571a4920fb9c
+R 8a83b779e616608b128caca45f079b56
+U drh
+Z 48ddf893902eeba18b4404a996ee96c5
index 281ccc3409155ae6e6960508bc70d1e4561f779e..c5304609a76e628d909b546b3b64a7243b39ed4c 100644 (file)
@@ -1 +1 @@
-502c66df8b5fc5ec8e3d94202030571a4920fb9c
\ No newline at end of file
+6242f113eb40d472b78685c296fecf9f749a11cd
\ No newline at end of file
index ba82bfed9cb70093f9f831340732de3bc539da6b..9586184ebe7843e8cb46cf585adf06a0973634b0 100644 (file)
@@ -13,7 +13,7 @@
 ** is not included in the SQLite library.  It is used for automated
 ** testing of the SQLite library.
 **
-** $Id: test1.c,v 1.342 2009/01/10 13:24:51 drh Exp $
+** $Id: test1.c,v 1.343 2009/01/19 17:40:12 drh Exp $
 */
 #include "sqliteInt.h"
 #include "tcl.h"
@@ -180,7 +180,8 @@ const char *sqlite3TestErrorName(int rc){
 ** from sqlite3_errcode.
 */
 int sqlite3TestErrCode(Tcl_Interp *interp, sqlite3 *db, int rc){
-  if( rc!=SQLITE_MISUSE && rc!=SQLITE_OK && sqlite3_errcode(db)!=rc ){
+  if( sqlite3_threadsafe()==0 && rc!=SQLITE_MISUSE && rc!=SQLITE_OK
+   && sqlite3_errcode(db)!=rc ){
     char zBuf[200];
     int r2 = sqlite3_errcode(db);
     sprintf(zBuf, "error code %s (%d) does not match sqlite3_errcode %s (%d)",
index 7352c2e83b064ba10781db5a010f065872f76c73..8324803dbe151089f2b97201a201f567deafe7cc 100644 (file)
@@ -10,7 +10,7 @@
 **
 *************************************************************************
 ** 
-** $Id: test_mutex.c,v 1.12 2008/11/04 14:55:47 danielk1977 Exp $
+** $Id: test_mutex.c,v 1.13 2009/01/19 17:40:12 drh Exp $
 */
 
 #include "tcl.h"
@@ -363,11 +363,11 @@ static sqlite3 *getDbPointer(Tcl_Interp *pInterp, Tcl_Obj *pObj){
   sqlite3 *db;
   Tcl_CmdInfo info;
   char *zCmd = Tcl_GetString(pObj);
-  if( 1!=Tcl_GetCommandInfo(pInterp, zCmd, &info) ){
-    Tcl_AppendResult(pInterp, "No such db-handle: \"", zCmd, "\"", 0);
-    return 0;
+  if( Tcl_GetCommandInfo(pInterp, zCmd, &info) ){
+    db = *((sqlite3 **)info.objClientData);
+  }else{
+    db = (sqlite3*)sqlite3TestTextToPtr(zCmd);
   }
-  db = *((sqlite3 **)info.objClientData);
   assert( db );
   return db;
 }
index 1986ddc7d199a64459dceb587bc5706dd06bd819..0f9cbbe0516f8c4563a120e0debafb3f2a1fc2b1 100644 (file)
 ** test that sqlite3 database handles may be concurrently accessed by 
 ** multiple threads. Right now this only works on unix.
 **
-** $Id: test_thread.c,v 1.8 2008/08/28 13:55:10 danielk1977 Exp $
+** $Id: test_thread.c,v 1.9 2009/01/19 17:40:12 drh Exp $
 */
 
 #include "sqliteInt.h"
 #include <tcl.h>
 
-#if SQLITE_THREADSAFE && defined(TCL_THREADS)
+#if SQLITE_THREADSAFE
 
 #include <errno.h>
 #include <unistd.h>
@@ -96,13 +96,14 @@ static Tcl_ThreadCreateType tclScriptThread(ClientData pSqlThread){
   Tcl_Obj *pRes;
   Tcl_Obj *pList;
   int rc;
-
   SqlThread *p = (SqlThread *)pSqlThread;
+  extern int Sqlitetest_mutex_Init(Tcl_Interp*);
 
   interp = Tcl_CreateInterp();
   Tcl_CreateObjCommand(interp, "clock_seconds", clock_seconds_proc, 0, 0);
   Tcl_CreateObjCommand(interp, "sqlthread", sqlthread_proc, pSqlThread, 0);
   Sqlitetest1_Init(interp);
+  Sqlitetest_mutex_Init(interp);
 
   rc = Tcl_Eval(interp, p->zScript);
   pRes = Tcl_GetObjResult(interp);
index 7be3dbb37db3bcba4847c9131fbdecdea36cb7b0..cce9ef0f04bd61bd3c65ede5d973676ca3ae0454 100644 (file)
@@ -9,7 +9,7 @@
 #
 #***********************************************************************
 #
-# $Id: thread001.test,v 1.6 2008/10/07 15:25:49 drh Exp $
+# $Id: thread001.test,v 1.7 2009/01/19 17:40:12 drh Exp $
 
 set testdir [file dirname $argv0]
 
@@ -30,6 +30,8 @@ set ::NTHREAD 10
 #    2) All threads use their own database handles.
 #    3) All threads use their own database handles, shared-cache is enabled.
 #
+#
+#
 foreach {tn same_db shared_cache} [list \
          1  1       0                   \
          2  0       0                   \
@@ -44,7 +46,7 @@ foreach {tn same_db shared_cache} [list \
     sqlite3_enable_shared_cache $shared_cache
     sqlite3_enable_shared_cache $shared_cache
   } $shared_cache
-  sqlite3 db test.db
+  sqlite3 db test.db -fullmutex 1
 
   set dbconfig ""
   if {$same_db} {
@@ -74,11 +76,13 @@ foreach {tn same_db shared_cache} [list \
   do_test thread001.$tn.3 {
     execsql { PRAGMA integrity_check }
   } {ok}
-  
+
   set thread_program {
+    #sqlthread parent {puts STARTING..}
     set needToClose 0
     if {![info exists ::DB]} {
       set ::DB [sqlthread open test.db]
+      #sqlthread parent "puts \"OPEN $::DB\""
       set needToClose 1
     }
   
@@ -97,8 +101,10 @@ foreach {tn same_db shared_cache} [list \
     }
   
     if {$needToClose} {
+      #sqlthread parent "puts \"CLOSE $::DB\""
       sqlite3_close $::DB
     }
+    #sqlthread parent "puts \"DONE\""
   
     list OK
   }
index 5e34b179b1582fb93fadef7b067a649270bedbbb..213e653d2309b1be40239568f242c2df6e72f73d 100644 (file)
@@ -9,7 +9,7 @@
 #
 #***********************************************************************
 #
-# $Id: thread_common.tcl,v 1.2 2007/09/10 10:53:02 danielk1977 Exp $
+# $Id: thread_common.tcl,v 1.3 2009/01/19 17:40:12 drh Exp $
 
 set testdir [file dirname $argv0]
 source $testdir/tester.tcl
@@ -37,6 +37,7 @@ set thread_procs {
         || $rc eq "SQLITE_SCHEMA"} {
       set res [list]
 
+      enter_db_mutex $::DB
       set err [catch {
         set ::STMT [sqlite3_prepare_v2 $::DB $sql -1 dummy_tail]
       } msg]
@@ -59,16 +60,21 @@ set thread_procs {
       if {[string first locked [sqlite3_errmsg $::DB]]>=0} {
         set rc SQLITE_LOCKED
       }
+      if {$rc ne "SQLITE_OK"} {
+        set errtxt "$rc - [sqlite3_errmsg $::DB] (debug1)"
+      }
+      leave_db_mutex $::DB
 
       if {$rc eq "SQLITE_LOCKED" || $rc eq "SQLITE_BUSY"} {
- #puts -nonewline "([sqlthread id] $rc)"
- #flush stdout
-        after 20
+        #sqlthread parent "puts \"thread [sqlthread id] is busy.  rc=$rc\""
+        after 200
+      } else {
+        #sqlthread parent "puts \"thread [sqlthread id] ran $sql\""
       }
     }
 
     if {$rc ne "SQLITE_OK"} {
-      error "$rc - [sqlite3_errmsg $::DB]"
+      error $errtxt
     }
     set res
   }