aboutsummaryrefslogtreecommitdiff
path: root/src/test_malloc.c
diff options
context:
space:
mode:
authordanielk1977 <danielk1977@noemail.net>2008-06-19 18:17:49 +0000
committerdanielk1977 <danielk1977@noemail.net>2008-06-19 18:17:49 +0000
commitd09414cdd60e8c30eb15e4758b8289efbe4cdedd (patch)
treed86848b8fa02eb4ee3265d6a5d384179585de5f0 /src/test_malloc.c
parent55b0cf00ad16da59d56358e0073627ae03a3ffa5 (diff)
downloadsqlite-d09414cdd60e8c30eb15e4758b8289efbe4cdedd.tar.gz
sqlite-d09414cdd60e8c30eb15e4758b8289efbe4cdedd.zip
Move the malloc() failure simulation out of malloc.c and into a separate sqlite3_mem_methods interface. Still some related changes to come. (CVS 5250)
FossilOrigin-Name: d22cd2a59f472f4eaf80aa9f55fbff2514ca428d
Diffstat (limited to 'src/test_malloc.c')
-rw-r--r--src/test_malloc.c30
1 files changed, 29 insertions, 1 deletions
diff --git a/src/test_malloc.c b/src/test_malloc.c
index 4643f2e55..59a2954f7 100644
--- a/src/test_malloc.c
+++ b/src/test_malloc.c
@@ -13,7 +13,7 @@
** This file contains code used to implement test interfaces to the
** memory allocation subsystem.
**
-** $Id: test_malloc.c,v 1.25 2008/06/19 00:16:08 drh Exp $
+** $Id: test_malloc.c,v 1.26 2008/06/19 18:17:50 danielk1977 Exp $
*/
#include "sqliteInt.h"
#include "tcl.h"
@@ -21,6 +21,8 @@
#include <string.h>
#include <assert.h>
+const char *sqlite3TestErrorName(int);
+
/*
** Transform pointers to text and back again
*/
@@ -781,6 +783,30 @@ static int test_status(
}
/*
+** install_malloc_faultsim BOOLEAN
+*/
+static int test_install_malloc_faultsim(
+ void * clientData,
+ Tcl_Interp *interp,
+ int objc,
+ Tcl_Obj *CONST objv[]
+){
+ int rc;
+ int isInstall;
+
+ if( objc!=2 ){
+ Tcl_WrongNumArgs(interp, 1, objv, "BOOLEAN");
+ return TCL_ERROR;
+ }
+ if( TCL_OK!=Tcl_GetBooleanFromObj(interp, objv[1], &isInstall) ){
+ return TCL_ERROR;
+ }
+ rc = sqlite3_test_control(SQLITE_TESTCTRL_FAULT_INSTALL, isInstall);
+ Tcl_SetResult(interp, (char *)sqlite3TestErrorName(rc), TCL_VOLATILE);
+ return TCL_OK;
+}
+
+/*
** Register commands with the TCL interpreter.
*/
int Sqlitetest_malloc_Init(Tcl_Interp *interp){
@@ -805,6 +831,8 @@ int Sqlitetest_malloc_Init(Tcl_Interp *interp){
{ "sqlite3_config_scratch", test_config_scratch },
{ "sqlite3_config_pagecache", test_config_pagecache },
{ "sqlite3_status", test_status },
+
+ { "install_malloc_faultsim", test_install_malloc_faultsim },
};
int i;
for(i=0; i<sizeof(aObjCmd)/sizeof(aObjCmd[0]); i++){