/ Check-in [e14e3688]
Login
SQLite training in Houston TX on 2019-11-05 (details)
Part of the 2019 Tcl Conference

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Fixes to malloc3.test so that it can run in transient or persistent failure mode. (CVS 4336)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: e14e3688eb64577a2a7070e4e47e715a5d7d5089
User & Date: danielk1977 2007-08-30 14:41:34
Context
2007-08-30
14:49
Remove the SYNC_BARRIER flag. (CVS 4337) check-in: 5a22d869 user: danielk1977 tags: trunk
14:41
Fixes to malloc3.test so that it can run in transient or persistent failure mode. (CVS 4336) check-in: e14e3688 user: danielk1977 tags: trunk
14:10
Bug fixes in the mutex header file. Tickets #2599 and #2600. (CVS 4335) check-in: 4bdfe141 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to test/malloc3.test.

     9      9   #
    10     10   #***********************************************************************
    11     11   #
    12     12   # This file contains tests to ensure that the library handles malloc() failures
    13     13   # correctly. The emphasis of these tests are the _prepare(), _step() and
    14     14   # _finalize() calls.
    15     15   #
    16         -# $Id: malloc3.test,v 1.12 2007/08/29 12:31:29 danielk1977 Exp $
           16  +# $Id: malloc3.test,v 1.13 2007/08/30 14:41:34 danielk1977 Exp $
    17     17   
    18     18   set testdir [file dirname $argv0]
    19     19   source $testdir/tester.tcl
    20     20   
    21     21   # Only run these tests if memory debugging is turned on.
    22     22   #
    23     23   ifcapable !memdebug {
................................................................................
   173    173   # TEST_AUTOCOMMIT --
   174    174   # 
   175    175   #     A shorthand test to see if a transaction is active or not. The first
   176    176   #     argument - $id - is the integer number of the test case. The second
   177    177   #     argument is either 1 or 0, the expected value of the auto-commit flag.
   178    178   #
   179    179   proc TEST_AUTOCOMMIT {id a} {
   180         -    TEST $id "do_test \$testid { sqlite3_get_autocommit $::DB } {$a}"
          180  +    TEST $id "do_test \$testid { sqlite3_get_autocommit \$::DB } {$a}"
   181    181   }
   182    182   
   183    183   #--------------------------------------------------------------------------
   184    184   # Start of test program declaration
   185    185   #
   186    186   
   187    187   
................................................................................
   515    515   }
   516    516   SQL COMMIT
   517    517   
   518    518   #
   519    519   # End of test program declaration
   520    520   #--------------------------------------------------------------------------
   521    521   
   522         -proc run_test {arglist {pcstart 0} {iFailStart 1}} {
          522  +proc run_test {arglist iRepeat {pcstart 0} {iFailStart 1}} {
   523    523     if {[llength $arglist] %2} {
   524    524       error "Uneven number of arguments to TEST"
   525    525     }
   526    526   
   527    527     for {set i 0} {$i < $pcstart} {incr i} {
   528    528       set k2 [lindex $arglist [expr 2 * $i]]
   529    529       set v2 [lindex $arglist [expr 2 * $i + 1]]
................................................................................
   556    556           incr pc
   557    557         }
   558    558   
   559    559         -sql {
   560    560           set ::rollback_hook_count 0
   561    561   
   562    562           set ac [sqlite3_get_autocommit $::DB]        ;# Auto-Commit
   563         -        sqlite3_memdebug_fail $iFail -repeat 1
          563  +        sqlite3_memdebug_fail $iFail -repeat 0
   564    564           set rc [catch {db eval [lindex $v 1]} msg]   ;# True error occurs
   565    565           set nac [sqlite3_get_autocommit $::DB]       ;# New Auto-Commit 
   566         -
   567    566   
   568    567           if {$rc != 0 && $nac && !$ac} {
   569    568             # Before [db eval] the auto-commit flag was clear. Now it
   570    569             # is set. Since an error occured we assume this was not a
   571    570   	  # commit - therefore a rollback occured. Check that the
   572    571   	  # rollback-hook was invoked.
   573    572             do_test malloc3-rollback_hook.$iterid {
................................................................................
   630    629         }
   631    630   
   632    631         default { error "Unknown switch: $k" }
   633    632       }
   634    633     }
   635    634   }
   636    635   
   637         -# Turn of the Tcl interface's prepared statement caching facility.
          636  +# Turn of the Tcl interface's prepared statement caching facility. Then
          637  +# run the tests with "persistent" malloc failures.
   638    638   db cache size 0
          639  +run_test $::run_test_script 1
   639    640   
   640         -run_test $::run_test_script 9 1
   641         -# run_test [lrange $::run_test_script 0 3] 0 63
   642         -sqlite3_memdebug_fail -1
          641  +# Close and reopen the db.
   643    642   db close
          643  +file delete -force test.db test.db-journal
          644  +sqlite3 db test.db
          645  +set ::DB [sqlite3_connection_pointer db]
          646  +
          647  +# Turn of the Tcl interface's prepared statement caching facility in
          648  +# the new connnection. Then run the tests with "transient" malloc failures.
          649  +db cache size 0
          650  +run_test $::run_test_script 0
   644    651   
          652  +sqlite3_memdebug_fail -1
   645    653   finish_test