os/persistentdata/persistentstorage/sqlite3api/TEST/TclScript/soak.test
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
     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.3 2008/07/12 14:52:20 drh 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 #
    53 # fuzzy malloc?
    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 }
    66 
    67 set ISQUICK 1
    68 
    69 set soak_starttime  [clock seconds]
    70 set soak_finishtime [expr {$soak_starttime + $TIMEOUT}]
    71 
    72 # Loop until the timeout is reached or an error occurs.
    73 #
    74 for {set iRun 0} {[clock seconds] < $soak_finishtime && $nErr==0} {incr iRun} {
    75 
    76   set iIdx [expr {$iRun % [llength $SOAKTESTS]}]
    77   source [file join $testdir [lindex $SOAKTESTS $iIdx]]
    78   catch {db close}
    79 
    80   if {$sqlite_open_file_count>0} {
    81     puts "$tail did not close all files: $sqlite_open_file_count"
    82     incr nErr
    83     lappend ::failList $tail
    84     set sqlite_open_file_count 0
    85   }
    86 
    87 }
    88 
    89 really_finish_test