diff options
author | danielk1977 <danielk1977@noemail.net> | 2007-09-01 09:02:53 +0000 |
---|---|---|
committer | danielk1977 <danielk1977@noemail.net> | 2007-09-01 09:02:53 +0000 |
commit | ca0c89715e462ad7190c22c1ba30c85d077263f0 (patch) | |
tree | 0d8a87d18da3f03f45031f0ce55120fb670362b8 /src/test6.c | |
parent | 95c8a54c7d4488b5bdd6fb73196bf1463e7556e9 (diff) | |
download | sqlite-ca0c89715e462ad7190c22c1ba30c85d077263f0.tar.gz sqlite-ca0c89715e462ad7190c22c1ba30c85d077263f0.zip |
Fix a problem handling a malloc() failure in printf.c. Also some other things to improve test coverage. (CVS 4361)
FossilOrigin-Name: 595bfe72f053bc6ecb58bb9044a4cdc53d30b404
Diffstat (limited to 'src/test6.c')
-rw-r--r-- | src/test6.c | 72 |
1 files changed, 52 insertions, 20 deletions
diff --git a/src/test6.c b/src/test6.c index 8045509bd..b35130370 100644 --- a/src/test6.c +++ b/src/test6.c @@ -698,33 +698,18 @@ static int processDevSymArgs( } /* -** tclcmd: sqlite_crashparams ?OPTIONS? DELAY CRASHFILE -** -** This procedure implements a TCL command that enables crash testing -** in testfixture. Once enabled, crash testing cannot be disabled. -** -** Available options are "-characteristics" and "-sectorsize". Both require -** an argument. For -sectorsize, this is the simulated sector size in -** bytes. For -characteristics, the argument must be a list of io-capability -** flags to simulate. Valid flags are "atomic", "atomic512", "atomic1K", -** "atomic2K", "atomic4K", "atomic8K", "atomic16K", "atomic32K", -** "atomic64K", "sequential" and "safe_append". -** -** Example: -** -** sqlite_crashparams -sect 1024 -char {atomic sequential} ./test.db 1 +** tclcmd: sqlite_crash_enable ENABLE ** +** Parameter ENABLE must be a boolean value. If true, then the "crash" +** vfs is added to the system. If false, it is removed. */ -static int crashParamsObjCmd( +static int crashEnableCmd( void * clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[] ){ - int iDelay; - const char *zCrashFile; - int nCrashFile, iDc, iSectorSize; - + int isEnable; static sqlite3_vfs crashVfs = { 1, /* iVersion */ 0, /* szOsFile */ @@ -747,6 +732,18 @@ static int crashParamsObjCmd( cfCurrentTime /* xCurrentTime */ }; + if( objc!=2 ){ + Tcl_WrongNumArgs(interp, 1, objv, "ENABLE"); + return TCL_ERROR; + } + + if( Tcl_GetBooleanFromObj(interp, objv[1], &isEnable) ){ + return TCL_ERROR; + } + + if( (isEnable && crashVfs.pAppData) || (!isEnable && !crashVfs.pAppData) ){ + return TCL_OK; + } if( crashVfs.pAppData==0 ){ sqlite3_vfs *pOriginalVfs = sqlite3_vfs_find(0); @@ -754,8 +751,42 @@ static int crashParamsObjCmd( crashVfs.pAppData = (void *)pOriginalVfs; crashVfs.szOsFile = sizeof(CrashFile) + pOriginalVfs->szOsFile; sqlite3_vfs_register(&crashVfs, 0); + }else{ + crashVfs.pAppData = 0; + sqlite3_vfs_unregister(&crashVfs); } + return TCL_OK; +} + +/* +** tclcmd: sqlite_crashparams ?OPTIONS? DELAY CRASHFILE +** +** This procedure implements a TCL command that enables crash testing +** in testfixture. Once enabled, crash testing cannot be disabled. +** +** Available options are "-characteristics" and "-sectorsize". Both require +** an argument. For -sectorsize, this is the simulated sector size in +** bytes. For -characteristics, the argument must be a list of io-capability +** flags to simulate. Valid flags are "atomic", "atomic512", "atomic1K", +** "atomic2K", "atomic4K", "atomic8K", "atomic16K", "atomic32K", +** "atomic64K", "sequential" and "safe_append". +** +** Example: +** +** sqlite_crashparams -sect 1024 -char {atomic sequential} ./test.db 1 +** +*/ +static int crashParamsObjCmd( + void * clientData, + Tcl_Interp *interp, + int objc, + Tcl_Obj *CONST objv[] +){ + int iDelay; + const char *zCrashFile; + int nCrashFile, iDc, iSectorSize; + iDc = -1; iSectorSize = -1; @@ -826,6 +857,7 @@ static int devSymObjCmd( */ int Sqlitetest6_Init(Tcl_Interp *interp){ #ifndef SQLITE_OMIT_DISKIO + Tcl_CreateObjCommand(interp, "sqlite3_crash_enable", crashEnableCmd, 0, 0); Tcl_CreateObjCommand(interp, "sqlite3_crashparams", crashParamsObjCmd, 0, 0); Tcl_CreateObjCommand(interp, "sqlite3_simulate_device", devSymObjCmd, 0, 0); #endif |