Modifications to crash-test infrastructure. (CVS 3695)

FossilOrigin-Name: c4be8d9949fc7b5e1bed757423c5195f38069048
This commit is contained in:
danielk1977 2007-03-17 10:26:59 +00:00
parent 933bbd6c8d
commit 59a33f98d6
11 changed files with 114 additions and 64 deletions

View File

@ -1,5 +1,5 @@
C Combine\sthe\stwo\svery\ssimilar\sdefinitions\sof\s(crashsql)\sin\sthe\stest\sscripts.\s(CVS\s3694)
D 2007-03-17T07:22:43
C Modifications\sto\scrash-test\sinfrastructure.\s(CVS\s3695)
D 2007-03-17T10:26:59
F Makefile.in 1fe3d0b46e40fd684e1e61f8e8056cefed16de9f
F Makefile.linux-gcc 2d8574d1ba75f129aba2019f0b959db380a90935
F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028
@ -60,7 +60,7 @@ F src/attach.c fd286a9140a2df84b1482f052b67ff5fad9569a1
F src/auth.c 902f4722661c796b97f007d9606bd7529c02597f
F src/btree.c f5c1b3d88ad62ab4682de37229168a00b87fc948
F src/btree.h 066444ee25bd6e6accb997bfd2cf5ace14dbcd00
F src/build.c f6b2616b60b19520b93cd26f21f76a8d2fbadc49
F src/build.c f2edc786b5bf165a7d0949ed3a5872455a610c0e
F src/callback.c 31d22b4919c7645cbcbb1591ce2453e8c677c558
F src/complete.c 7d1a44be8f37de125fcafd3d3a018690b3799675
F src/date.c 393c73fc027597e008dcd81454544659e978b05c
@ -106,7 +106,7 @@ F src/test2.c 59085c04e22a22bed9f1078ab318adc34c1229f3
F src/test3.c ed494a126221c4b9f66f8f0445554ad749764709
F src/test4.c 8b784cd82de158a2317cb4ac4bc86f91ad315e25
F src/test5.c 7162f8526affb771c4ed256826eee7bb9eca265f
F src/test6.c 60a02961ceb7b3edc25f5dc5c1ac2556622a76de
F src/test6.c edbd903a4886c171f199048af58c3aa5b2a86712
F src/test7.c 03fa8d787f6aebc6d1f72504d52f33013ad2c8e3
F src/test8.c 628ec89f9fbf3bfb9c58a503d845a0719595d0ad
F src/test_async.c e3deaedd4d86a56391b81808fde9e44fbd92f1d3
@ -133,7 +133,7 @@ F src/vtab.c 7fbda947e28cbe7adb3ba752a76ca9ef29936750
F src/where.c 1242dd545ffa7be8b2f539984d5f458ec731a937
F tclinstaller.tcl 046e3624671962dc50f0481d7c25b38ef803eb42
F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2
F test/all.test b62fcd122052efaff1b0979aefa2dd65cfc8ee52
F test/all.test 7da67663cb5af0c95ecd4805d888459023fb8cfd
F test/alter.test a2cc30e844cb3b5d203416962f56f78fc11b1978
F test/alter2.test 8b2d81eae944471d473de99ab25ba6d9cda73cd3
F test/alter3.test a6eec8f454be9b6ce73d8d7dc711453675a10ce7
@ -183,7 +183,7 @@ F test/colmeta.test 6505c73ab58796afcb7c89ba9f429d573fbc6e53
F test/conflict.test 8a59399f61a14296a9bfed02e0570590a8a79cba
F test/corrupt.test 18c7a995b1af76a8c8600b996257f2c7b7bff083
F test/corrupt2.test 572f8df0303d0ce63ddad5c5c9101a83a345ae46
F test/crash.test 61bf6b1467e6308faeb24053731a53b9810d0ad1
F test/crash.test 167eb4652eccbedb199b6f21850346c3f5d779fb
F test/crashtest1.c 09c1c7d728ccf4feb9e481671e29dda5669bbcc2
F test/date.test 63cc718e1d209b10c6b7be8ce72b11addb9f1e04
F test/default.test 252298e42a680146b1dd64f563b95bdf088d94fb
@ -232,7 +232,7 @@ F test/insert3.test 09a532d5b6f3a788d91be0d4d368462f522685d1
F test/insert4.test 0bb119fea2868afdcf78e4e3e3bfed27bbdb2430
F test/interrupt.test c38b7f7c17914f0cd6a119beed5d03bc3f47f9eb
F test/intpkey.test af4fd826c4784ec5c93b444de07adea0254d0d30
F test/ioerr.test 053da63476d1b6a32ec61ac21c0391e614cb1d1a
F test/ioerr.test 491d42c49bbec598966d26b01ed7901f55e5ee2d
F test/join.test af0443185378b64878750aa1cf4b83c216f246b4
F test/join2.test f2171c265e57ee298a27e57e7051d22962f9f324
F test/join3.test 6f0c774ff1ba0489e6c88a3e77b9d3528fb4fda0
@ -249,7 +249,7 @@ F test/lock.test 6825aea0b5885578b1b63a3b178803842c4ee9f1
F test/lock2.test d83ba79d3c4fffdb5b926c7d8ca7a36c34288a55
F test/lock3.test 615111293cf32aa2ed16d01c6611737651c96fb9
F test/main.test e7212ce1023957c7209778cc87fa932bd79ba89a
F test/malloc.test 0eb9fcffa8693bcbc47fd28f26616474da44f18b
F test/malloc.test 2f234703cd206fe441e21341dba2d554a7cf8e68
F test/malloc2.test 4ed7d719542c4570dec9c2ebe2bbdf3a9f3b0d05
F test/malloc3.test fd4186bee73c2a2638f4e2a05a684c06836f725b
F test/malloc4.test 59cd02f71b363302a04c4e77b97c0a1572eaa210
@ -276,7 +276,7 @@ F test/pagesize.test 05c74ea49f790734ec1e9ab765d9bf1cce79b8f2
F test/pragma.test 91739ef06ab9ecf91e90d25951858caba71d6fe7
F test/printf.test cdd8e20dd901382a385afcbaa777b9377815c2ad
F test/progress.test 8b22b4974b0a95272566385f8cb8c341c7130df8 x
F test/quick.test 6bc0f7c7b905f7de5fe4d3f13239ced3e4e66fe7
F test/quick.test 9c02be6cdc6ee2247a1b00486b162cfbd60a01ae
F test/quote.test 5891f2338980916cf7415484b4ce785294044adb
F test/reindex.test 38b138abe36bf9a08c791ed44d9f76cd6b97b78b
F test/rollback.test 673cd8c44c685ad54987fe7f0eeba84efa09685d
@ -305,7 +305,7 @@ F test/table.test feea6a3eb08cf166f570255eea5447e42ef82498
F test/tableapi.test 036575a98dcce7c92e9f39056839bbad8a715412
F test/tclsqlite.test 51334389283c74bcbe28645a73159b17e239e9f3
F test/temptable.test c36f3e5a94507abb64f7ba23deeb4e1a8a8c3821
F test/tester.tcl 4e062859b4a4597e23894b9afa2fbd320b9513a9
F test/tester.tcl 3c7545cbd7fc80a986eda77145e18260dbf34c96
F test/thread1.test 776c9e459b75ba905193b351926ac4019b049f35
F test/thread2.test 6d7b30102d600f51b4055ee3a5a19228799049fb
F test/threadtest1.c 6029d9c5567db28e6dc908a0c63099c3ba6c383b
@ -392,7 +392,7 @@ F www/audit.tcl 90e09d580f79c7efec0c7d6f447b7ec5c2dce5c0
F www/autoinc.tcl b357f5ba954b046ee35392ce0f884a2fcfcdea06
F www/c_interface.tcl b51b08591554c16a0c3ef718364a508ac25abc7e
F www/capi3.tcl 7a7cc225fe02eb7ab861a6019b08baa0014409e1
F www/capi3ref.tcl 4e0df9c41ebc669a7d7e9b81b410d1f907d20e78
F www/capi3ref.tcl 24fc13e145bdc07a77051d944534a97a957267ab
F www/changes.tcl dba0e1f40192f79c7a887fa3efa56e6fdd54f85a
F www/common.tcl 2b793e5c31486c8a01dd27dc0a631ad93704438e
F www/compile.tcl 276546d7eb445add5a867193bbd80f6919a6b084
@ -436,7 +436,7 @@ F www/tclsqlite.tcl bb0d1357328a42b1993d78573e587c6dcbc964b9
F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b
F www/whentouse.tcl 97e2b5cd296f7d8057e11f44427dea8a4c2db513
P fbc53da8c645935c74e49af2ab2cf447dc72ba4e
R 9f3ee429c1669bb49f23db6678a5b730
P eaf434d5887bf75330e1cea12be810dfe667b62a
R 3e037a9ae48873c3a73dcd8bd26cfac6
U danielk1977
Z be503f1e3c0d6d60b895890cf3d106d6
Z 2681bb64cf477e20030d108b1c89215c

View File

@ -1 +1 @@
eaf434d5887bf75330e1cea12be810dfe667b62a
c4be8d9949fc7b5e1bed757423c5195f38069048

View File

@ -22,7 +22,7 @@
** COMMIT
** ROLLBACK
**
** $Id: build.c,v 1.414 2007/03/13 16:32:25 danielk1977 Exp $
** $Id: build.c,v 1.415 2007/03/17 10:26:59 danielk1977 Exp $
*/
#include "sqliteInt.h"
#include <ctype.h>
@ -2362,12 +2362,12 @@ void sqlite3CreateIndex(
goto exit_create_index;
}
}
if( sqlite3FindIndex(db, zName, pDb->zName)!=0 ){
if( !ifNotExist ){
sqlite3ErrorMsg(pParse, "index %s already exists", zName);
}
goto exit_create_index;
if( sqlite3FindIndex(db, zName, pDb->zName)!=0 ){
if( !ifNotExist ){
sqlite3ErrorMsg(pParse, "index %s already exists", zName);
}
goto exit_create_index;
}
}else{
char zBuf[30];
int n;

View File

@ -38,9 +38,9 @@ struct crashFile {
};
/*
** Size of a simulated disk block
** Size of a simulated disk block. Default is 512 bytes.
*/
#define BLOCKSIZE 512
static int BLOCKSIZE = 512;
#define BLOCK_OFFSET(x) ((x) * BLOCKSIZE)
@ -58,6 +58,11 @@ struct crashFile {
static int iCrashDelay = 0;
static char zCrashFile[500];
/*
** A list of all open files.
*/
static crashFile *pAllFiles = 0;
/*
** Set the value of the two crash parameters.
*/
@ -69,6 +74,16 @@ static void setCrashParams(int iDelay, char const *zFile){
sqlite3OsLeaveMutex();
}
/*
** Set the value of the simulated disk block size.
*/
static void setBlocksize(int iBlockSize){
sqlite3OsEnterMutex();
assert( !pAllFiles );
BLOCKSIZE = iBlockSize;
sqlite3OsLeaveMutex();
}
/*
** File zPath is being sync()ed. Return non-zero if this should
** cause a crash.
@ -94,11 +109,6 @@ static int crashRequired(char const *zPath){
return r;
}
/*
** A list of all open files.
*/
static crashFile *pAllFiles = 0;
/* Forward reference */
static void initFile(OsFile **pId, char const *zName, OsFile *pBase);
@ -510,7 +520,7 @@ static void initFile(OsFile **pId, char const *zName, OsFile *pBase){
/*
** tclcmd: sqlite_crashparams DELAY CRASHFILE
** tclcmd: sqlite_crashparams DELAY CRASHFILE ?BLOCKSIZE?
**
** This procedure implements a TCL command that enables crash testing
** in testfixture. Once enabled, crash testing cannot be disabled.
@ -521,20 +531,31 @@ static int crashParamsObjCmd(
int objc,
Tcl_Obj *CONST objv[]
){
int delay;
int iDelay;
const char *zFile;
int nFile;
if( objc!=3 ){
Tcl_WrongNumArgs(interp, 1, objv, "DELAY CRASHFILE");
if( objc!=3 && objc!=4 ){
Tcl_WrongNumArgs(interp, 1, objv, "DELAY CRASHFILE ?BLOCKSIZE?");
return TCL_ERROR;
}
if( Tcl_GetIntFromObj(interp, objv[1], &delay) ) return TCL_ERROR;
if( Tcl_GetIntFromObj(interp, objv[1], &iDelay) ) return TCL_ERROR;
zFile = Tcl_GetStringFromObj(objv[2], &nFile);
if( nFile>=sizeof(zCrashFile)-1 ){
Tcl_AppendResult(interp, "crash file name too big", 0);
return TCL_ERROR;
}
setCrashParams(delay, zFile);
setCrashParams(iDelay, zFile);
if( objc==4 ){
int iBlockSize = 0;
if( Tcl_GetIntFromObj(interp, objv[3], &iBlockSize) ) return TCL_ERROR;
if( pAllFiles ){
char *zErr = "Cannot modify blocksize after opening files";
Tcl_SetResult(interp, zErr, TCL_STATIC);
return TCL_ERROR;
}
setBlocksize(iBlockSize);
}
sqlite3CrashTestEnable = 1;
return TCL_OK;
}

View File

@ -10,7 +10,7 @@
#***********************************************************************
# This file runs all tests.
#
# $Id: all.test,v 1.36 2006/11/23 21:09:11 drh Exp $
# $Id: all.test,v 1.37 2007/03/17 10:26:59 danielk1977 Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
@ -51,6 +51,7 @@ set EXCLUDE {
all.test
async.test
crash.test
crash2.test
autovacuum_crash.test
quick.test
malloc.test

View File

@ -13,11 +13,11 @@
# The focus of this file is testing the ability of the database to
# uses its rollback journal to recover intact (no database corruption)
# from a power failure during the middle of a COMMIT. The OS interface
# modules are overloaded in a separate instance of testfixture using
# the modified I/O routines found in test6.c. These routines allow us
# to simulate the kind of file damage that occurs after a power failure.
# modules are overloaded using the modified I/O routines found in test6.c.
# These routines allow us to simulate the kind of file damage that
# occurs after a power failure.
#
# $Id: crash.test,v 1.22 2007/03/17 07:22:43 danielk1977 Exp $
# $Id: crash.test,v 1.23 2007/03/17 10:26:59 danielk1977 Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
@ -68,7 +68,7 @@ do_test crash-1.1 {
expr 0
} {0}
do_test crash-1.2 {
crashsql 1 test.db-journal {
crashsql -delay 1 -file test.db-journal {
DELETE FROM abc WHERE a = 1;
}
} {1 {child process exited abnormally}}
@ -76,7 +76,7 @@ do_test crash-1.3 {
signature
} $::sig
do_test crash-1.4 {
crashsql 1 test.db {
crashsql -delay 1 -file test.db {
DELETE FROM abc WHERE a = 1;
}
} {1 {child process exited abnormally}}
@ -84,7 +84,7 @@ do_test crash-1.5 {
signature
} $::sig
do_test crash-1.6 {
crashsql 2 test.db-journal {
crashsql -delay 2 -file test.db-journal {
DELETE FROM abc WHERE a = 1;
}
} {1 {child process exited abnormally}}
@ -95,7 +95,7 @@ do_test crash-1.7 {
} {0 {1 2 3 4 5 6}}
do_test crash-1.8 {
crashsql 3 test.db-journal {
crashsql -delay 3 -file test.db-journal {
DELETE FROM abc WHERE a = 1;
}
} {0 {}}
@ -105,7 +105,7 @@ do_test crash-1.9 {
}
} {0 {4 5 6}}
do_test crash-1.10 {
crashsql 2 test.db {
crashsql -delay 2 -file test.db {
DELETE FROM abc WHERE a = 4;
}
} {0 {}}
@ -143,7 +143,7 @@ do_test crash-2.2 {
expr ([file size test.db] / 1024)>16
} {1}
do_test crash-2.3 {
crashsql 2 test.db-journal {
crashsql -delay 2 -file test.db-journal {
DELETE FROM abc WHERE a < 800;
}
} {1 {child process exited abnormally}}
@ -151,7 +151,7 @@ do_test crash-2.4 {
signature
} $sig
do_test crash-2.5 {
crashsql 1 test.db {
crashsql -delay 1 -file test.db {
DELETE FROM abc WHERE a<800;
}
} {1 {child process exited abnormally}}
@ -185,7 +185,7 @@ do_test crash-3.0 {
for {set i 1} {$i < $repeats} {incr i} {
set sig [signature]
do_test crash-3.$i.1 {
crashsql [expr $i%5 + 1] test.db-journal "
crashsql -delay [expr $i%5 + 1] -file test.db-journal "
BEGIN;
SELECT random() FROM abc LIMIT $i;
INSERT INTO abc VALUES(randstr(10,10), 0, 0);
@ -224,7 +224,7 @@ for {set i 1} {$i<$repeats} {incr i} {
set sig [signature]
set sig2 [signature2]
do_test crash-4.1.$i.1 {
set c [crashsql $i test.db-journal "
set c [crashsql -delay $i -file test.db-journal "
ATTACH 'test2.db' AS aux;
BEGIN;
SELECT random() FROM abc LIMIT $i;
@ -249,7 +249,7 @@ while {[incr i]} {
set sig2 [signature2]
set ::fin 0
do_test crash-4.2.$i.1 {
set c [crashsql $i test2.db-journal "
set c [crashsql -delay $i -file test2.db-journal "
ATTACH 'test2.db' AS aux;
BEGIN;
SELECT random() FROM abc LIMIT $i;
@ -277,7 +277,7 @@ for {set i 1} {$i < 5} {incr i} {
set sig [signature]
set sig2 [signature2]
do_test crash-4.3.$i.1 {
crashsql 1 test.db-mj* "
crashsql -delay 1 -file test.db-mj* "
ATTACH 'test2.db' AS aux;
BEGIN;
SELECT random() FROM abc LIMIT $i;
@ -340,7 +340,7 @@ do_test crash-5.3 {
# database file and the journal file does not contain trustworthy rollback
# data for this page.
#
crashsql 1 test.db-journal {
crashsql -delay 1 -file test.db-journal {
BEGIN; -- 1
DELETE FROM abc WHERE oid = 1; -- 2
INSERT INTO abc VALUES(randstr(1500,1500), 0, 0); -- 3
@ -361,7 +361,7 @@ do_test crash-5.5 {
# journal file before truncation in an auto-vacuum database.
#
do_test crash-6.1 {
crashsql 1 test.db {
crashsql -delay 1 -file test.db {
DROP TABLE abc;
}
} {1 {child process exited abnormally}}
@ -374,7 +374,7 @@ do_test crash-6.2 {
# corrupted slightly so that the corruption has to be detected by the
# checksum.
do_test crash-7.1 {
crashsql 1 test.db {
crashsql -delay 1 -file test.db {
ATTACH 'test2.db' AS aux;
BEGIN;
INSERT INTO abc VALUES(randstr(1500,1500), 0, 0);

View File

@ -15,7 +15,7 @@
# The tests in this file use special facilities that are only
# available in the SQLite test fixture.
#
# $Id: ioerr.test,v 1.30 2007/03/15 12:17:43 drh Exp $
# $Id: ioerr.test,v 1.31 2007/03/17 10:26:59 danielk1977 Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
@ -141,7 +141,7 @@ ifcapable crashtest {
CREATE TABLE tx(a, b);
CREATE TABLE aux.ty(a, b);
}
set rc [crashsql 2 test2.db-journal {
set rc [crashsql -delay 2 -file test2.db-journal {
ATTACH 'test2.db' as aux;
PRAGMA cache_size = 10;
BEGIN;

View File

@ -14,7 +14,7 @@
# special feature is used to see what happens in the library if a malloc
# were to really fail due to an out-of-memory situation.
#
# $Id: malloc.test,v 1.36 2006/10/18 23:26:39 drh Exp $
# $Id: malloc.test,v 1.37 2007/03/17 10:26:59 danielk1977 Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
@ -359,7 +359,7 @@ do_malloc_test 12 -tclbody {
# transaction.
ifcapable crashtest {
do_malloc_test 13 -tclprep {
set rc [crashsql 1 test2.db {
set rc [crashsql -delay 1 -file test2.db {
ATTACH 'test2.db' as aux;
PRAGMA cache_size = 10;
BEGIN;

View File

@ -6,7 +6,7 @@
#***********************************************************************
# This file runs all tests.
#
# $Id: quick.test,v 1.47 2006/11/23 21:09:11 drh Exp $
# $Id: quick.test,v 1.48 2007/03/17 10:26:59 danielk1977 Exp $
proc lshift {lvar} {
upvar $lvar l
@ -43,6 +43,7 @@ set EXCLUDE {
btree6.test
corrupt.test
crash.test
crash2.test
loadext.test
malloc.test
malloc2.test

View File

@ -11,7 +11,7 @@
# This file implements some common TCL routines used for regression
# testing the SQLite library
#
# $Id: tester.tcl,v 1.74 2007/03/17 07:22:43 danielk1977 Exp $
# $Id: tester.tcl,v 1.75 2007/03/17 10:26:59 danielk1977 Exp $
# Make sure tclsqlite3 was compiled correctly. Abort now with an
# error message if not.
@ -309,14 +309,37 @@ proc ifcapable {expr code {else ""} {elsecode ""}} {
# error message. This is "child process exited abnormally" if the crash
# occured.
#
proc crashsql {crashdelay crashfile sql} {
# crashsql -delay CRASHDELAY -file CRASHFILE ?-blocksize BLOCKSIZE $sql
#
proc crashsql {args} {
if {$::tcl_platform(platform)!="unix"} {
error "crashsql should only be used on unix"
}
set blocksize ""
set crashdelay 1
set crashfile ""
set sql [lindex $args end]
for {set ii 0} {$ii < [llength $args]-1} {incr ii 2} {
set z [lindex $args $ii]
set n [string length $z]
set z2 [lindex $args [expr $ii+1]]
if {$n>1 && [string first $z -delay]==0} {set crashdelay $z2} \
elseif {$n>1 && [string first $z -file]==0} {set crashfile $z2} \
elseif {$n>1 && [string first $z -blocksize]==0} {set blocksize $z2} \
else { error "Unrecognized option: $z" }
}
if {$crashfile eq ""} {
error "Compulsory option -file missing"
}
set cfile [file join [pwd] $crashfile]
set f [open crash.tcl w]
puts $f "sqlite3_crashparams $crashdelay $cfile"
puts $f "sqlite3_crashparams $crashdelay $cfile $blocksize"
puts $f "set sqlite_pending_byte $::sqlite_pending_byte"
puts $f "sqlite3 db test.db"

View File

@ -1,8 +1,8 @@
set rcsid {$Id: capi3ref.tcl,v 1.52 2007/02/20 15:21:05 drh Exp $}
set rcsid {$Id: capi3ref.tcl,v 1.53 2007/03/17 10:26:59 danielk1977 Exp $}
source common.tcl
header {C/C++ Interface For SQLite Version 3}
puts {
<h2>C/C++ Interface For SQLite Version 3</h2>
<h2 class=pdf_section>C/C++ Interface For SQLite Version 3</h2>
}
proc api {name prototype desc {notused x}} {
@ -1722,6 +1722,7 @@ foreach name [lsort [array names name_to_idx]] {
#parray name_to_idx
#parray sname
incr n -1
puts "<DIV class=pdf_ignore>"
puts {<table width="100%" cellpadding="5"><tr>}
set nrow [expr {($n+2)/3}]
set i 0
@ -1740,6 +1741,7 @@ for {set j 0} {$j<3} {incr j} {
}
puts "</table>"
puts "<!-- $n entries. $nrow rows in 3 columns -->"
puts "</DIV>"
proc resolve_name {ignore_list name} {
global name_to_idx
@ -1756,7 +1758,7 @@ foreach name [lsort [array names name_to_idx]] {
set done($i) 1
foreach {namelist prototype desc} [lindex $apilist $i] break
foreach name $namelist {
puts "<a name=\"$name\">"
puts "<a name=\"$name\"></a>"
}
puts "<p><hr></p>"
puts "<blockquote><pre>"
@ -1773,4 +1775,6 @@ foreach name [lsort [array names name_to_idx]] {
puts "<p>$d3</p>"
}
puts "<DIV class=pdf_ignore>"
footer $rcsid
puts "</DIV>"