Home | History | Annotate | Download | only in test
      1 # 2007 May 24
      2 #
      3 # The author disclaims copyright to this source code.  In place of
      4 # a legal notice, here is a blessing:
      5 #
      6 #    May you do good and not evil.
      7 #    May you find forgiveness for yourself and forgive others.
      8 #    May you share freely, never taking more than you give.
      9 #
     10 #***********************************************************************
     11 # This file is the driver for the "soak" tests. It is a peer of the
     12 # quick.test and all.test scripts.
     13 #
     14 # $Id: soak.test,v 1.4 2008/11/13 18:29:51 shane Exp $
     15 
     16 set testdir [file dirname $argv0]
     17 source $testdir/tester.tcl
     18 rename finish_test really_finish_test
     19 proc finish_test {} {}
     20 
     21 # By default, guarantee that the tests will run for at least 1 hour.
     22 #
     23 set TIMEOUT 3600
     24 
     25 # Process command-line arguments. 
     26 #
     27 if {[llength $argv]>0} {
     28   foreach {name value} $argv {
     29     switch -- $name {
     30       -timeout {
     31         set TIMEOUT $value
     32       }
     33       default {
     34          puts stderr "Unknown option: $name"
     35          exit
     36       }
     37     }
     38   }
     39 }
     40 set argv [list]
     41 
     42 # Test plan:
     43 #
     44 # The general principle is to run those SQLite tests that use
     45 # pseudo-random data in some way over and over again for a very 
     46 # long time. The number of tests run depends on the value of 
     47 # global variable $TIMEOUT - tests are run for at least $TIMEOUT 
     48 # seconds.
     49 #
     50 #   fuzz.test     (pseudo-random SQL statements)
     51 #   trans.test    (pseudo-random changes to a database followed by rollbacks)
     52 #   fuzz_malloc.test
     53 #   corruptC.test (pseudo-random corruption to a database)
     54 #
     55 # Many database changes maintaining some kind of invariant. 
     56 # Storing checksums etc.
     57 #
     58 
     59 # List of test files that are run by this file.
     60 #
     61 set SOAKTESTS {
     62   fuzz.test
     63   fuzz_malloc.test
     64   trans.test
     65   corruptC.test
     66 }
     67 
     68 set G(isquick) 1
     69 
     70 set soak_starttime  [clock seconds]
     71 set soak_finishtime [expr {$soak_starttime + $TIMEOUT}]
     72 
     73 # Loop until the timeout is reached or an error occurs.
     74 #
     75 for {set iRun 0} {[clock seconds] < $soak_finishtime} {incr iRun} {
     76 
     77   set iIdx [expr {$iRun % [llength $SOAKTESTS]}]
     78   source [file join $testdir [lindex $SOAKTESTS $iIdx]]
     79   catch {db close}
     80 
     81   if {$sqlite_open_file_count>0} {
     82     puts "$tail did not close all files: $sqlite_open_file_count"
     83     fail_test $tail
     84     set sqlite_open_file_count 0
     85   }
     86 
     87   if {[set_test_counter errors]>0} break
     88 }
     89 
     90 really_finish_test
     91