os/persistentdata/persistentstorage/sqlite3api/TEST/TclScript/soak.test
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/persistentdata/persistentstorage/sqlite3api/TEST/TclScript/soak.test	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,89 @@
     1.4 +# 2007 May 24
     1.5 +#
     1.6 +# The author disclaims copyright to this source code.  In place of
     1.7 +# a legal notice, here is a blessing:
     1.8 +#
     1.9 +#    May you do good and not evil.
    1.10 +#    May you find forgiveness for yourself and forgive others.
    1.11 +#    May you share freely, never taking more than you give.
    1.12 +#
    1.13 +#***********************************************************************
    1.14 +# This file is the driver for the "soak" tests. It is a peer of the
    1.15 +# quick.test and all.test scripts.
    1.16 +#
    1.17 +# $Id: soak.test,v 1.3 2008/07/12 14:52:20 drh Exp $
    1.18 +
    1.19 +set testdir [file dirname $argv0]
    1.20 +source $testdir/tester.tcl
    1.21 +rename finish_test really_finish_test
    1.22 +proc finish_test {} {}
    1.23 +
    1.24 +# By default, guarantee that the tests will run for at least 1 hour.
    1.25 +#
    1.26 +set TIMEOUT 3600
    1.27 +
    1.28 +# Process command-line arguments. 
    1.29 +#
    1.30 +if {[llength $argv]>0} {
    1.31 +  foreach {name value} $argv {
    1.32 +    switch -- $name {
    1.33 +      -timeout {
    1.34 +        set TIMEOUT $value
    1.35 +      }
    1.36 +      default {
    1.37 +         puts stderr "Unknown option: $name"
    1.38 +         exit
    1.39 +      }
    1.40 +    }
    1.41 +  }
    1.42 +}
    1.43 +set argv [list]
    1.44 +
    1.45 +# Test plan:
    1.46 +#
    1.47 +# The general principle is to run those SQLite tests that use
    1.48 +# pseudo-random data in some way over and over again for a very 
    1.49 +# long time. The number of tests run depends on the value of 
    1.50 +# global variable $TIMEOUT - tests are run for at least $TIMEOUT 
    1.51 +# seconds.
    1.52 +#
    1.53 +#   fuzz.test   (pseudo-random SQL statements)
    1.54 +#   trans.test  (pseudo-random changes to a database followed by rollbacks)
    1.55 +#
    1.56 +# fuzzy malloc?
    1.57 +#
    1.58 +# Many database changes maintaining some kind of invariant. 
    1.59 +# Storing checksums etc.
    1.60 +#
    1.61 +
    1.62 +# List of test files that are run by this file.
    1.63 +#
    1.64 +set SOAKTESTS {
    1.65 +  fuzz.test
    1.66 +  fuzz_malloc.test
    1.67 +  trans.test
    1.68 +}
    1.69 +
    1.70 +set ISQUICK 1
    1.71 +
    1.72 +set soak_starttime  [clock seconds]
    1.73 +set soak_finishtime [expr {$soak_starttime + $TIMEOUT}]
    1.74 +
    1.75 +# Loop until the timeout is reached or an error occurs.
    1.76 +#
    1.77 +for {set iRun 0} {[clock seconds] < $soak_finishtime && $nErr==0} {incr iRun} {
    1.78 +
    1.79 +  set iIdx [expr {$iRun % [llength $SOAKTESTS]}]
    1.80 +  source [file join $testdir [lindex $SOAKTESTS $iIdx]]
    1.81 +  catch {db close}
    1.82 +
    1.83 +  if {$sqlite_open_file_count>0} {
    1.84 +    puts "$tail did not close all files: $sqlite_open_file_count"
    1.85 +    incr nErr
    1.86 +    lappend ::failList $tail
    1.87 +    set sqlite_open_file_count 0
    1.88 +  }
    1.89 +
    1.90 +}
    1.91 +
    1.92 +really_finish_test