Improvements to the ".testctrl fault_install" command in the CLI.

FossilOrigin-Name: 48b34ded82d0cec8a7dd67431f057b320b8c459b1b78c0fbf79bc2b355e85d4e
This commit is contained in:
drh 2024-05-10 17:05:24 +00:00
parent 7e60106d15
commit 0e4afddadf
3 changed files with 31 additions and 15 deletions

View File

@ -1,5 +1,5 @@
C Add\san\ssqlite3FaultSim(300)\scall\sto\sthe\ssqlite3ParserAddCleanup()\sroutine\nfor\smore\sprecise\ssimulation\sof\sOOM\serrors\sin\sthat\sroutine.
D 2024-05-10T16:28:35.966
C Improvements\sto\sthe\s".testctrl\sfault_install"\scommand\sin\sthe\sCLI.
D 2024-05-10T17:05:24.627
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
@ -754,7 +754,7 @@ F src/random.c 606b00941a1d7dd09c381d3279a058d771f406c5213c9932bbd93d5587be4b9c
F src/resolve.c 8816212645e4e9bdf3cc2f2d298304f388d699f8fab47f3a5712ef5bbc5b6ccc
F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97
F src/select.c ce81687d769b174aa547b8216a34fabc9cafc05789b615494ab78dc2c1e799fa
F src/shell.c.in 0354ca51eee5fbf6af394a7ef9f5ef6823ef45b743db65431f6777e4d5be2199
F src/shell.c.in 8f2406e4e8d726452e48058d117f52e86b789f47435157b0418fb06c631349b6
F src/sqlite.h.in 32389e0d584551b300d0157881336162c14315a424cbf385c0d65eb7c2e31f7b
F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8
F src/sqlite3ext.h 3f046c04ea3595d6bfda99b781926b17e672fd6d27da2ba6d8d8fc39981dcb54
@ -2189,11 +2189,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
P 1d6716054d7fc50df237996c3db30e5fb8e32acbf48cb8b9af472360515945c4
R dbff3b0072db6fdc65663e31e8141b09
T *branch * cleanup-testing
T *sym-cleanup-testing *
T -sym-trunk *
P 1e8863909ac369e5e62e82e53b6e5a7cc6794100cef281ede00b0bb9bbc28594
R 8cf25f7e0890ed58515d4489ba665230
U drh
Z 3a787a3d44ce577cad9fbd2868c41f20
Z ccce4523fbbf328d3eae15c83868f55f
# Remove this line to create a well-formed Fossil manifest.

View File

@ -1 +1 @@
1e8863909ac369e5e62e82e53b6e5a7cc6794100cef281ede00b0bb9bbc28594
48b34ded82d0cec8a7dd67431f057b320b8c459b1b78c0fbf79bc2b355e85d4e

View File

@ -7940,7 +7940,10 @@ static struct {
int iCnt; /* Trigger the fault only if iCnt is already zero */
int iInterval; /* Reset iCnt to this value after each fault */
int eVerbose; /* When to print output */
} faultsim_state = {-1, 0, 0, 0, 0};
int nHit; /* Number of hits seen so far */
int nRepeat; /* Turn off after this many hits. 0 for never */
int nSkip; /* Skip this many before first fault */
} faultsim_state = {-1, 0, 0, 0, 0, 0, 0};
/*
** This is the fault-sim callback
@ -7949,8 +7952,8 @@ static int faultsim_callback(int iArg){
if( faultsim_state.iId>0 && faultsim_state.iId!=iArg ){
return SQLITE_OK;
}
if( faultsim_state.iCnt>0 ){
faultsim_state.iCnt--;
if( faultsim_state.iCnt ){
if( faultsim_state.iCnt>0 ) faultsim_state.iCnt--;
if( faultsim_state.eVerbose>=2 ){
oputf("FAULT-SIM id=%d no-fault (cnt=%d)\n", iArg, faultsim_state.iCnt);
}
@ -7960,6 +7963,10 @@ static int faultsim_callback(int iArg){
oputf("FAULT-SIM id=%d returns %d\n", iArg, faultsim_state.iErr);
}
faultsim_state.iCnt = faultsim_state.iInterval;
faultsim_state.nHit++;
if( faultsim_state.nRepeat>0 && faultsim_state.nRepeat<=faultsim_state.nHit ){
faultsim_state.iCnt = -1;
}
return faultsim_state.iErr;
}
@ -11121,17 +11128,23 @@ static int do_meta_command(char *zLine, ShellState *p){
if( cli_strcmp(z,"off")==0 ){
sqlite3_test_control(testctrl, 0);
}else if( cli_strcmp(z,"on")==0 ){
faultsim_state.iCnt = faultsim_state.iInterval;
faultsim_state.iCnt = faultsim_state.nSkip;
if( faultsim_state.iErr==0 ) faultsim_state.iErr = 1;
faultsim_state.nHit = 0;
sqlite3_test_control(testctrl, faultsim_callback);
}else if( cli_strcmp(z,"reset")==0 ){
faultsim_state.iCnt = faultsim_state.iInterval;
faultsim_state.iCnt = faultsim_state.nSkip;
faultsim_state.nHit = 0;
sqlite3_test_control(testctrl, faultsim_callback);
}else if( cli_strcmp(z,"status")==0 ){
oputf("faultsim.iId: %d\n", faultsim_state.iId);
oputf("faultsim.iErr: %d\n", faultsim_state.iErr);
oputf("faultsim.iCnt: %d\n", faultsim_state.iCnt);
oputf("faultsim.nHit: %d\n", faultsim_state.nHit);
oputf("faultsim.iInterval: %d\n", faultsim_state.iInterval);
oputf("faultsim.eVerbose: %d\n", faultsim_state.eVerbose);
oputf("faultsim.nRepeat: %d\n", faultsim_state.nRepeat);
oputf("faultsim.nSkip: %d\n", faultsim_state.nSkip);
}else if( cli_strcmp(z,"-v")==0 ){
if( faultsim_state.eVerbose<2 ) faultsim_state.eVerbose++;
}else if( cli_strcmp(z,"-q")==0 ){
@ -11142,6 +11155,10 @@ static int do_meta_command(char *zLine, ShellState *p){
faultsim_state.iErr = atoi(azArg[++kk]);
}else if( cli_strcmp(z,"-interval")==0 && kk+1<nArg ){
faultsim_state.iInterval = atoi(azArg[++kk]);
}else if( cli_strcmp(z,"-repeat")==0 && kk+1<nArg ){
faultsim_state.nRepeat = atoi(azArg[++kk]);
}else if( cli_strcmp(z,"-skip")==0 && kk+1<nArg ){
faultsim_state.nSkip = atoi(azArg[++kk]);
}else if( cli_strcmp(z,"-?")==0 || sqlite3_strglob("*help*",z)==0){
bShowHelp = 1;
}else{
@ -11165,6 +11182,8 @@ static int do_meta_command(char *zLine, ShellState *p){
" --errcode N When triggered, return N as error code\n"
" --id ID Trigger only for the ID specified\n"
" --interval N Trigger only after every N-th call\n"
" --repeat N Turn off after N hits. 0 means never\n"
" --skip N Skip the first N encounters\n"
);
}
break;