/ Check-in [eaf434d5]
Login

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

Overview
Comment:Combine the two very similar definitions of (crashsql) in the test scripts. (CVS 3694)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: eaf434d5887bf75330e1cea12be810dfe667b62a
User & Date: danielk1977 2007-03-17 07:22:43
Context
2007-03-17
10:26
Modifications to crash-test infrastructure. (CVS 3695) check-in: c4be8d99 user: danielk1977 tags: trunk
07:22
Combine the two very similar definitions of (crashsql) in the test scripts. (CVS 3694) check-in: eaf434d5 user: danielk1977 tags: trunk
2007-03-16
18:30
Out-of-memory cleanup in tokenizers. Handle NULL return from malloc/calloc/realloc appropriately, and use sizeof(var) instead of sizeof(type) to make certain that we don't get a mismatch between them as the code rots. (CVS 3693) check-in: fbc53da8 user: shess tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to test/crash.test.

    13     13   # The focus of this file is testing the ability of the database to
    14     14   # uses its rollback journal to recover intact (no database corruption)
    15     15   # from a power failure during the middle of a COMMIT.  The OS interface
    16     16   # modules are overloaded in a separate instance of testfixture using
    17     17   # the modified I/O routines found in test6.c.  These routines allow us
    18     18   # to simulate the kind of file damage that occurs after a power failure.
    19     19   #
    20         -# $Id: crash.test,v 1.21 2006/01/06 14:32:20 drh Exp $
           20  +# $Id: crash.test,v 1.22 2007/03/17 07:22:43 danielk1977 Exp $
    21     21   
    22     22   set testdir [file dirname $argv0]
    23     23   source $testdir/tester.tcl
    24     24   
    25     25   ifcapable !crashtest {
    26     26     finish_test
    27     27     return
    28     28   }
    29     29   
    30     30   # set repeats 100
    31     31   set repeats 10
    32     32   
    33         -# This proc execs a seperate process that crashes midway through executing
    34         -# the SQL script $sql on database test.db.
    35         -#
    36         -# The crash occurs during a sync() of file $crashfile. When the crash
    37         -# occurs a random subset of all unsynced writes made by the process are
    38         -# written into the files on disk. Argument $crashdelay indicates the
    39         -# number of file syncs to wait before crashing.
    40         -#
    41         -# The return value is a list of two elements. The first element is a
    42         -# boolean, indicating whether or not the process actually crashed or
    43         -# reported some other error. The second element in the returned list is the
    44         -# error message. This is "child process exited abnormally" if the crash
    45         -# occured.
    46         -proc crashsql {crashdelay crashfile sql} {
    47         -  set cfile [file join [pwd] $crashfile]
    48         -
    49         -  set f [open crash.tcl w]
    50         -  puts $f "sqlite3_crashparams $crashdelay $cfile"
    51         -  puts $f "set sqlite_pending_byte $::sqlite_pending_byte"
    52         -  puts $f {sqlite3 db test.db}
    53         -
    54         -  # This block sets the cache size of the main database to 10
    55         -  # pages. This is done in case the build is configured to omit
    56         -  # "PRAGMA cache_size".
    57         -  puts $f {db eval {SELECT * FROM sqlite_master;}}
    58         -  puts $f {set bt [btree_from_db db]}
    59         -  puts $f {btree_set_cache_size $bt 10}
    60         -
    61         -  puts $f "db eval {"
    62         -  puts $f   "$sql"
    63         -  puts $f "}"
    64         -  close $f
    65         -
    66         -  set r [catch {
    67         -    exec [info nameofexec] crash.tcl >@stdout
    68         -  } msg]
    69         -  lappend r $msg
    70         -}
    71         -
    72     33   # The following procedure computes a "signature" for table "abc".  If
    73     34   # abc changes in any way, the signature should change.  
    74     35   proc signature {} {
    75     36     return [db eval {SELECT count(*), md5sum(a), md5sum(b), md5sum(c) FROM abc}]
    76     37   }
    77     38   proc signature2 {} {
    78     39     return [db eval {SELECT count(*), md5sum(a), md5sum(b), md5sum(c) FROM abc2}]

Changes to test/tester.tcl.

     7      7   #    May you find forgiveness for yourself and forgive others.
     8      8   #    May you share freely, never taking more than you give.
     9      9   #
    10     10   #***********************************************************************
    11     11   # This file implements some common TCL routines used for regression
    12     12   # testing the SQLite library
    13     13   #
    14         -# $Id: tester.tcl,v 1.73 2007/03/15 12:17:43 drh Exp $
           14  +# $Id: tester.tcl,v 1.74 2007/03/17 07:22:43 danielk1977 Exp $
    15     15   
    16     16   # Make sure tclsqlite3 was compiled correctly.  Abort now with an
    17     17   # error message if not.
    18     18   #
    19     19   if {[sqlite3 -tcl-uses-utf]} {
    20     20     if {"\u1234"=="u1234"} {
    21     21       puts stderr "***** BUILD PROBLEM *****"
................................................................................
   313    313     if {$::tcl_platform(platform)!="unix"} {
   314    314       error "crashsql should only be used on unix"
   315    315     }
   316    316     set cfile [file join [pwd] $crashfile]
   317    317   
   318    318     set f [open crash.tcl w]
   319    319     puts $f "sqlite3_crashparams $crashdelay $cfile"
          320  +  puts $f "set sqlite_pending_byte $::sqlite_pending_byte"
   320    321     puts $f "sqlite3 db test.db"
   321         -  puts $f "db eval {pragma cache_size = 10}"
          322  +
          323  +  # This block sets the cache size of the main database to 10
          324  +  # pages. This is done in case the build is configured to omit
          325  +  # "PRAGMA cache_size".
          326  +  puts $f {db eval {SELECT * FROM sqlite_master;}}
          327  +  puts $f {set bt [btree_from_db db]}
          328  +  puts $f {btree_set_cache_size $bt 10}
          329  +
   322    330     puts $f "db eval {"
   323    331     puts $f   "$sql"
   324    332     puts $f "}"
   325    333     close $f
   326    334   
   327    335     set r [catch {
   328    336       exec [info nameofexec] crash.tcl >@stdout