AryaWu/sqlite
0
1# 2007 May 242#3# The author disclaims copyright to this source code. In place of4# 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 the12# quick.test and all.test scripts.13#14# $Id: soak.test,v 1.4 2008/11/13 18:29:51 shane Exp $15 16set testdir [file dirname $argv0]17source $testdir/tester.tcl18rename finish_test really_finish_test19proc finish_test {} {}20 21# By default, guarantee that the tests will run for at least 1 hour.22#23set TIMEOUT 360024 25# Process command-line arguments. 26#27if {[llength $argv]>0} {28 foreach {name value} $argv {29 switch -- $name {30 -timeout {31 set TIMEOUT $value32 }33 default {34 puts stderr "Unknown option: $name"35 exit36 }37 }38 }39}40set argv [list]41 42# Test plan:43#44# The general principle is to run those SQLite tests that use45# 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.test53# 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#61set SOAKTESTS {62 fuzz.test63 fuzz_malloc.test64 trans.test65 corruptC.test66}67 68set G(isquick) 169 70set soak_starttime [clock_seconds]71set soak_finishtime [expr {$soak_starttime + $TIMEOUT}]72 73# Loop until the timeout is reached or an error occurs.74#75for {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 $tail84 set sqlite_open_file_count 085 }86 87 if {[set_test_counter errors]>0} break88}89 90really_finish_test91 