1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-07 02:42:48 +03:00

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
This commit is contained in:
danielk1977
2008-06-19 18:17:49 +00:00
parent 55b0cf00ad
commit d09414cdd6
11 changed files with 208 additions and 105 deletions

View File

@@ -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
*/
@@ -780,6 +782,30 @@ static int test_status(
return TCL_OK;
}
/*
** 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.
*/
@@ -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++){