/ Check-in [3ccce1f5]
Login

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

Overview
Comment:Add additional randomness to crash tests. (CVS 4694)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 3ccce1f58be46787f8a35f0fa6d738ed126c0f07
User & Date: drh 2008-01-08 15:18:52
Context
2008-01-08
16:03
Add crash4.test with additional crash testing. (CVS 4695) check-in: 87b4ac4b user: drh tags: trunk
15:18
Add additional randomness to crash tests. (CVS 4694) check-in: 3ccce1f5 user: drh tags: trunk
02:57
Progress toward registerification of the constraint checking logic for INSERT and UPDATE. (CVS 4693) check-in: b9bf509e user: drh 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 using the modified I/O routines found in test6.c.  
    17     17   # These routines allow us to simulate the kind of file damage that 
    18     18   # occurs after a power failure.
    19     19   #
    20         -# $Id: crash.test,v 1.26 2007/10/09 08:29:32 danielk1977 Exp $
           20  +# $Id: crash.test,v 1.27 2008/01/08 15:18:52 drh 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
................................................................................
    63     63       CREATE TABLE abc(a, b, c);
    64     64       INSERT INTO abc VALUES(1, 2, 3);
    65     65       INSERT INTO abc VALUES(4, 5, 6);
    66     66     }
    67     67     set ::sig [signature]
    68     68     expr 0
    69     69   } {0}
    70         -do_test crash-1.2 {
    71         -  crashsql -delay 1 -file test.db-journal {
    72         -    DELETE FROM abc WHERE a = 1;
    73         -  }
    74         -} {1 {child process exited abnormally}}
    75         -do_test crash-1.3 {
    76         -  signature
    77         -} $::sig
           70  +for {set i 0} {$i<10} {incr i} {
           71  +  set seed [expr {int(abs(rand()*10000))}]
           72  +  do_test crash-1.2.$i {
           73  +    crashsql -delay 1 -file test.db-journal -seed $seed {
           74  +      DELETE FROM abc WHERE a = 1;
           75  +    }
           76  +  } {1 {child process exited abnormally}}
           77  +  do_test crash-1.3.$i {
           78  +    signature
           79  +  } $::sig
           80  +}
    78     81   do_test crash-1.4 {
    79     82     crashsql -delay 1 -file test.db {
    80     83       DELETE FROM abc WHERE a = 1;
    81     84     }
    82     85   } {1 {child process exited abnormally}}
    83     86   do_test crash-1.5 {
    84     87     signature
................................................................................
   181    184       INSERT INTO abc SELECT * FROM abc;
   182    185     }
   183    186     expr ([file size test.db] / 1024) > 450
   184    187   } {1}
   185    188   for {set i 1} {$i < $repeats} {incr i} {
   186    189     set sig [signature]
   187    190     do_test crash-3.$i.1 {
   188         -     crashsql -delay [expr $i%5 + 1] -file test.db-journal "
          191  +     set seed [expr {int(abs(rand()*10000))}]
          192  +     crashsql -delay [expr $i%5 + 1] -file test.db-journal -seed $seed "
   189    193          BEGIN;
   190    194          SELECT random() FROM abc LIMIT $i;
   191    195          INSERT INTO abc VALUES(randstr(10,10), 0, 0);
   192    196          DELETE FROM abc WHERE random()%10!=0;
   193    197          COMMIT;
   194    198        "
   195    199     } {1 {child process exited abnormally}}
................................................................................
   219    223         CREATE TABLE aux.abc2 AS SELECT 2*a as a, 2*b as b, 2*c as c FROM abc;
   220    224       }
   221    225       expr ([file size test2.db] / 1024) > 450
   222    226     } {1}
   223    227     
   224    228     set fin 0
   225    229     for {set i 1} {$i<$repeats} {incr i} {
          230  +    set seed [expr {int(abs(rand()*10000))}]
   226    231       set sig [signature]
   227    232       set sig2 [signature2]
   228    233       do_test crash-4.1.$i.1 {
   229         -       set c [crashsql -delay $i -file test.db-journal "
          234  +       set c [crashsql -delay $i -file test.db-journal -seed $::seed "
   230    235            ATTACH 'test2.db' AS aux;
   231    236            BEGIN;
   232    237            SELECT randstr($i,$i) FROM abc LIMIT $i;
   233    238            INSERT INTO abc VALUES(randstr(10,10), 0, 0);
   234    239            DELETE FROM abc WHERE random()%10!=0;
   235    240            INSERT INTO abc2 VALUES(randstr(10,10), 0, 0);
   236    241            DELETE FROM abc2 WHERE random()%10!=0;
................................................................................
   249    254       do_test crash-4.1.$i.3 {
   250    255         signature2
   251    256       } $sig2
   252    257     } 
   253    258     set i 0
   254    259     set fin 0
   255    260     while {[incr i]} {
          261  +    set seed [expr {int(abs(rand()*10000))}]
   256    262       set sig [signature]
   257    263       set sig2 [signature2]
   258    264       set ::fin 0
   259    265       do_test crash-4.2.$i.1 {
   260         -       set c [crashsql -delay $i -file test2.db-journal "
          266  +       set c [crashsql -delay $i -file test2.db-journal -seed $::seed "
   261    267            ATTACH 'test2.db' AS aux;
   262    268            BEGIN;
   263    269            SELECT randstr($i,$i) FROM abc LIMIT $i;
   264    270            INSERT INTO abc VALUES(randstr(10,10), 0, 0);
   265    271            DELETE FROM abc WHERE random()%10!=0;
   266    272            INSERT INTO abc2 VALUES(randstr(10,10), 0, 0);
   267    273            DELETE FROM abc2 WHERE random()%10!=0;

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.96 2008/01/07 19:20:25 drh Exp $
           14  +# $Id: tester.tcl,v 1.97 2008/01/08 15:18:52 drh Exp $
    15     15   
    16     16   
    17     17   set tcl_precision 15
    18     18   set sqlite_pending_byte 0x0010000
    19     19   
    20     20   # 
    21     21   # Check the command-line arguments for a default soft-heap-limit.
................................................................................
   348    348   proc crashsql {args} {
   349    349     if {$::tcl_platform(platform)!="unix"} {
   350    350       error "crashsql should only be used on unix"
   351    351     }
   352    352   
   353    353     set blocksize ""
   354    354     set crashdelay 1
          355  +  set prngseed 0
   355    356     set crashfile ""
   356    357     set dc ""
   357    358     set sql [lindex $args end]
   358    359     
   359    360     for {set ii 0} {$ii < [llength $args]-1} {incr ii 2} {
   360    361       set z [lindex $args $ii]
   361    362       set n [string length $z]
   362    363       set z2 [lindex $args [expr $ii+1]]
   363    364   
   364    365       if     {$n>1 && [string first $z -delay]==0}     {set crashdelay $z2} \
          366  +    elseif {$n>1 && [string first $z -seed]==0}      {set prngseed $z2} \
   365    367       elseif {$n>1 && [string first $z -file]==0}      {set crashfile $z2}  \
   366    368       elseif {$n>1 && [string first $z -blocksize]==0} {set blocksize "-s $z2" } \
   367    369       elseif {$n>1 && [string first $z -characteristics]==0} {set dc "-c {$z2}" } \
   368    370       else   { error "Unrecognized option: $z" }
   369    371     }
   370    372   
   371    373     if {$crashfile eq ""} {
................................................................................
   382    384   
   383    385     # This block sets the cache size of the main database to 10
   384    386     # pages. This is done in case the build is configured to omit
   385    387     # "PRAGMA cache_size".
   386    388     puts $f {db eval {SELECT * FROM sqlite_master;}}
   387    389     puts $f {set bt [btree_from_db db]}
   388    390     puts $f {btree_set_cache_size $bt 10}
          391  +  if {$prngseed} {
          392  +    set seed [expr {$prngseed%10007+1}]
          393  +    # puts seed=$seed
          394  +    puts $f "db eval {SELECT randomblob($seed)}"
          395  +  }
   389    396   
   390    397     puts $f "db eval {"
   391    398     puts $f   "$sql"
   392    399     puts $f "}"
   393    400     close $f
   394    401   
   395    402     set r [catch {