/ Check-in [e14e3688]
Login

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 Unified Diffs Ignore Whitespace Patch

Changes to test/malloc3.test.

9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
...
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
...
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
...
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
...
630
631
632
633
634
635
636
637

638

639
640
641
642
643



644






645
#
#***********************************************************************
#
# This file contains tests to ensure that the library handles malloc() failures
# correctly. The emphasis of these tests are the _prepare(), _step() and
# _finalize() calls.
#
# $Id: malloc3.test,v 1.12 2007/08/29 12:31:29 danielk1977 Exp $

set testdir [file dirname $argv0]
source $testdir/tester.tcl

# Only run these tests if memory debugging is turned on.
#
ifcapable !memdebug {
................................................................................
# TEST_AUTOCOMMIT --
# 
#     A shorthand test to see if a transaction is active or not. The first
#     argument - $id - is the integer number of the test case. The second
#     argument is either 1 or 0, the expected value of the auto-commit flag.
#
proc TEST_AUTOCOMMIT {id a} {
    TEST $id "do_test \$testid { sqlite3_get_autocommit $::DB } {$a}"
}

#--------------------------------------------------------------------------
# Start of test program declaration
#


................................................................................
}
SQL COMMIT

#
# End of test program declaration
#--------------------------------------------------------------------------

proc run_test {arglist {pcstart 0} {iFailStart 1}} {
  if {[llength $arglist] %2} {
    error "Uneven number of arguments to TEST"
  }

  for {set i 0} {$i < $pcstart} {incr i} {
    set k2 [lindex $arglist [expr 2 * $i]]
    set v2 [lindex $arglist [expr 2 * $i + 1]]
................................................................................
        incr pc
      }

      -sql {
        set ::rollback_hook_count 0

        set ac [sqlite3_get_autocommit $::DB]        ;# Auto-Commit
        sqlite3_memdebug_fail $iFail -repeat 1
        set rc [catch {db eval [lindex $v 1]} msg]   ;# True error occurs
        set nac [sqlite3_get_autocommit $::DB]       ;# New Auto-Commit 


        if {$rc != 0 && $nac && !$ac} {
          # Before [db eval] the auto-commit flag was clear. Now it
          # is set. Since an error occured we assume this was not a
	  # commit - therefore a rollback occured. Check that the
	  # rollback-hook was invoked.
          do_test malloc3-rollback_hook.$iterid {
................................................................................
      }

      default { error "Unknown switch: $k" }
    }
  }
}

# Turn of the Tcl interface's prepared statement caching facility.

db cache size 0


run_test $::run_test_script 9 1
# run_test [lrange $::run_test_script 0 3] 0 63
sqlite3_memdebug_fail -1
db close










finish_test







|







 







|







 







|







 







|


<







 







|
>

>

<
<
|

>
>
>

>
>
>
>
>
>

9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
...
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
...
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
...
556
557
558
559
560
561
562
563
564
565

566
567
568
569
570
571
572
...
629
630
631
632
633
634
635
636
637
638
639
640


641
642
643
644
645
646
647
648
649
650
651
652
653
#
#***********************************************************************
#
# This file contains tests to ensure that the library handles malloc() failures
# correctly. The emphasis of these tests are the _prepare(), _step() and
# _finalize() calls.
#
# $Id: malloc3.test,v 1.13 2007/08/30 14:41:34 danielk1977 Exp $

set testdir [file dirname $argv0]
source $testdir/tester.tcl

# Only run these tests if memory debugging is turned on.
#
ifcapable !memdebug {
................................................................................
# TEST_AUTOCOMMIT --
# 
#     A shorthand test to see if a transaction is active or not. The first
#     argument - $id - is the integer number of the test case. The second
#     argument is either 1 or 0, the expected value of the auto-commit flag.
#
proc TEST_AUTOCOMMIT {id a} {
    TEST $id "do_test \$testid { sqlite3_get_autocommit \$::DB } {$a}"
}

#--------------------------------------------------------------------------
# Start of test program declaration
#


................................................................................
}
SQL COMMIT

#
# End of test program declaration
#--------------------------------------------------------------------------

proc run_test {arglist iRepeat {pcstart 0} {iFailStart 1}} {
  if {[llength $arglist] %2} {
    error "Uneven number of arguments to TEST"
  }

  for {set i 0} {$i < $pcstart} {incr i} {
    set k2 [lindex $arglist [expr 2 * $i]]
    set v2 [lindex $arglist [expr 2 * $i + 1]]
................................................................................
        incr pc
      }

      -sql {
        set ::rollback_hook_count 0

        set ac [sqlite3_get_autocommit $::DB]        ;# Auto-Commit
        sqlite3_memdebug_fail $iFail -repeat 0
        set rc [catch {db eval [lindex $v 1]} msg]   ;# True error occurs
        set nac [sqlite3_get_autocommit $::DB]       ;# New Auto-Commit 


        if {$rc != 0 && $nac && !$ac} {
          # Before [db eval] the auto-commit flag was clear. Now it
          # is set. Since an error occured we assume this was not a
	  # commit - therefore a rollback occured. Check that the
	  # rollback-hook was invoked.
          do_test malloc3-rollback_hook.$iterid {
................................................................................
      }

      default { error "Unknown switch: $k" }
    }
  }
}

# Turn of the Tcl interface's prepared statement caching facility. Then
# run the tests with "persistent" malloc failures.
db cache size 0
run_test $::run_test_script 1



# Close and reopen the db.
db close
file delete -force test.db test.db-journal
sqlite3 db test.db
set ::DB [sqlite3_connection_pointer db]

# Turn of the Tcl interface's prepared statement caching facility in
# the new connnection. Then run the tests with "transient" malloc failures.
db cache size 0
run_test $::run_test_script 0

sqlite3_memdebug_fail -1
finish_test