aboutsummaryrefslogtreecommitdiff
path: root/src/test_malloc.c
diff options
context:
space:
mode:
authordrh <drh@noemail.net>2018-05-24 17:38:00 +0000
committerdrh <drh@noemail.net>2018-05-24 17:38:00 +0000
commitb9cd2c4536880e8588f8f5c90b6e375b98c8697b (patch)
treeedba74079bd10d4a799064106dd3adab02303c7a /src/test_malloc.c
parentbbd574bc375bb4414526ec9e26849dd58f212e80 (diff)
downloadsqlite-b9cd2c4536880e8588f8f5c90b6e375b98c8697b.tar.gz
sqlite-b9cd2c4536880e8588f8f5c90b6e375b98c8697b.zip
In the OOM testing logic, add the sqlite3FirstFault() routine as a place to
set a breakpoint the first time any simulated OOM fault occurs for a single test case. FossilOrigin-Name: b4d80bd287ca7f3a6d182ba2435273266035b94fdf6a44047a64a4eff931c571
Diffstat (limited to 'src/test_malloc.c')
-rw-r--r--src/test_malloc.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/test_malloc.c b/src/test_malloc.c
index 33bc3807b..32a03e719 100644
--- a/src/test_malloc.c
+++ b/src/test_malloc.c
@@ -32,6 +32,8 @@ static struct MemFault {
int nRepeat; /* Number of times to repeat the failure */
int nBenign; /* Number of benign failures seen since last config */
int nFail; /* Number of failures seen since last config */
+ int nOkBefore; /* Successful allocations prior to the first fault */
+ int nOkAfter; /* Successful allocations after a fault */
u8 enable; /* True if enabled */
int isInstalled; /* True if the fault simulation layer is installed */
int isBenignMode; /* True if malloc failures are considered benign */
@@ -48,17 +50,31 @@ static void sqlite3Fault(void){
}
/*
+** This routine exists as a place to set a breakpoint that will
+** fire the first time any malloc() fails on a single test case.
+** The sqlite3Fault() routine above runs on every malloc() failure.
+** This routine only runs on the first such failure.
+*/
+static void sqlite3FirstFault(void){
+ static int cnt2 = 0;
+ cnt2++;
+}
+
+/*
** Check to see if a fault should be simulated. Return true to simulate
** the fault. Return false if the fault should not be simulated.
*/
static int faultsimStep(void){
if( likely(!memfault.enable) ){
+ memfault.nOkAfter++;
return 0;
}
if( memfault.iCountdown>0 ){
memfault.iCountdown--;
+ memfault.nOkBefore++;
return 0;
}
+ if( memfault.nFail==0 ) sqlite3FirstFault();
sqlite3Fault();
memfault.nFail++;
if( memfault.isBenignMode>0 ){
@@ -133,6 +149,8 @@ static void faultsimConfig(int nDelay, int nRepeat){
memfault.nRepeat = nRepeat;
memfault.nBenign = 0;
memfault.nFail = 0;
+ memfault.nOkBefore = 0;
+ memfault.nOkAfter = 0;
memfault.enable = nDelay>=0;
/* Sometimes, when running multi-threaded tests, the isBenignMode