]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
General test coverage improvements. (CVS 3022)
authordanielk1977 <danielk1977@noemail.net>
Tue, 24 Jan 2006 10:58:21 +0000 (10:58 +0000)
committerdanielk1977 <danielk1977@noemail.net>
Tue, 24 Jan 2006 10:58:21 +0000 (10:58 +0000)
FossilOrigin-Name: 153940af5af4f775fa3b1784931d3fd1e41764c5

main.mk
manifest
manifest.uuid
src/os.c
src/test1.c
src/test6.c
src/utf.c
test/malloc.test
test/tclsqlite.test

diff --git a/main.mk b/main.mk
index ca5fa74803e2045115f2f88e12a8c7213e7c28f1..a5bb9d01c731977276845672d97f3d2eeeace54f 100644 (file)
--- a/main.mk
+++ b/main.mk
@@ -123,6 +123,7 @@ TESTSRC = \
   $(TOP)/src/btree.c \
   $(TOP)/src/date.c \
   $(TOP)/src/func.c \
+  $(TOP)/src/os.c \
   $(TOP)/src/os_unix.c \
   $(TOP)/src/os_win.c \
   $(TOP)/src/pager.c \
index 868fc26b86a3f56b2c5682177b44e352f676ba58..4bb4e90fd716f777aa5ec8afc12a4e2cd22e6c72 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Sqlite3_analyzer\sreports\san\serror\sif\sit\sruns\sinto\strouble.\s(CVS\s3021)
-D 2006-01-24T02:19:53
+C General\stest\scoverage\simprovements.\s(CVS\s3022)
+D 2006-01-24T10:58:22
 F Makefile.in 53841eb72e9eeb6030a8ce28c2595a92f440fd10
 F Makefile.linux-gcc 74ba0eadf88748a9ce3fd03d2a3ede2e6715baec
 F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028
@@ -19,7 +19,7 @@ F doc/lemon.html f0f682f50210928c07e562621c3b7e8ab912a538
 F doc/report1.txt a031aaf37b185e4fa540223cb516d3bccec7eeac
 F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895
 F ltmain.sh f6b283068efa69f06eb8aa1fe4bddfdbdeb35826
-F main.mk ff2b29a41a3862d44075194203f96192a6013871
+F main.mk 8b8d1c8a21f9a898fbf524d7d5935b823d05a433
 F mkdll.sh 89b5390110c0b7fd93d6c456964c2b9adfcfc339
 F mkopcodec.awk bd46ad001c98dfbab07b1713cb8e692fa0e5415d
 F mkopcodeh.awk 071dbba4eaf56c8d643baf4604a043af35683316
@@ -50,7 +50,7 @@ F src/insert.c 4d37e285459af9bc2ff92ae237285b12cd5e8a71
 F src/legacy.c 86b669707b3cefd570e34154e2f6457547d1df4f
 F src/main.c 439168db0a830efd0b9e7325aff39adc5524a1b5
 F src/md5.c c5fdfa5c2593eaee2e32a5ce6c6927c986eaf217
-F src/os.c 1d1a61cdf150e9f9520a3bc787c8465148ea2e78
+F src/os.c 59f05de8c5777c34876607114a2fbe55ae578235
 F src/os.h 93035a0e3b9dd05cdd0aaef32ea28ca28e02fe78
 F src/os_common.h 061fba8511a656b118551424f64e366ad0d4cb3b
 F src/os_test.c 49833426101f99aee4bb5f6a44b7c4b2029fda1c
@@ -73,18 +73,18 @@ F src/sqlite.h.in 492580f7e3ff71eb43193eb7bb98e2d549889ce3
 F src/sqliteInt.h 35a3c3556abfca796cf44fea83c9f04385efcfb6
 F src/table.c 486dcfce532685b53b5a2b5da8bba0ded6fb2316
 F src/tclsqlite.c 7764ab34df617b3d3cfd5f0fdf3444ed219c11d6
-F src/test1.c 846b3731af01ac90bad583f55e7969c8fb232172
+F src/test1.c ce715e15c8045c598fe83a17f862ddeedf60c057
 F src/test2.c ca74a1d8aeb7d9606e8f6b762c5daf85c1a3f92b
 F src/test3.c 86e99724ee898b119ed575ef9f98618afe7e5e5d
 F src/test4.c ff4e9406b3d2809966d8f0e82468ac5508be9f56
 F src/test5.c 7162f8526affb771c4ed256826eee7bb9eca265f
-F src/test6.c 74d91b487c68154156eded457925d96aa2a3fdbb
+F src/test6.c 60a02961ceb7b3edc25f5dc5c1ac2556622a76de
 F src/test7.c d28d3e62f9594923648fc6a8fb030eba36564ba1
 F src/test_async.c 6776f5027ca6378c116ff5ccc2fe41b908e33772
 F src/tokenize.c 9ae9a59238eb97fbc61baea280563b91100518fb
 F src/trigger.c 4d3644cbd16959b568c95ae73493402be8021b08
 F src/update.c 14be4ba2f438919b4217085c02feff569e6cf1f2
-F src/utf.c 5ab8ca05d4e9ec81174b010f01ab12a232f0087d
+F src/utf.c 1199766bbb0157931a83aa6eede6b6381177be64
 F src/util.c 82ee598519b8193184bdeab06b51a4ffa05ad60b
 F src/vacuum.c 3865673cc66acd0717ecd517f6b8fdb2a5e7924b
 F src/vdbe.c 484a724611113426744caa295be6ee947cc51317
@@ -187,7 +187,7 @@ F test/lock.test 9b7afcb24f53d24da502abb33daaad2cd6d44107
 F test/lock2.test d83ba79d3c4fffdb5b926c7d8ca7a36c34288a55
 F test/lock3.test 615111293cf32aa2ed16d01c6611737651c96fb9
 F test/main.test b12f01d49a5c805a33fa6c0ef168691f63056e79
-F test/malloc.test ce6d1e7e79f9db967b51e1975b50760af66db90d
+F test/malloc.test 7d875b2b59ae1d79fba71403298a1eb4a1ed7c38
 F test/malloc2.test e6e321db96d6c94cb18bf82ad7215070c41e624e
 F test/malloc3.test fd4186bee73c2a2638f4e2a05a684c06836f725b
 F test/malloc4.test 59cd02f71b363302a04c4e77b97c0a1572eaa210
@@ -235,7 +235,7 @@ F test/subselect.test 2d13fb7f450db3595adcdd24079a0dd1d2d6abc2
 F test/sync.test 0c43399676de101e3af4d6069a94e211bb77f6b9
 F test/table.test 6dc0dfa44dd429520e0e5a0c5e55025f730e9403
 F test/tableapi.test 6a66d58b37d46dc0f2b3c7d4bd2617d209399bd1
-F test/tclsqlite.test 9b5c4a09879a97572e5c84372f5d045dd4703392
+F test/tclsqlite.test 96f5dbba15df0523e889b8d892f152c2f60b8efb
 F test/temptable.test c36f3e5a94507abb64f7ba23deeb4e1a8a8c3821
 F test/tester.tcl 0a939262ccb0b87449f98d8780396a4c293831b0
 F test/thread1.test 776c9e459b75ba905193b351926ac4019b049f35
@@ -344,7 +344,7 @@ F www/tclsqlite.tcl bb0d1357328a42b1993d78573e587c6dcbc964b9
 F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
 F www/version3.tcl a99cf5f6d8bd4d5537584a2b342f0fb9fa601d8b
 F www/whentouse.tcl 97e2b5cd296f7d8057e11f44427dea8a4c2db513
-P 5254874a96acf89fe5f76c1628057b73ce66de4c
-R 01003271a9b6db821cada0864c4bf62c
-U drh
-Z dd8b891e185e0e2faa5176556f8e1ad6
+P 388b9262281308d0a9dd16e2fb3df3425c2a491a
+R a57aac9d19a26b897ebc5facba2c16a4
+U danielk1977
+Z 44dd13cc4a0c64f905d66d184bb2463e
index 434cfb8eaadeff744fe6d314a4ae9ca0d694491c..941989535f18fcec15f8d90708e84fe9d1d10998 100644 (file)
@@ -1 +1 @@
-388b9262281308d0a9dd16e2fb3df3425c2a491a
\ No newline at end of file
+153940af5af4f775fa3b1784931d3fd1e41764c5
\ No newline at end of file
index 8c7aadbd911b4314716fa728330a82d76b5e6877..ec482fe0e7c2754eb4a80be142784ba22170eb36 100644 (file)
--- a/src/os.c
+++ b/src/os.c
@@ -52,9 +52,14 @@ int sqlite3OsSync(OsFile *id, int fullsync){
 void sqlite3OsSetFullSync(OsFile *id, int value){
   id->pMethod->xSetFullSync(id, value);
 }
+#if defined(SQLITE_TEST) || defined(SQLITE_DEBUG)
+/* This method is currently only used while interactively debugging the 
+** pager. More specificly, it can only be used when sqlite3DebugPrintf() is
+** included in the build. */
 int sqlite3OsFileHandle(OsFile *id){
   return id->pMethod->xFileHandle(id);
 }
+#endif
 int sqlite3OsFileSize(OsFile *id, i64 *pSize){
   return id->pMethod->xFileSize(id, pSize);
 }
index af22b72ba25ecc51acfa80fc9b1f8d8a0d5128c3..a3f85624623e110c700bc8d214cce222096e38c2 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.202 2006/01/23 07:52:38 danielk1977 Exp $
+** $Id: test1.c,v 1.203 2006/01/24 10:58:22 danielk1977 Exp $
 */
 #include "sqliteInt.h"
 #include "tcl.h"
@@ -1005,6 +1005,20 @@ static int test_enable_shared(
 }
 #endif
 
+/*
+** Usage: sqlite3_libversion_number
+**
+*/
+static int test_libversion_number(
+  ClientData clientData, /* Pointer to sqlite3_enable_XXX function */
+  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */
+  int objc,              /* Number of arguments */
+  Tcl_Obj *CONST objv[]  /* Command arguments */
+){
+  Tcl_SetObjResult(interp, Tcl_NewIntObj(sqlite3_libversion_number()));
+  return TCL_OK;
+}
+
 /*
 ** Usage:  sqlite_abort
 **
@@ -1835,7 +1849,7 @@ static int test_bind_text(
 }
 
 /*
-** Usage:   sqlite3_bind_text16  STMT N STRING BYTES
+** Usage:   sqlite3_bind_text16 ?-static? STMT N STRING BYTES
 **
 ** Test the sqlite3_bind_text16 interface.  STMT is a prepared statement.
 ** N is the index of a wildcard in the prepared statement.  This command
@@ -1855,18 +1869,24 @@ static int test_bind_text16(
   char *value;
   int rc;
 
-  if( objc!=5 ){
+  void (*xDel)() = (objc==6?SQLITE_STATIC:SQLITE_TRANSIENT);
+  Tcl_Obj *oStmt    = objv[objc-4];
+  Tcl_Obj *oN       = objv[objc-3];
+  Tcl_Obj *oString  = objv[objc-2];
+  Tcl_Obj *oBytes   = objv[objc-1];
+
+  if( objc!=5 && objc!=6){
     Tcl_AppendResult(interp, "wrong # args: should be \"",
         Tcl_GetStringFromObj(objv[0], 0), " STMT N VALUE BYTES", 0);
     return TCL_ERROR;
   }
 
-  if( getStmtPointer(interp, Tcl_GetString(objv[1]), &pStmt) ) return TCL_ERROR;
-  if( Tcl_GetIntFromObj(interp, objv[2], &idx) ) return TCL_ERROR;
-  value = (char*)Tcl_GetByteArrayFromObj(objv[3], 0);
-  if( Tcl_GetIntFromObj(interp, objv[4], &bytes) ) return TCL_ERROR;
+  if( getStmtPointer(interp, Tcl_GetString(oStmt), &pStmt) ) return TCL_ERROR;
+  if( Tcl_GetIntFromObj(interp, oN, &idx) ) return TCL_ERROR;
+  value = (char*)Tcl_GetByteArrayFromObj(oString, 0);
+  if( Tcl_GetIntFromObj(interp, oBytes, &bytes) ) return TCL_ERROR;
 
-  rc = sqlite3_bind_text16(pStmt, idx, (void *)value, bytes, SQLITE_TRANSIENT);
+  rc = sqlite3_bind_text16(pStmt, idx, (void *)value, bytes, xDel);
   if( sqlite3TestErrCode(interp, StmtToDb(pStmt), rc) ) return TCL_ERROR;
   if( rc!=SQLITE_OK ){
     return TCL_ERROR;
@@ -3521,6 +3541,7 @@ int Sqlitetest1_Init(Tcl_Interp *interp){
 #ifndef SQLITE_OMIT_SHARED_CACHE
      { "sqlite3_enable_shared_cache", test_enable_shared, 0  },
 #endif
+     { "sqlite3_libversion_number", test_libversion_number, 0  },
   };
   static int bitmask_size = sizeof(Bitmask)*8;
   int i;
index 608a140ee382119baab4190a51f10e02ccca722f..32ee4762a7ede063a359f97c883db028cf21a7c3 100644 (file)
@@ -462,7 +462,10 @@ int crashLockState(OsFile *id){
 ** Return the underlying file handle.
 */
 int crashFileHandle(OsFile *id){
+#if defined(SQLITE_TEST) || defined(SQLITE_DEBUG)
   return sqlite3OsFileHandle(((crashFile*)id)->pBase);
+#endif
+  return 0;
 }
 
 /*
index 7261d5adb513ff0a37a8176af16c05b708b8ead6..d6e4e00af9a033651ac0d39d55b1da99248f7b00 100644 (file)
--- a/src/utf.c
+++ b/src/utf.c
@@ -12,7 +12,7 @@
 ** This file contains routines used to translate between UTF-8, 
 ** UTF-16, UTF-16BE, and UTF-16LE.
 **
-** $Id: utf.c,v 1.36 2006/01/13 06:33:24 danielk1977 Exp $
+** $Id: utf.c,v 1.37 2006/01/24 10:58:22 danielk1977 Exp $
 **
 ** Notes on UTF-8:
 **
@@ -479,6 +479,15 @@ int sqlite3utf16ByteLen(const void *zIn, int nChar){
   char const *z = zIn;
   int n = 0;
   if( SQLITE_UTF16NATIVE==SQLITE_UTF16BE ){
+    /* Using an "if (SQLITE_UTF16NATIVE==SQLITE_UTF16BE)" construct here
+    ** and in other parts of this file means that at one branch will
+    ** not be covered by coverage testing on any single host. But coverage
+    ** will be complete if the tests are run on both a little-endian and 
+    ** big-endian host. Because both the UTF16NATIVE and SQLITE_UTF16BE
+    ** macros are constant at compile time the compiler can determine
+    ** which branch will be followed. It is therefore assumed that no runtime
+    ** penalty is paid for this "if" statement.
+    */
     while( c && ((nChar<0) || n<nChar) ){
       READ_UTF16BE(z, c);
       n++;
index d97dbf448a8ed2530aaa33b6cec7639ad4cee0f0..cbeef245de2b1ad2a03e31a88ebf686175e1b021 100644 (file)
@@ -14,7 +14,7 @@
 # special feature is used to see what happens in the library if a malloc
 # were to really fail due to an out-of-memory situation.
 #
-# $Id: malloc.test,v 1.29 2006/01/18 05:51:58 danielk1977 Exp $
+# $Id: malloc.test,v 1.30 2006/01/24 10:58:23 danielk1977 Exp $
 
 set testdir [file dirname $argv0]
 source $testdir/tester.tcl
@@ -483,6 +483,36 @@ do_malloc_test 18 -tclbody {
   }
 }
 
+# This test is aimed at coverage testing. Specificly, it is supposed to
+# cause a malloc() only used when converting between the two utf-16 
+# encodings to fail (i.e. little-endian->big-endian). It only actually 
+# hits this malloc() on little-endian hosts.
+#
+set static_string "\x00h\x00e\x00l\x00l\x00o"
+for {set l 0} {$l<10} {incr l} {
+  append static_string $static_string
+}
+append static_string "\x00\x00"
+do_malloc_test 19 -tclprep {
+  execsql {
+    PRAGMA encoding = "UTF16be";
+    CREATE TABLE abc(a, b, c);
+  }
+} -tclbody {
+  unset -nocomplain ::STMT
+  set r [catch {
+    set ::STMT [sqlite3_prepare $::DB {SELECT ?} -1 DUMMY]
+    sqlite3_bind_text16 -static $::STMT 1 $static_string 112
+  } msg]
+  if {$r} {error [string range $msg 4 end]}
+  set msg
+} -cleanup {
+  if {[info exists ::STMT]} {
+    sqlite3_finalize $::STMT
+  }
+}
+unset static_string
+
 # Ensure that no file descriptors were leaked.
 do_test malloc-99.X {
   catch {db close}
index 185f04a733a92c4d9b628b48d053e75baecae506..c2cf9c4adeb60f33ee9bf1e130a28882abdb7124 100644 (file)
@@ -15,7 +15,7 @@
 # interface is pretty well tested.  This file contains some addition
 # tests for fringe issues that the main test suite does not cover.
 #
-# $Id: tclsqlite.test,v 1.50 2006/01/17 09:35:02 danielk1977 Exp $
+# $Id: tclsqlite.test,v 1.51 2006/01/24 10:58:23 danielk1977 Exp $
 
 set testdir [file dirname $argv0]
 source $testdir/tester.tcl
@@ -447,4 +447,11 @@ do_test tcl-11.3 {
   db exists {SELECT 1 FROM t4 WHERE x==8}
 } {0}
 
+do_test tcl-12.1 {
+  unset -nocomplain a b c version
+  set version [db version]
+  scan $version "%d.%d.%d" a b c
+  expr $a*1000000 + $b*1000 + $c
+} [sqlite3_libversion_number]
+
 finish_test