aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main.c2
-rw-r--r--src/os.c11
-rw-r--r--src/os.h5
-rw-r--r--src/os_unix.c7
-rw-r--r--src/os_win.c7
-rw-r--r--src/test_init.c11
6 files changed, 17 insertions, 26 deletions
diff --git a/src/main.c b/src/main.c
index fe26386a0..54eae54a7 100644
--- a/src/main.c
+++ b/src/main.c
@@ -167,7 +167,7 @@ int sqlite3_initialize(void){
}
if( rc==SQLITE_OK ){
sqlite3GlobalConfig.isPCacheInit = 1;
- rc = sqlite3_os_init();
+ rc = sqlite3OsInit();
}
if( rc==SQLITE_OK ){
sqlite3PCacheBufferSetup( sqlite3GlobalConfig.pPage,
diff --git a/src/os.c b/src/os.c
index a2b0325c6..4adf12396 100644
--- a/src/os.c
+++ b/src/os.c
@@ -191,6 +191,17 @@ int sqlite3OsCloseFree(sqlite3_file *pFile){
}
/*
+** This function is a wrapper around the OS specific implementation of
+** sqlite3_os_init(). The purpose of the wrapper is to provide the
+** ability to simulate a malloc failure, so that the handling of an
+** error in sqlite3_os_init() by the upper layers can be tested.
+*/
+int sqlite3OsInit(void){
+ DO_OS_MALLOC_TEST(0);
+ return sqlite3_os_init();
+}
+
+/*
** The list of all registered VFS implementations.
*/
static sqlite3_vfs * SQLITE_WSD vfsList = 0;
diff --git a/src/os.h b/src/os.h
index d483f3f52..7bc848f12 100644
--- a/src/os.h
+++ b/src/os.h
@@ -224,6 +224,11 @@
#define SHARED_FIRST (PENDING_BYTE+2)
#define SHARED_SIZE 510
+/*
+** Wrapper around OS specific sqlite3_os_init() function.
+*/
+int sqlite3OsInit(void);
+
/*
** Functions for accessing sqlite3_file methods
*/
diff --git a/src/os_unix.c b/src/os_unix.c
index 00bbb538c..cfaf2a2bd 100644
--- a/src/os_unix.c
+++ b/src/os_unix.c
@@ -5126,13 +5126,6 @@ int sqlite3_os_init(void){
};
unsigned int i; /* Loop counter */
-#ifdef SQLITE_TEST
- /* This block is used by test code only to simulate the effect on sqlite
- ** of returning an error from within the sqlite3_os_init() function. */
- int sqlite3TestFailOsInit(void);
- if( sqlite3TestFailOsInit() ){ return SQLITE_ERROR; }
-#endif
-
/* Register all VFSes defined in the aVfs[] array */
for(i=0; i<(sizeof(aVfs)/sizeof(sqlite3_vfs)); i++){
sqlite3_vfs_register(&aVfs[i], i==0);
diff --git a/src/os_win.c b/src/os_win.c
index 220b123c8..5d8463728 100644
--- a/src/os_win.c
+++ b/src/os_win.c
@@ -1883,13 +1883,6 @@ int sqlite3_os_init(void){
winGetLastError /* xGetLastError */
};
-#ifdef SQLITE_TEST
- /* This block is used by test code only to simulate the effect on sqlite
- ** of returning an error from within the sqlite3_os_init() function. */
- int sqlite3TestFailOsInit(void);
- if( sqlite3TestFailOsInit() ){ return SQLITE_ERROR; }
-#endif
-
sqlite3_vfs_register(&winVfs, 1);
return SQLITE_OK;
}
diff --git a/src/test_init.c b/src/test_init.c
index a8b8ce0d5..c5be6376b 100644
--- a/src/test_init.c
+++ b/src/test_init.c
@@ -40,7 +40,6 @@ static struct Wrapped {
int mutex_fail; /* True to fail mutex subsystem inialization */
int pcache_init; /* True if pcache subsystem is initalized */
int pcache_fail; /* True to fail pcache subsystem inialization */
- int osinit_fail; /* True to fail OS subsystem inialization */
} wrapped;
static int wrMemInit(void *pAppData){
@@ -196,8 +195,6 @@ static int init_wrapper_install(
wrapped.mutex_fail = 1;
}else if( strcmp(z, "pcache")==0 ){
wrapped.pcache_fail = 1;
- }else if( strcmp(z, "os")==0 ){
- wrapped.osinit_fail = 1;
}else{
Tcl_AppendResult(interp, "Unknown argument: \"", z, "\"");
return TCL_ERROR;
@@ -239,7 +236,6 @@ static int init_wrapper_clear(
wrapped.mem_fail = 0;
wrapped.mutex_fail = 0;
wrapped.pcache_fail = 0;
- wrapped.osinit_fail = 0;
return TCL_OK;
}
@@ -266,18 +262,11 @@ static int init_wrapper_query(
if( wrapped.pcache_init ){
Tcl_ListObjAppendElement(interp, pRet, Tcl_NewStringObj("pcache", -1));
}
- if( sqlite3GlobalConfig.isInit ){
- Tcl_ListObjAppendElement(interp, pRet, Tcl_NewStringObj("os", -1));
- }
Tcl_SetObjResult(interp, pRet);
return TCL_OK;
}
-int sqlite3TestFailOsInit(void){
- return (wrapped.mem.xMalloc && wrapped.osinit_fail);
-}
-
int Sqlitetest_init_Init(Tcl_Interp *interp){
static struct {
char *zName;