sl@0: # 2007 May 24 sl@0: # sl@0: # The author disclaims copyright to this source code. In place of sl@0: # a legal notice, here is a blessing: sl@0: # sl@0: # May you do good and not evil. sl@0: # May you find forgiveness for yourself and forgive others. sl@0: # May you share freely, never taking more than you give. sl@0: # sl@0: #*********************************************************************** sl@0: # This file is the driver for the "soak" tests. It is a peer of the sl@0: # quick.test and all.test scripts. sl@0: # sl@0: # $Id: soak.test,v 1.3 2008/07/12 14:52:20 drh Exp $ sl@0: sl@0: set testdir [file dirname $argv0] sl@0: source $testdir/tester.tcl sl@0: rename finish_test really_finish_test sl@0: proc finish_test {} {} sl@0: sl@0: # By default, guarantee that the tests will run for at least 1 hour. sl@0: # sl@0: set TIMEOUT 3600 sl@0: sl@0: # Process command-line arguments. sl@0: # sl@0: if {[llength $argv]>0} { sl@0: foreach {name value} $argv { sl@0: switch -- $name { sl@0: -timeout { sl@0: set TIMEOUT $value sl@0: } sl@0: default { sl@0: puts stderr "Unknown option: $name" sl@0: exit sl@0: } sl@0: } sl@0: } sl@0: } sl@0: set argv [list] sl@0: sl@0: # Test plan: sl@0: # sl@0: # The general principle is to run those SQLite tests that use sl@0: # pseudo-random data in some way over and over again for a very sl@0: # long time. The number of tests run depends on the value of sl@0: # global variable $TIMEOUT - tests are run for at least $TIMEOUT sl@0: # seconds. sl@0: # sl@0: # fuzz.test (pseudo-random SQL statements) sl@0: # trans.test (pseudo-random changes to a database followed by rollbacks) sl@0: # sl@0: # fuzzy malloc? sl@0: # sl@0: # Many database changes maintaining some kind of invariant. sl@0: # Storing checksums etc. sl@0: # sl@0: sl@0: # List of test files that are run by this file. sl@0: # sl@0: set SOAKTESTS { sl@0: fuzz.test sl@0: fuzz_malloc.test sl@0: trans.test sl@0: } sl@0: sl@0: set ISQUICK 1 sl@0: sl@0: set soak_starttime [clock seconds] sl@0: set soak_finishtime [expr {$soak_starttime + $TIMEOUT}] sl@0: sl@0: # Loop until the timeout is reached or an error occurs. sl@0: # sl@0: for {set iRun 0} {[clock seconds] < $soak_finishtime && $nErr==0} {incr iRun} { sl@0: sl@0: set iIdx [expr {$iRun % [llength $SOAKTESTS]}] sl@0: source [file join $testdir [lindex $SOAKTESTS $iIdx]] sl@0: catch {db close} sl@0: sl@0: if {$sqlite_open_file_count>0} { sl@0: puts "$tail did not close all files: $sqlite_open_file_count" sl@0: incr nErr sl@0: lappend ::failList $tail sl@0: set sqlite_open_file_count 0 sl@0: } sl@0: sl@0: } sl@0: sl@0: really_finish_test