]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Testing coverage enhancements. (CVS 5358)
authordrh <drh@noemail.net>
Tue, 8 Jul 2008 00:06:49 +0000 (00:06 +0000)
committerdrh <drh@noemail.net>
Tue, 8 Jul 2008 00:06:49 +0000 (00:06 +0000)
FossilOrigin-Name: fe80aa58a4ac12db5a92d25d28165f5159f04533

manifest
manifest.uuid
src/build.c
src/test_mutex.c
src/tokenize.c
test/bind.test
test/tokenize.test [new file with mode: 0644]

index 79370b07fdb27fdfdc4a2a2e34e630c54614cc7e..708031cd70a79ab30366dabc615ce611124be030 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Make\scheck-in\s(5356)\scompatible\swith\sbuilds\sthat\sdo\snot\senable\smemory\nmanagement.\s\sRemove\sunnecessary\scode\sfrom\smain.c.\s\sAdd\sout-of-memory\ntests\sfor\ssqlite3_complete16().\s(CVS\s5357)
-D 2008-07-07T19:52:10
+C Testing\scoverage\senhancements.\s(CVS\s5358)
+D 2008-07-08T00:06:50
 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
 F Makefile.in 325dfac0a0dd1cb4d975f1ace6453157892e6042
 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
@@ -98,7 +98,7 @@ F src/btmutex.c 483ced3c52205b04b97df69161fadbf87f4f1ea2
 F src/btree.c e00268557794be741e26cbca1cd77aa37e53b1cc
 F src/btree.h b1bd7e0b8c2e33658aaf447cb0d1d94f74664b6b
 F src/btreeInt.h 02325f04758dba0fcd0c08ac55cd9b189dad61a5
-F src/build.c 88cc5501a87f72d0538b040001d88d31f994edea
+F src/build.c 8779e9276bef80143a9db5d51b19301457680fc1
 F src/callback.c 3ba98ae46f60aa7c2c40eac7d18fe5ba9b706b83
 F src/complete.c cb14e06dbe79dee031031f0d9e686ff306afe07c
 F src/date.c e841168e5520bbbb2a1cbcdce7531d8b23017b4d
@@ -168,14 +168,14 @@ F src/test_hexio.c 2f1122aa3f012fa0142ee3c36ce5c902a70cd12f
 F src/test_loadext.c df8ab3a6481ddebbdf0d28ebac5d9e0790f7860f
 F src/test_malloc.c 62296810d3ee914fc3e05f2a8a69d8f8f42c32e1
 F src/test_md5.c 28209a4e2068711b5443c33104fe41f21d160071
-F src/test_mutex.c b1433eb96520656fb3e4a218253a94ac32bd5775
+F src/test_mutex.c 0a515271d8ee480b7929b8b2ba20a7bc2224ae9f
 F src/test_onefile.c 243157b10275251c5dc2d6619aee2ff9ae22379c
 F src/test_osinst.c 867f1317bd135f942a63eab5a78da40fc70d1493
 F src/test_schema.c 4b4bf7bb329326458c491b0e6facd4c8c4c5b479
 F src/test_server.c f0a403b5f699c09bd2b1236b6f69830fd6221f6b
 F src/test_tclvar.c 73530070df8378571c8ce6bbbbb993236ae3ad0b
 F src/test_thread.c e297dd41db0b249646e69f97d36ec13e56e8b730
-F src/tokenize.c d39f0d6ce75ca9d0fa4041baec42b5e0411a74fc
+F src/tokenize.c 36484c7774914b7e307800a9bfde6a6b2fcd5a57
 F src/trigger.c 1e751f8d5ceeb328d26bf1ccfb2de50653670d49
 F src/update.c 2d7143b9014e955509cc4f323f9a9584fb898f34
 F src/utf.c 8d52f620a7153d90b058502124fe51d821fcdf57
@@ -216,7 +216,7 @@ F test/badutf.test d5360fc31f643d37a973ab0d8b4fb85799c3169f
 F test/between.test 16b1776c6323faadb097a52d673e8e3d8be7d070
 F test/bigfile.test 9a6a8346e4042d9c781ed6cb6553ac871ae30618
 F test/bigrow.test f0aeb7573dcb8caaafea76454be3ade29b7fc747
-F test/bind.test 93e0b1e501bc2123d97749787e6a2c8abeb9f599
+F test/bind.test 6cd35462394bdbf5928ad3f80f6fc43eab0be5ba
 F test/bindxfer.test 995d2cf8df61204d748cde6960443121c4ccd2e1
 F test/bitvec.test 62a512c3f7041d1df12558eb25990e5a19820571
 F test/blob.test 2a38d867bdf08f9ce081776acec1ac8d4bca66be
@@ -527,6 +527,7 @@ F test/tkt3080.test 31a02e87a4c80ed443831c2c5b0e8216ff95ac14
 F test/tkt3093.test fbdbc5b4969244ad11f540759003e361fcaf391f
 F test/tkt3121.test 9da9c57b75c9dbebae70eb19f458bbc616d04280
 F test/tkt3201.test 5b16303169c2262d78586679ae8884337e5fc9a8
+F test/tokenize.test ce430a7aed48fc98301611429595883fdfcab5d7
 F test/trace.test 951cd0f5f571e7f36bf7bfe04be70f90fb16fb00
 F test/trans.test 2fd24cd7aa0b879d49a224cbd647d698f1e7ac5c
 F test/trigger1.test 7c13f39ca36f529bf856e05c7d004fc0531d48b4
@@ -598,7 +599,7 @@ F tool/speedtest16.c c8a9c793df96db7e4933f0852abb7a03d48f2e81
 F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
 F tool/speedtest8.c 1dbced29de5f59ba2ebf877edcadf171540374d1
 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
-P fbd320ed27dc8910f5035b41171576b4a37cb8b9
-R 3bbbd66d8233e7386454ae7a004ab261
+P 28f8b6bfcc3e169f8a54a6681395f2c85bf99cab
+R 45fa0fc8c38b488b294ddeb46f1ccc23
 U drh
-Z cc062abff1f84979b85c070012e27ea8
+Z 80facad624be60e0509d94f9ed839a1b
index 5c563fb9839cebd75fa0e17192e09edd4172f186..f3d5af5d03e6a194441f3e93d44e37f18e1a45aa 100644 (file)
@@ -1 +1 @@
-28f8b6bfcc3e169f8a54a6681395f2c85bf99cab
\ No newline at end of file
+fe80aa58a4ac12db5a92d25d28165f5159f04533
\ No newline at end of file
index 09a82cbaf6fe2018043a3f8f03f3063282f2452a..8fe25968d5fb6681cbf8c397d945c8adea745737 100644 (file)
@@ -22,7 +22,7 @@
 **     COMMIT
 **     ROLLBACK
 **
-** $Id: build.c,v 1.485 2008/06/15 02:51:47 drh Exp $
+** $Id: build.c,v 1.486 2008/07/08 00:06:50 drh Exp $
 */
 #include "sqliteInt.h"
 #include <ctype.h>
@@ -238,6 +238,7 @@ void sqlite3FinishCoding(Parse *pParse){
 void sqlite3NestedParse(Parse *pParse, const char *zFormat, ...){
   va_list ap;
   char *zSql;
+  char *zErrMsg = 0;
 # define SAVE_SZ  (sizeof(Parse) - offsetof(Parse,nVar))
   char saveBuf[SAVE_SZ];
 
@@ -253,7 +254,8 @@ void sqlite3NestedParse(Parse *pParse, const char *zFormat, ...){
   pParse->nested++;
   memcpy(saveBuf, &pParse->nVar, SAVE_SZ);
   memset(&pParse->nVar, 0, SAVE_SZ);
-  sqlite3RunParser(pParse, zSql, 0);
+  sqlite3RunParser(pParse, zSql, &zErrMsg);
+  sqlite3_free(zErrMsg);
   sqlite3_free(zSql);
   memcpy(&pParse->nVar, saveBuf, SAVE_SZ);
   pParse->nested--;
index b24bd2e67542b661cb517cb6667900b1966920b4..c2df5563aae22fb54fda4b3e0d0fb301bc2f961a 100644 (file)
@@ -10,7 +10,7 @@
 **
 *************************************************************************
 ** 
-** $Id: test_mutex.c,v 1.4 2008/06/22 12:37:58 drh Exp $
+** $Id: test_mutex.c,v 1.5 2008/07/08 00:06:50 drh Exp $
 */
 
 #include "tcl.h"
 #include <assert.h>
 #include <string.h>
 
+/* defined in test1.c */
 const char *sqlite3TestErrorName(int);
 
+/* A countable mutex */
 struct sqlite3_mutex {
   sqlite3_mutex *pReal;
   int eType;
 };
 
+/* State variables */
 static struct test_mutex_globals {
-  int isInstalled;
-  sqlite3_mutex_methods m;          /* Interface to "real" mutex system */
-  int aCounter[8];                  /* Number of grabs of each type of mutex */
-  sqlite3_mutex aStatic[6];         /* The six static mutexes */
+  int isInstalled;              /* True if installed */
+  int disableInit;              /* True to cause sqlite3_initalize() to fail */
+  int isInit;                   /* True if initialized */
+  sqlite3_mutex_methods m;      /* Interface to "real" mutex system */
+  int aCounter[8];              /* Number of grabs of each type of mutex */
+  sqlite3_mutex aStatic[6];     /* The six static mutexes */
 } g;
 
+/* Return true if the countable mutex is currently held */
 static int counterMutexHeld(sqlite3_mutex *p){
   return g.m.xMutexHeld(p->pReal);
 }
 
+/* Return true if the countable mutex is not currently held */
 static int counterMutexNotheld(sqlite3_mutex *p){
   return g.m.xMutexNotheld(p->pReal);
 }
 
+/* Initialize the countable mutex interface
+** Or, if g.disableInit is non-zero, then do not initialize but instead
+** return the value of g.disableInit as the result code.  This can be used
+** to simulate an initialization failure.
+*/
 static int counterMutexInit(void){ 
-  return g.m.xMutexInit();
+  int rc;
+  if( g.disableInit ) return g.disableInit;
+  rc = g.m.xMutexInit();
+  g.isInit = 1;
+  return rc;
 }
 
+/*
+** Uninitialize the mutex subsystem
+*/
 static int counterMutexEnd(void){ 
+  assert( g.isInit );
+  g.isInit = 0;
   return g.m.xMutexEnd();
 }
 
+/*
+** Allocate a countable mutex
+*/
 static sqlite3_mutex *counterMutexAlloc(int eType){
   sqlite3_mutex *pReal;
   sqlite3_mutex *pRet = 0;
 
+  assert( g.isInit );
   assert(eType<8 && eType>=0);
 
   pReal = g.m.xMutexAlloc(eType);
@@ -69,24 +94,39 @@ static sqlite3_mutex *counterMutexAlloc(int eType){
   return pRet;
 }
 
+/*
+** Free a countable mutex
+*/
 static void counterMutexFree(sqlite3_mutex *p){
+  assert( g.isInit );
   g.m.xMutexFree(p->pReal);
   if( p->eType==0 || p->eType==1 ){
     free(p);
   }
 }
 
+/*
+** Enter a countable mutex.  Block until entry is safe.
+*/
 static void counterMutexEnter(sqlite3_mutex *p){
+  assert( g.isInit );
   g.aCounter[p->eType]++;
   g.m.xMutexEnter(p->pReal);
 }
 
+/*
+** Try to enter a mutex.  Return true on success.
+*/
 static int counterMutexTry(sqlite3_mutex *p){
+  assert( g.isInit );
   g.aCounter[p->eType]++;
   return g.m.xMutexTry(p->pReal);
 }
 
+/* Leave a mutex
+*/
 static void counterMutexLeave(sqlite3_mutex *p){
+  assert( g.isInit );
   g.m.xMutexLeave(p->pReal);
 }
 
@@ -301,5 +341,8 @@ int Sqlitetest_mutex_Init(Tcl_Interp *interp){
     Tcl_CreateObjCommand(interp, aCmd[i].zName, aCmd[i].xProc, 0, 0);
   }
   memset(&g, 0, sizeof(g));
+
+  Tcl_LinkVar(interp, "disable_mutex_init", 
+              (char*)&g.disableInit, TCL_LINK_INT);
   return SQLITE_OK;
 }
index 4b545a324051beb4c767ddf896f3222d2139ddfe..05622dae127bc08926e787834f409ccfc6d8691f 100644 (file)
@@ -15,7 +15,7 @@
 ** individual tokens and sends those tokens one-by-one over to the
 ** parser for analysis.
 **
-** $Id: tokenize.c,v 1.144 2008/06/15 02:51:48 drh Exp $
+** $Id: tokenize.c,v 1.145 2008/07/08 00:06:50 drh Exp $
 */
 #include "sqliteInt.h"
 #include <ctype.h>
@@ -374,9 +374,9 @@ int sqlite3GetToken(const unsigned char *z, int *tokenType){
 /*
 ** Run the parser on the given SQL string.  The parser structure is
 ** passed in.  An SQLITE_ status code is returned.  If an error occurs
-** and pzErrMsg!=NULL then an error message might be written into 
-** memory obtained from sqlite3_malloc() and *pzErrMsg made to point to that
-** error message.  Or maybe not.
+** then an and attempt is made to write an error message into 
+** memory obtained from sqlite3_malloc() and to make *pzErrMsg point to that
+** error message.
 */
 int sqlite3RunParser(Parse *pParse, const char *zSql, char **pzErrMsg){
   int nErr = 0;
@@ -393,6 +393,7 @@ int sqlite3RunParser(Parse *pParse, const char *zSql, char **pzErrMsg){
   pParse->rc = SQLITE_OK;
   pParse->zTail = pParse->zSql = zSql;
   i = 0;
+  assert( pzErrMsg!=0 );
   pEngine = sqlite3ParserAlloc((void*(*)(size_t))sqlite3Malloc);
   if( pEngine==0 ){
     db->mallocFailed = 1;
@@ -420,19 +421,15 @@ int sqlite3RunParser(Parse *pParse, const char *zSql, char **pzErrMsg){
       case TK_COMMENT: {
         if( db->u1.isInterrupted ){
           pParse->rc = SQLITE_INTERRUPT;
-          if( pzErrMsg ){
-            sqlite3SetString(pzErrMsg, "interrupt", (char*)0);
-          }
+          sqlite3SetString(pzErrMsg, "interrupt", (char*)0);
           goto abort_parse;
         }
         break;
       }
       case TK_ILLEGAL: {
-        if( pzErrMsg ){
-          sqlite3_free(*pzErrMsg);
-          *pzErrMsg = sqlite3MPrintf(db, "unrecognized token: \"%T\"",
-                          &pParse->sLastToken);
-        }
+        sqlite3_free(*pzErrMsg);
+        *pzErrMsg = sqlite3MPrintf(db, "unrecognized token: \"%T\"",
+                        &pParse->sLastToken);
         nErr++;
         goto abort_parse;
       }
@@ -466,7 +463,7 @@ abort_parse:
     sqlite3SetString(&pParse->zErrMsg, sqlite3ErrStr(pParse->rc), (char*)0);
   }
   if( pParse->zErrMsg ){
-    if( pzErrMsg && *pzErrMsg==0 ){
+    if( *pzErrMsg==0 ){
       *pzErrMsg = pParse->zErrMsg;
     }else{
       sqlite3_free(pParse->zErrMsg);
index 075ffd10c9a35511bb709aaf5b75f5c28e774d53..3b74998664e649e9853065213278536fa4be8b22 100644 (file)
@@ -11,7 +11,7 @@
 # This file implements regression tests for SQLite library.  The
 # focus of this script testing the sqlite_bind API.
 #
-# $Id: bind.test,v 1.42 2008/04/16 16:11:49 drh Exp $
+# $Id: bind.test,v 1.43 2008/07/08 00:06:51 drh Exp $
 #
 
 set testdir [file dirname $argv0]
@@ -91,6 +91,19 @@ do_test bind-1.9 {
   execsql {SELECT rowid, * FROM t1}
 } {1 123 abcdefg {} 2 456 abcdefg {}}
 
+do_test bind-1.10 {
+   set rc [catch {
+     sqlite3_prepare db {INSERT INTO t1 VALUES($abc:123,?,:abc)} -1 TAIL
+   } msg]
+   lappend rc $msg
+} {1 {(1) near ":123": syntax error}}
+do_test bind-1.11 {
+   set rc [catch {
+     sqlite3_prepare db {INSERT INTO t1 VALUES(@abc:xyz,?,:abc)} -1 TAIL
+   } msg]
+   lappend rc $msg
+} {1 {(1) near ":xyz": syntax error}}
+
 do_test bind-1.99 {
   sqlite3_finalize $VM
 } SQLITE_OK
diff --git a/test/tokenize.test b/test/tokenize.test
new file mode 100644 (file)
index 0000000..46fd4ee
--- /dev/null
@@ -0,0 +1,65 @@
+# 2008 July 7
+#
+# 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 testing the tokenizer
+#
+# $Id: tokenize.test,v 1.1 2008/07/08 00:06:51 drh Exp $
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+do_test tokenize-1.1 {
+  catchsql {SELECT 1.0e+}
+} {1 {unrecognized token: "1.0e"}}
+do_test tokenize-1.2 {
+  catchsql {SELECT 1.0E+}
+} {1 {unrecognized token: "1.0E"}}
+do_test tokenize-1.3 {
+  catchsql {SELECT 1.0e-}
+} {1 {unrecognized token: "1.0e"}}
+do_test tokenize-1.4 {
+  catchsql {SELECT 1.0E-}
+} {1 {unrecognized token: "1.0E"}}
+do_test tokenize-1.5 {
+  catchsql {SELECT 1.0e+/}
+} {1 {unrecognized token: "1.0e"}}
+do_test tokenize-1.6 {
+  catchsql {SELECT 1.0E+:}
+} {1 {unrecognized token: "1.0E"}}
+do_test tokenize-1.7 {
+  catchsql {SELECT 1.0e-:}
+} {1 {unrecognized token: "1.0e"}}
+do_test tokenize-1.8 {
+  catchsql {SELECT 1.0E-/}
+} {1 {unrecognized token: "1.0E"}}
+do_test tokenize-1.9 {
+  catchsql {SELECT 1.0F+5}
+} {1 {unrecognized token: "1.0F"}}
+do_test tokenize-1.10 {
+  catchsql {SELECT 1.0d-10}
+} {1 {unrecognized token: "1.0d"}}
+do_test tokenize-1.11 {
+  catchsql {SELECT 1.0e,5}
+} {1 {unrecognized token: "1.0e"}}
+do_test tokenize-1.12 {
+  catchsql {SELECT 1.0E.10}
+} {1 {unrecognized token: "1.0E"}}
+
+do_test tokenize-2.1 {
+  catchsql {SELECT 1, 2 /*}
+} {1 {near "*": syntax error}}
+do_test tokenize-2.2 {
+  catchsql {SELECT 1, 2 /* }
+} {0 {1 2}}
+
+
+finish_test