]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Fix bugs in the altermalloc.test and incrblob_err.test scripts. (CVS 4295)
authordanielk1977 <danielk1977@noemail.net>
Sat, 25 Aug 2007 13:09:26 +0000 (13:09 +0000)
committerdanielk1977 <danielk1977@noemail.net>
Sat, 25 Aug 2007 13:09:26 +0000 (13:09 +0000)
FossilOrigin-Name: e5ec17071720a973bbd213a8b23038d3aff25315

manifest
manifest.uuid
src/alter.c
test/altermalloc.test
test/incrblob_err.test
test/malloc_common.tcl

index f7c76209832a599ab27a32e4ccc935ff33857bb6..2fa718ed9b9f01be94a37611ebf913c69e681cbf 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Update\sthe\sasync2.test\stest\sscript\sto\suse\sthe\snew\smalloc()\sfailure\ssimulation\sinterface.\s(CVS\s4294)
-D 2007-08-25T12:39:29
+C Fix\sbugs\sin\sthe\saltermalloc.test\sand\sincrblob_err.test\sscripts.\s(CVS\s4295)
+D 2007-08-25T13:09:26
 F Makefile.in 938f2769921fa1b30c633548f153804021eb1512
 F Makefile.linux-gcc 65241babba6faf1152bf86574477baab19190499
 F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028
@@ -76,7 +76,7 @@ F sqlite.pc.in 30552343140c53304c2a658c080fbe810cd09ca2
 F sqlite3.1 6be1ad09113570e1fc8dcaff84c9b0b337db5ffc
 F sqlite3.def a96c1d0d39362b763d2ddba220a32da41a15c4b4
 F sqlite3.pc.in 985b9bf34192a549d7d370e0f0b6b34a4f61369a
-F src/alter.c f0aac0060ae8102e58f210b44d35b53438d53173
+F src/alter.c fd78c6005456c727a6cb7c01c5266f2aacf6d401
 F src/analyze.c a14237d869c6bea0846493b59317e4097e81a0b6
 F src/attach.c a52225c75b107be8c5bc144a2b6d20201be3f8f8
 F src/auth.c 083c1205b45e3f52291ec539d396b4fc557856b3
@@ -173,7 +173,7 @@ F test/all.test 0b2117b4ccbb3dc88a5259d1735a04d20584b92b
 F test/alter.test c2a9402e17a731e5294ef370214bd9f88351d18d
 F test/alter2.test 50c3f554b8236d179d72511c0a4f23c5eb7f2af3
 F test/alter3.test a6eec8f454be9b6ce73d8d7dc711453675a10ce7
-F test/altermalloc.test 19323e0f452834044c27a54c6e78554d706de7ba
+F test/altermalloc.test 19162a6b6046a858ad123e57b75215f401ceb7fc
 F test/analyze.test 2f55535aa335785db1a2f97d3f3831c16c09f8b0
 F test/async.test 464dc7c7ccb144e8c82ecca429e6d7cd1c96bd6e
 F test/async2.test 8f2c70b831dac7292450d0a42580cf2dab497dbb
@@ -307,7 +307,7 @@ F test/icu.test e6bfae7f625c88fd14df6f540fe835bdfc1e4329
 F test/in.test 369cb2aa1eab02296b4ec470732fe8c131260b1d
 F test/in2.test b1f447f4f0f67e9f83ff931e7e2e30873f9ea055
 F test/incrblob.test 7f95c929b719626443a996b105d2b0ff06f47818
-F test/incrblob_err.test 2501bec57e317e7051451b5093b47fc61a96c85a
+F test/incrblob_err.test bd993cdd0259461bdebbc7559fe7b11e8742f5b3
 F test/incrvacuum.test 569347726ea5940c3359e3d8cabb3505595cb82f
 F test/incrvacuum2.test 82397ceb5941cbe852fd29bb33fcdf5665bc80c2
 F test/incrvacuum_ioerr.test cb331403b8dea3c5bae6163861ff25037b0df56a
@@ -352,7 +352,7 @@ F test/malloc9.test fb99833476bc1a9b0b15573b9a56ae13af843ef9
 F test/mallocA.test f49b8df5e1d2a090830ef5a5f94174c3c930234b
 F test/mallocB.test 56fd615f3fea97180132a89dd1dd2068852ef6a0
 F test/mallocC.test b6b83dea1c3820a70d50b0378481b71bda44bcb3
-F test/malloc_common.tcl 4f07ce6b4a542cc7052e26543406bca439a863f5
+F test/malloc_common.tcl b649c5fc558a137ddf4c69867c89e2e335b342ec
 F test/manydb.test 8de36b8d33aab5ef295b11d9e95310aeded31af8
 F test/memdb.test a67bda4ff90a38f2b19f6c7f95aa7289e051d893
 F test/memleak.test d2d2a1ff7105d32dc3fdf691458cf6cba58c7217
@@ -561,7 +561,7 @@ F www/tclsqlite.tcl 8be95ee6dba05eabcd27a9d91331c803f2ce2130
 F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
 F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b
 F www/whentouse.tcl fc46eae081251c3c181bd79c5faef8195d7991a5
-P 04167483aad42d319393e8caf470d8de11e468d8
-R 3ac03d9834656eb331e47b1b082a24fe
+P 686fcfeda407c29cdb51fe814da616f1ccac5414
+R 79030448b310160e2ed68e6b77c89fcc
 U danielk1977
-Z 187857b23ffd18eb57875326b16afab2
+Z f916d879cdbedc415720abb0ce0c3ff1
index 831483d6769bef11e0e59f1218d9e44953f0d1d0..b93ec5890451e0d30f85e665aea54d470a30f6de 100644 (file)
@@ -1 +1 @@
-686fcfeda407c29cdb51fe814da616f1ccac5414
\ No newline at end of file
+e5ec17071720a973bbd213a8b23038d3aff25315
\ No newline at end of file
index 93748520e3a064dfd1ff59f1046930ec3e3cd4af..1d0137dd19f20fe1ef1cd3f9766e8e3cdefd7fbf 100644 (file)
@@ -12,7 +12,7 @@
 ** This file contains C code routines that used to generate VDBE code
 ** that implements the ALTER TABLE command.
 **
-** $Id: alter.c,v 1.29 2007/08/16 10:09:02 danielk1977 Exp $
+** $Id: alter.c,v 1.30 2007/08/25 13:09:26 danielk1977 Exp $
 */
 #include "sqliteInt.h"
 #include <ctype.h>
@@ -587,7 +587,7 @@ void sqlite3AlterBeginAddColumn(Parse *pParse, SrcList *pSrc){
   assert( pNew->nCol>0 );
   nAlloc = (((pNew->nCol-1)/8)*8)+8;
   assert( nAlloc>=pNew->nCol && nAlloc%8==0 && nAlloc-pNew->nCol<8 );
-  pNew->aCol = (Column*)sqlite3_malloc(sizeof(Column)*nAlloc);
+  pNew->aCol = (Column*)sqlite3MallocZero(sizeof(Column)*nAlloc);
   pNew->zName = sqlite3DbStrDup(db, pTab->zName);
   if( !pNew->aCol || !pNew->zName ){
     db->mallocFailed = 1;
index d9911bfb9257dd54afa7df6885059e85438ada0e..a9085d063a123fdf58a775f0559747f3f0d74542 100644 (file)
 # focus of this script is testing the ALTER TABLE statement and
 # specifically out-of-memory conditions within that command.
 #
-# $Id: altermalloc.test,v 1.3 2006/09/04 18:54:14 drh Exp $
+# $Id: altermalloc.test,v 1.4 2007/08/25 13:09:26 danielk1977 Exp $
 #
 
 set testdir [file dirname $argv0]
 source $testdir/tester.tcl
 
-# Only run these tests if memory debugging is turned on.
-#
-if {[info command sqlite_malloc_stat]==""} {
-  puts "Skipping malloc tests: not compiled with -DSQLITE_MEMDEBUG=1"
-  finish_test
-  return
-}
-
 # If SQLITE_OMIT_ALTERTABLE is defined, omit this file.
 ifcapable !altertable {
   finish_test
   return
 }
 
-# Usage: do_malloc_test <test name> <options...>
-#
-# The first argument, <test number>, is an integer used to name the
-# tests executed by this proc. Options are as follows:
-#
-#     -tclprep          TCL script to run to prepare test.
-#     -sqlprep          SQL script to run to prepare test.
-#     -tclbody          TCL script to run with malloc failure simulation.
-#     -sqlbody          TCL script to run with malloc failure simulation.
-#     -cleanup          TCL script to run after the test.
-#
-# This command runs a series of tests to verify SQLite's ability
-# to handle an out-of-memory condition gracefully. It is assumed
-# that if this condition occurs a malloc() call will return a
-# NULL pointer. Linux, for example, doesn't do that by default. See
-# the "BUGS" section of malloc(3).
-#
-# Each iteration of a loop, the TCL commands in any argument passed
-# to the -tclbody switch, followed by the SQL commands in any argument
-# passed to the -sqlbody switch are executed. Each iteration the
-# Nth call to sqliteMalloc() is made to fail, where N is increased
-# each time the loop runs starting from 1. When all commands execute
-# successfully, the loop ends.
-#
-proc do_malloc_test {tn args} {
-  array set ::mallocopts $args
-
-  set ::go 1
-  for {set ::n 1} {$::go} {incr ::n} {
-
-    do_test $tn.$::n {
-
-      sqlite_malloc_fail 0
-      catch {db close}
-      catch {file delete -force test.db}
-      catch {file delete -force test.db-journal}
-      catch {file delete -force test2.db}
-      catch {file delete -force test2.db-journal}
-      set ::DB [sqlite3 db test.db]
-
-      if {[info exists ::mallocopts(-tclprep)]} {
-        eval $::mallocopts(-tclprep)
-      }
-      if {[info exists ::mallocopts(-sqlprep)]} {
-        execsql $::mallocopts(-sqlprep)
-      }
-
-      sqlite_malloc_fail $::n
-      set ::mallocbody {}
-      if {[info exists ::mallocopts(-tclbody)]} {
-        append ::mallocbody "$::mallocopts(-tclbody)\n"
-      }
-      if {[info exists ::mallocopts(-sqlbody)]} {
-        append ::mallocbody "db eval {$::mallocopts(-sqlbody)}"
-      }
-
-      set v [catch $::mallocbody msg]
-
-      set leftover [lindex [sqlite_malloc_stat] 2]
-      if {$leftover>0} {
-        if {$leftover>1} {puts "\nLeftover: $leftover\nReturn=$v  Message=$msg"}
-        set ::go 0
-        set v {1 1}
-      } else {
-        set v2 [expr {$msg=="" || $msg=="out of memory"}]
-        if {!$v2} {puts "\nError message returned: $msg"}
-        lappend v $v2
-      }
-    } {1 1}
-    sqlite_malloc_fail 0
-
-    if {[info exists ::mallocopts(-cleanup)]} {
-      catch $::mallocopts(-cleanup)
-    }
-  }
-  unset ::mallocopts
-}
+source $testdir/malloc_common.tcl
 
 do_malloc_test altermalloc-1 -tclprep {
   db close
index 5608ea7371485d3a30e8b7aeece9e857d39229df..86e52d91e30db6cd491d856387054b05a52f2471 100644 (file)
@@ -9,7 +9,7 @@
 #
 #***********************************************************************
 #
-# $Id: incrblob_err.test,v 1.3 2007/05/17 16:38:30 danielk1977 Exp $
+# $Id: incrblob_err.test,v 1.4 2007/08/25 13:09:26 danielk1977 Exp $
 #
 
 set testdir [file dirname $argv0]
@@ -22,107 +22,13 @@ ifcapable {!incrblob} {
 
 # Only run these tests if memory debugging is turned on.
 #
-if {[info command sqlite_malloc_stat]==""} {
+if {[info command sqlite3_memdebug_fail]==""} {
    puts "Skipping incrblob_err tests: not compiled with -DSQLITE_MEMDEBUG..."
    finish_test
    return
 }
 
-# Usage: do_malloc_test <test number> <options...>
-#
-# The first argument, <test number>, is an integer used to name the
-# tests executed by this proc. Options are as follows:
-#
-#     -tclprep          TCL script to run to prepare test.
-#     -sqlprep          SQL script to run to prepare test.
-#     -tclbody          TCL script to run with malloc failure simulation.
-#     -sqlbody          TCL script to run with malloc failure simulation.
-#     -cleanup          TCL script to run after the test.
-#
-# This command runs a series of tests to verify SQLite's ability
-# to handle an out-of-memory condition gracefully. It is assumed
-# that if this condition occurs a malloc() call will return a
-# NULL pointer. Linux, for example, doesn't do that by default. See
-# the "BUGS" section of malloc(3).
-#
-# Each iteration of a loop, the TCL commands in any argument passed
-# to the -tclbody switch, followed by the SQL commands in any argument
-# passed to the -sqlbody switch are executed. Each iteration the
-# Nth call to sqliteMalloc() is made to fail, where N is increased
-# each time the loop runs starting from 1. When all commands execute
-# successfully, the loop ends.
-#
-proc do_malloc_test {tn args} {
-  array unset ::mallocopts 
-  array set ::mallocopts $args
-
-  set ::go 1
-  for {set ::n 1} {$::go && $::n < 50000} {incr ::n} {
-    do_test incrblob_err-$tn.$::n {
-
-      # Remove all traces of database files test.db and test2.db from the files
-      # system. Then open (empty database) "test.db" with the handle [db].
-      # 
-      sqlite_malloc_fail 0
-      catch {db close} 
-      catch {file delete -force test.db}
-      catch {file delete -force test.db-journal}
-      catch {file delete -force test2.db}
-      catch {file delete -force test2.db-journal}
-      catch {sqlite3 db test.db} 
-      set ::DB [sqlite3_connection_pointer db]
-
-      # Execute any -tclprep and -sqlprep scripts.
-      #
-      if {[info exists ::mallocopts(-tclprep)]} {
-        eval $::mallocopts(-tclprep)
-      }
-      if {[info exists ::mallocopts(-sqlprep)]} {
-        execsql $::mallocopts(-sqlprep)
-      }
-
-      # Now set the ${::n}th malloc() to fail and execute the -tclbody and
-      # -sqlbody scripts.
-      #
-      sqlite_malloc_fail $::n
-      set ::mallocbody {}
-      if {[info exists ::mallocopts(-tclbody)]} {
-        append ::mallocbody "$::mallocopts(-tclbody)\n"
-      }
-      if {[info exists ::mallocopts(-sqlbody)]} {
-        append ::mallocbody "db eval {$::mallocopts(-sqlbody)}"
-      }
-      set v [catch $::mallocbody msg]
-
-      # If the test fails (if $v!=0) and the database connection actually
-      # exists, make sure the failure code is SQLITE_NOMEM.
-      if {$v && [info command db]=="db" && [info exists ::mallocopts(-sqlbody)]
-              && [db errorcode]!=7} {
-        set v 999
-      }
-
-      set leftover [lindex [sqlite_malloc_stat] 2]
-      if {$leftover>0} {
-        if {$leftover>1} {puts "\nLeftover: $leftover\nReturn=$v  Message=$msg"}
-        set ::go 0
-        if {$v} {
-          puts "\nError message returned: $msg"
-        } else {
-          set v {1 1}
-        }
-      } else {
-        set v2 [expr {$msg=="" || $msg=="out of memory"}]
-        if {!$v2} {puts "\nError message returned: $msg"}
-        lappend v $v2
-      }
-    } {1 1}
-
-    if {[info exists ::mallocopts(-cleanup)]} {
-      catch [list uplevel #0 $::mallocopts(-cleanup)] msg
-    }
-  }
-  unset ::mallocopts
-}
+source $testdir/malloc_common.tcl
 
 set ::fd [open [info script]]
 set ::data [read $::fd]
@@ -173,7 +79,7 @@ do_malloc_test 3 -tclprep {
     error "out of memory" 
   }
 } 
-sqlite_malloc_fail 0
+sqlite3_memdebug_fail -1 0
 
 do_ioerr_test incrblob_err-4 -cksum 1 -sqlprep {
   CREATE TABLE blobs(k, v BLOB);
index c49f5ac61bcd6f8f7ead2408cba308458eac7898..3e31ef4ef8a0cba31c2b5874a8849bfb6045a470 100644 (file)
@@ -1,4 +1,10 @@
 
+ifcapable !memdebug {
+  puts "Skipping malloc tests: not compiled with -DSQLITE_MEMDEBUG..."
+  finish_test
+  return
+}
+
 # Usage: do_malloc_test <test number> <options...>
 #
 # The first argument, <test number>, is an integer used to name the