]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Move the test (sqlite3_simulate_device) functionality out of the main code and into...
authordanielk1977 <danielk1977@noemail.net>
Tue, 22 Jan 2008 11:50:13 +0000 (11:50 +0000)
committerdanielk1977 <danielk1977@noemail.net>
Tue, 22 Jan 2008 11:50:13 +0000 (11:50 +0000)
FossilOrigin-Name: 17e7bd6c3f507ffc6b56f54ae8c70730e8246f39

Makefile.in
main.mk
manifest
manifest.uuid
src/os.c
src/test6.c
src/test_devsym.c [new file with mode: 0644]
test/io.test
test/mallocD.test

index 5efb24a77559b74d2d73ff21254a52cdfedd5c7b..9076de78a3b8181a9006a75f1bee8832899f6214 100644 (file)
@@ -244,6 +244,7 @@ TESTSRC = \
   $(TOP)/src/test_async.c \
   $(TOP)/src/test_btree.c \
   $(TOP)/src/test_config.c \
+  $(TOP)/src/test_devsym.c \
   $(TOP)/src/test_hexio.c \
   $(TOP)/src/test_malloc.c \
   $(TOP)/src/test_md5.c \
diff --git a/main.mk b/main.mk
index b4825a372f794fb7d2bfd2aeec0080cd626d0646..db0807d7f9bd41319f2dc557a55e663b2b092ead 100644 (file)
--- a/main.mk
+++ b/main.mk
@@ -212,6 +212,7 @@ TESTSRC = \
   $(TOP)/src/test_async.c \
   $(TOP)/src/test_btree.c \
   $(TOP)/src/test_config.c \
+  $(TOP)/src/test_devsym.c \
   $(TOP)/src/test_hexio.c \
   $(TOP)/src/test_malloc.c \
   $(TOP)/src/test_md5.c \
index 474bc51a7ee99354369c1129edc3819ffdddb405..9a673c55b7077c6a3952c863f91ff5de10d2d2d8 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,7 +1,7 @@
-C Changes\sto\slemon\sto\sgenerate\sadditional\scomments\sin\sthe\soutput\sfile\sand\nto\sremove\sunreachable\scode.\s\sAdditional\stest\scases\sfor\simproved\stest\ncoverage.\s(CVS\s4736)
-D 2008-01-22T01:48:06
+C Move\sthe\stest\s(sqlite3_simulate_device)\sfunctionality\sout\sof\sthe\smain\scode\sand\sinto\sa\stest\svfs.\s(CVS\s4737)
+D 2008-01-22T11:50:13
 F Makefile.arm-wince-mingw32ce-gcc ac5f7b2cef0cd850d6f755ba6ee4ab961b1fadf7
-F Makefile.in 30789bf70614bad659351660d76b8e533f3340e9
+F Makefile.in 936bcacced594b24b8fdcfc0fc0efc00e15de8a8
 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
 F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028
 F VERSION 6055d543dbd832b5c0209d6cc787413c1814efdc
@@ -64,7 +64,7 @@ F ext/icu/README.txt 3b130aa66e7a681136f6add198b076a2f90d1e33
 F ext/icu/icu.c 12e763d288d23b5a49de37caa30737b971a2f1e2
 F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895
 F ltmain.sh 56abb507100ed2d4261f6dd1653dec3cf4066387
-F main.mk 5ffa15b4f43f4e9720f216b6d8fc7cb96e6e4411
+F main.mk b49a8c68baf8c17f72bb1ac78ef183b62f6e3f97
 F mkdll.sh 5f8438dcac98e795d7df6529159a1ec566de0183
 F mkextu.sh 416f9b7089d80e5590a29692c9d9280a10dbad9f
 F mkextw.sh 1a866b53637dab137191341cc875575a5ca110fb
@@ -113,7 +113,7 @@ F src/mutex.h 079fa6fe9da18ceb89e79012c010594c6672addb
 F src/mutex_os2.c 4058d04e81a6c1e240020d299a3192d92352c7ef
 F src/mutex_unix.c a6e111947a3cdaa2cda394ed060d7f496fcb4af8
 F src/mutex_w32.c 6e197765f283815496193e78e9548b5d0e53b68e
-F src/os.c 8360932f1450b2b45edb608a3b184b031f7d00cc
+F src/os.c 32251c046e86772cedd56a18a2ff317bf493fa53
 F src/os.h d04706d54a072c7a30ab9e346ad916ef28c842d5
 F src/os_common.h 98862f120ca6bf7a48ce8b16f158b77d00bc9d2f
 F src/os_os2.c 4aca68faa5fe20e41e1b123a46087ebd9e0bb170
@@ -145,7 +145,7 @@ F src/test2.c 77b34303883b9d722c65a6879bb0163a400e3789
 F src/test3.c 6b49ddb0946907a07210998810807ace51be00a5
 F src/test4.c c2c0f5dc907f1346f5d4b65eb5799f11eb9e4071
 F src/test5.c 3a6a5717a149d7ca2e6d14f5be72cf7555d54dc4
-F src/test6.c 8944b6482be3a54505c4f14339392448e4cabe66
+F src/test6.c f8b34a6ff04937092327798ddf0ab46863535bc5
 F src/test7.c acec2256c7c2d279db5a8b5fa1a2a68fcc942c67
 F src/test8.c 6399d2f0561f1f65785c63e94f2cdd36fb248872
 F src/test9.c b46c8fe02ac7cca1a7316436d8d38d50c66f4b2f
@@ -153,6 +153,7 @@ F src/test_async.c 5f21392d66869a4c87dc9153e40d0dc0e085261f
 F src/test_autoext.c 855157d97aa28cf84233847548bfacda21807436
 F src/test_btree.c c1308ba0b88ab577fa56c9e493a09829dfcded9c
 F src/test_config.c fd6ba4c62dd943e794f00f6ea1e9e32d97bf27f1
+F src/test_devsym.c 6341971bf1c7769c740501b36bc6192cd975c335
 F src/test_hexio.c 1a1cd8324d57585ea86b922f609fa1fbaaf9662d
 F src/test_loadext.c 22065d601a18878e5542191001f0eaa5d77c0ed8
 F src/test_malloc.c 72ceed192f7b229db34a2869ff9285b41a5cb796
@@ -342,7 +343,7 @@ F test/insert4.test 6e382eaf7295a4463e6f29ea20fcd8e63d097eeb
 F test/insert5.test 509017213328147d3acdfa2c441bfd82362dda41
 F test/interrupt.test 42e7cf98646fd9cb4a3b131a93ed3c50b9e149f1
 F test/intpkey.test 537669fd535f62632ca64828e435b9e54e8d677f
-F test/io.test 80a7a7f1a2792e037d447b03e8c22ee1f6eaf339
+F test/io.test f2e9890eb3f159973fcb11008054596b0caeca4f
 F test/ioerr.test 5382046b2ef19b9084652e7d2d1e82ab33c0deda
 F test/ioerr2.test e3d52c40f43f9b61da9b38951a737e7b84ebae96
 F test/ioerr3.test d3cec5e1a11ad6d27527d0d38573fbff14c71bdd
@@ -376,7 +377,7 @@ F test/mallocA.test 5ee8d42ff90e5b1aeee6fb645e73ffcb35bffd21
 F test/mallocAll.test 2a2222a5e447be6c6579055a9a26e507e4586f4e
 F test/mallocB.test 82ecf4d3fa6c389cabc747daa2deddfe94af2a74
 F test/mallocC.test 9daac0aa8e5b0afa7b0a3fb0cd792f02fe0cc838
-F test/mallocD.test d638fb8f214b47fd31edfae8af738b92bd943dc0
+F test/mallocD.test 24c1d07a00e605831d0d627b036bd690b2952416
 F test/mallocE.test e15333c394d7c330c8372a7cdf7b0f7c16573082
 F test/mallocF.test 6f25bc474f2b29954e5fac274d0e6ed9d86efea5
 F test/mallocG.test ac896f96098a30ed0dcc001b6f9243770a463081
@@ -610,7 +611,7 @@ F www/tclsqlite.tcl 8be95ee6dba05eabcd27a9d91331c803f2ce2130
 F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
 F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b
 F www/whentouse.tcl fc46eae081251c3c181bd79c5faef8195d7991a5
-P 51452d20f99ecbe0fdb73cfafde5270711aeacad
-R 9db7de996b03087357a154a15493b9be
-U drh
-Z 821a8fe0db1ecdef250b265a178867b8
+P 2a0bc1e186532a0bfe36ca18fda74a5e7a199227
+R 8aeac68813d7cfbc6958a810d0c1e1d8
+U danielk1977
+Z 298f0f8d954eedc2b3f36fd2e741cf3e
index 33bc45eb5f780ea01292d7a2072d60ef826139f8..661b50ad1d81aaa8dade0cc7399e6fab18779984 100644 (file)
@@ -1 +1 @@
-2a0bc1e186532a0bfe36ca18fda74a5e7a199227
\ No newline at end of file
+17e7bd6c3f507ffc6b56f54ae8c70730e8246f39
\ No newline at end of file
index f9291652ba14b78c66028fd323977a17fb7107a9..71284cd90426135a5c7b322fd289f14b8c2784de 100644 (file)
--- a/src/os.c
+++ b/src/os.c
@@ -89,35 +89,13 @@ int sqlite3OsCheckReservedLock(sqlite3_file *id){
 int sqlite3OsFileControl(sqlite3_file *id, int op, void *pArg){
   return id->pMethods->xFileControl(id,op,pArg);
 }
-
-#ifdef SQLITE_TEST
-  /* The following two variables are used to override the values returned
-  ** by the xSectorSize() and xDeviceCharacteristics() vfs methods for
-  ** testing purposes. They are usually set by a test command implemented
-  ** in test6.c.
-  */
-  int sqlite3_test_sector_size = 0;
-  int sqlite3_test_device_characteristics = 0;
-  int sqlite3OsDeviceCharacteristics(sqlite3_file *id){
-    int dc = id->pMethods->xDeviceCharacteristics(id);
-    return dc | sqlite3_test_device_characteristics;
-  }
-  int sqlite3OsSectorSize(sqlite3_file *id){
-    if( sqlite3_test_sector_size==0 ){
-      int (*xSectorSize)(sqlite3_file*) = id->pMethods->xSectorSize;
-      return (xSectorSize ? xSectorSize(id) : SQLITE_DEFAULT_SECTOR_SIZE);
-    }
-    return sqlite3_test_sector_size;
-  }
-#else
-  int sqlite3OsSectorSize(sqlite3_file *id){
-    int (*xSectorSize)(sqlite3_file*) = id->pMethods->xSectorSize;
-    return (xSectorSize ? xSectorSize(id) : SQLITE_DEFAULT_SECTOR_SIZE);
-  }
-  int sqlite3OsDeviceCharacteristics(sqlite3_file *id){
-    return id->pMethods->xDeviceCharacteristics(id);
-  }
-#endif
+int sqlite3OsSectorSize(sqlite3_file *id){
+  int (*xSectorSize)(sqlite3_file*) = id->pMethods->xSectorSize;
+  return (xSectorSize ? xSectorSize(id) : SQLITE_DEFAULT_SECTOR_SIZE);
+}
+int sqlite3OsDeviceCharacteristics(sqlite3_file *id){
+  return id->pMethods->xDeviceCharacteristics(id);
+}
 
 /*
 ** The next group of routines are convenience wrappers around the
index 2e8c4f69ddf82a6c341f9e94995f3efd4d305251..9330a1ddcbacaa8c3d383895a2ed45bbe6515297 100644 (file)
@@ -849,22 +849,15 @@ static int devSymObjCmd(
   int objc,
   Tcl_Obj *CONST objv[]
 ){
-
-  extern int sqlite3_test_device_characteristics;
-  extern int sqlite3_test_sector_size;
+  void devsym_register(int iDeviceChar, int iSectorSize);
 
   int iDc = -1;
   int iSectorSize = -1;
+
   if( processDevSymArgs(interp, objc-1, &objv[1], &iDc, &iSectorSize) ){
     return TCL_ERROR;
   }
-
-  if( iDc>=0 ){
-    sqlite3_test_device_characteristics = iDc;
-  }
-  if( iSectorSize>=0 ){
-    sqlite3_test_sector_size = iSectorSize;
-  }
+  devsym_register(iDc, iSectorSize);
 
   return TCL_OK;
 }
diff --git a/src/test_devsym.c b/src/test_devsym.c
new file mode 100644 (file)
index 0000000..588f5d2
--- /dev/null
@@ -0,0 +1,347 @@
+/*
+** 2008 Jan 22
+**
+** The author disclaims copyright to this source code.  In place of
+** a legal notice, here is a blessing:
+**
+**    May you do good and not evil.
+**    May you find forgiveness for yourself and forgive others.
+**    May you share freely, never taking more than you give.
+**
+******************************************************************************
+**
+** This file contains code that modified the OS layer in order to simulate
+** different device types (by overriding the return values of the 
+** xDeviceCharacteristics() and xSectorSize() methods).
+*/
+#if SQLITE_TEST          /* This file is used for testing only */
+
+#include <sqlite3.h>
+#include "sqliteInt.h"
+
+/*
+** Maximum pathname length supported by the devsym backend.
+*/
+#define DEVSYM_MAX_PATHNAME 512
+
+/*
+** Name used to identify this VFS.
+*/
+#define DEVSYM_VFS_NAME "devsym"
+
+typedef struct devsym_file devsym_file;
+struct devsym_file {
+  sqlite3_file base;
+  sqlite3_file *pReal;
+};
+
+/*
+** Method declarations for devsym_file.
+*/
+static int devsymClose(sqlite3_file*);
+static int devsymRead(sqlite3_file*, void*, int iAmt, sqlite3_int64 iOfst);
+static int devsymWrite(sqlite3_file*,const void*,int iAmt, sqlite3_int64 iOfst);
+static int devsymTruncate(sqlite3_file*, sqlite3_int64 size);
+static int devsymSync(sqlite3_file*, int flags);
+static int devsymFileSize(sqlite3_file*, sqlite3_int64 *pSize);
+static int devsymLock(sqlite3_file*, int);
+static int devsymUnlock(sqlite3_file*, int);
+static int devsymCheckReservedLock(sqlite3_file*);
+static int devsymFileControl(sqlite3_file*, int op, void *pArg);
+static int devsymSectorSize(sqlite3_file*);
+static int devsymDeviceCharacteristics(sqlite3_file*);
+
+/*
+** Method declarations for devsym_vfs.
+*/
+static int devsymOpen(sqlite3_vfs*, const char *, sqlite3_file*, int , int *);
+static int devsymDelete(sqlite3_vfs*, const char *zName, int syncDir);
+static int devsymAccess(sqlite3_vfs*, const char *zName, int flags);
+static int devsymGetTempName(sqlite3_vfs*, int nOut, char *zOut);
+static int devsymFullPathname(sqlite3_vfs*, const char *zName, int, char *zOut);
+static void *devsymDlOpen(sqlite3_vfs*, const char *zFilename);
+static void devsymDlError(sqlite3_vfs*, int nByte, char *zErrMsg);
+static void *devsymDlSym(sqlite3_vfs*,void*, const char *zSymbol);
+static void devsymDlClose(sqlite3_vfs*, void*);
+static int devsymRandomness(sqlite3_vfs*, int nByte, char *zOut);
+static int devsymSleep(sqlite3_vfs*, int microseconds);
+static int devsymCurrentTime(sqlite3_vfs*, double*);
+
+static sqlite3_vfs devsym_vfs = {
+  1,                     /* iVersion */
+  sizeof(devsym_file),      /* szOsFile */
+  DEVSYM_MAX_PATHNAME,      /* mxPathname */
+  0,                     /* pNext */
+  DEVSYM_VFS_NAME,          /* zName */
+  0,                     /* pAppData */
+  devsymOpen,               /* xOpen */
+  devsymDelete,             /* xDelete */
+  devsymAccess,             /* xAccess */
+  devsymGetTempName,        /* xGetTempName */
+  devsymFullPathname,       /* xFullPathname */
+  devsymDlOpen,             /* xDlOpen */
+  devsymDlError,            /* xDlError */
+  devsymDlSym,              /* xDlSym */
+  devsymDlClose,            /* xDlClose */
+  devsymRandomness,         /* xRandomness */
+  devsymSleep,              /* xSleep */
+  devsymCurrentTime         /* xCurrentTime */
+};
+
+static sqlite3_io_methods devsym_io_methods = {
+  1,                            /* iVersion */
+  devsymClose,                      /* xClose */
+  devsymRead,                       /* xRead */
+  devsymWrite,                      /* xWrite */
+  devsymTruncate,                   /* xTruncate */
+  devsymSync,                       /* xSync */
+  devsymFileSize,                   /* xFileSize */
+  devsymLock,                       /* xLock */
+  devsymUnlock,                     /* xUnlock */
+  devsymCheckReservedLock,          /* xCheckReservedLock */
+  devsymFileControl,                /* xFileControl */
+  devsymSectorSize,                 /* xSectorSize */
+  devsymDeviceCharacteristics       /* xDeviceCharacteristics */
+};
+
+struct DevsymGlobal {
+  sqlite3_vfs *pVfs;
+  int iDeviceChar;
+  int iSectorSize;
+};
+struct DevsymGlobal g = {0, 0, 512};
+
+/*
+** Close an devsym-file.
+*/
+static int devsymClose(sqlite3_file *pFile){
+  devsym_file *p = (devsym_file *)pFile;
+  return sqlite3OsClose(p->pReal);
+}
+
+/*
+** Read data from an devsym-file.
+*/
+static int devsymRead(
+  sqlite3_file *pFile, 
+  void *zBuf, 
+  int iAmt, 
+  sqlite_int64 iOfst
+){
+  devsym_file *p = (devsym_file *)pFile;
+  return sqlite3OsRead(p->pReal, zBuf, iAmt, iOfst);
+}
+
+/*
+** Write data to an devsym-file.
+*/
+static int devsymWrite(
+  sqlite3_file *pFile, 
+  const void *zBuf, 
+  int iAmt, 
+  sqlite_int64 iOfst
+){
+  devsym_file *p = (devsym_file *)pFile;
+  return sqlite3OsWrite(p->pReal, zBuf, iAmt, iOfst);
+}
+
+/*
+** Truncate an devsym-file.
+*/
+static int devsymTruncate(sqlite3_file *pFile, sqlite_int64 size){
+  devsym_file *p = (devsym_file *)pFile;
+  return sqlite3OsTruncate(p->pReal, size);
+}
+
+/*
+** Sync an devsym-file.
+*/
+static int devsymSync(sqlite3_file *pFile, int flags){
+  devsym_file *p = (devsym_file *)pFile;
+  return sqlite3OsSync(p->pReal, flags);
+}
+
+/*
+** Return the current file-size of an devsym-file.
+*/
+static int devsymFileSize(sqlite3_file *pFile, sqlite_int64 *pSize){
+  devsym_file *p = (devsym_file *)pFile;
+  return sqlite3OsFileSize(p->pReal, pSize);
+}
+
+/*
+** Lock an devsym-file.
+*/
+static int devsymLock(sqlite3_file *pFile, int eLock){
+  devsym_file *p = (devsym_file *)pFile;
+  return sqlite3OsLock(p->pReal, eLock);
+}
+
+/*
+** Unlock an devsym-file.
+*/
+static int devsymUnlock(sqlite3_file *pFile, int eLock){
+  devsym_file *p = (devsym_file *)pFile;
+  return sqlite3OsUnlock(p->pReal, eLock);
+}
+
+/*
+** Check if another file-handle holds a RESERVED lock on an devsym-file.
+*/
+static int devsymCheckReservedLock(sqlite3_file *pFile){
+  devsym_file *p = (devsym_file *)pFile;
+  return sqlite3OsCheckReservedLock(p->pReal);
+}
+
+/*
+** File control method. For custom operations on an devsym-file.
+*/
+static int devsymFileControl(sqlite3_file *pFile, int op, void *pArg){
+  devsym_file *p = (devsym_file *)pFile;
+  return sqlite3OsFileControl(p->pReal, op, pArg);
+}
+
+/*
+** Return the sector-size in bytes for an devsym-file.
+*/
+static int devsymSectorSize(sqlite3_file *pFile){
+  return g.iSectorSize;
+}
+
+/*
+** Return the device characteristic flags supported by an devsym-file.
+*/
+static int devsymDeviceCharacteristics(sqlite3_file *pFile){
+  return g.iDeviceChar;
+}
+
+/*
+** Open an devsym file handle.
+*/
+static int devsymOpen(
+  sqlite3_vfs *pVfs,
+  const char *zName,
+  sqlite3_file *pFile,
+  int flags,
+  int *pOutFlags
+){
+  devsym_file *p = (devsym_file *)pFile;
+  pFile->pMethods = &devsym_io_methods;
+  p->pReal = (sqlite3_file *)&p[1];
+  return sqlite3OsOpen(g.pVfs, zName, p->pReal, flags, pOutFlags);
+}
+
+/*
+** Delete the file located at zPath. If the dirSync argument is true,
+** ensure the file-system modifications are synced to disk before
+** returning.
+*/
+static int devsymDelete(sqlite3_vfs *pVfs, const char *zPath, int dirSync){
+  return sqlite3OsDelete(g.pVfs, zPath, dirSync);
+}
+
+/*
+** Test for access permissions. Return true if the requested permission
+** is available, or false otherwise.
+*/
+static int devsymAccess(sqlite3_vfs *pVfs, const char *zPath, int flags){
+  return sqlite3OsAccess(g.pVfs, zPath, flags);
+}
+
+/*
+** Populate buffer zBufOut with a pathname suitable for use as a 
+** temporary file. zBufOut is guaranteed to point to a buffer of 
+** at least (DEVSYM_MAX_PATHNAME+1) bytes.
+*/
+static int devsymGetTempName(sqlite3_vfs *pVfs, int nOut, char *zBufOut){
+  return sqlite3OsGetTempname(g.pVfs, nOut, zBufOut);
+}
+
+/*
+** Populate buffer zOut with the full canonical pathname corresponding
+** to the pathname in zPath. zOut is guaranteed to point to a buffer
+** of at least (DEVSYM_MAX_PATHNAME+1) bytes.
+*/
+static int devsymFullPathname(
+  sqlite3_vfs *pVfs, 
+  const char *zPath, 
+  int nOut, 
+  char *zOut
+){
+  return sqlite3OsFullPathname(g.pVfs, zPath, nOut, zOut);
+}
+
+/*
+** Open the dynamic library located at zPath and return a handle.
+*/
+static void *devsymDlOpen(sqlite3_vfs *pVfs, const char *zPath){
+  return sqlite3OsDlOpen(g.pVfs, zPath);
+}
+
+/*
+** Populate the buffer zErrMsg (size nByte bytes) with a human readable
+** utf-8 string describing the most recent error encountered associated 
+** with dynamic libraries.
+*/
+static void devsymDlError(sqlite3_vfs *pVfs, int nByte, char *zErrMsg){
+  sqlite3OsDlError(g.pVfs, nByte, zErrMsg);
+}
+
+/*
+** Return a pointer to the symbol zSymbol in the dynamic library pHandle.
+*/
+static void *devsymDlSym(sqlite3_vfs *pVfs, void *pHandle, const char *zSymbol){
+  return sqlite3OsDlSym(g.pVfs, pHandle, zSymbol);
+}
+
+/*
+** Close the dynamic library handle pHandle.
+*/
+static void devsymDlClose(sqlite3_vfs *pVfs, void *pHandle){
+  sqlite3OsDlClose(g.pVfs, pHandle);
+}
+
+/*
+** Populate the buffer pointed to by zBufOut with nByte bytes of 
+** random data.
+*/
+static int devsymRandomness(sqlite3_vfs *pVfs, int nByte, char *zBufOut){
+  return sqlite3OsRandomness(g.pVfs, nByte, zBufOut);
+}
+
+/*
+** Sleep for nMicro microseconds. Return the number of microseconds 
+** actually slept.
+*/
+static int devsymSleep(sqlite3_vfs *pVfs, int nMicro){
+  return sqlite3OsSleep(g.pVfs, nMicro);
+}
+
+/*
+** Return the current time as a Julian Day number in *pTimeOut.
+*/
+static int devsymCurrentTime(sqlite3_vfs *pVfs, double *pTimeOut){
+  return sqlite3OsCurrentTime(g.pVfs, pTimeOut);
+}
+
+/*
+** This procedure registers the devsym vfs with SQLite. If the argument is
+** true, the devsym vfs becomes the new default vfs. It is the only publicly
+** available function in this file.
+*/
+void devsym_register(int iDeviceChar, int iSectorSize){
+  if( g.pVfs==0 ){
+    g.pVfs = sqlite3_vfs_find(0);
+    devsym_vfs.szOsFile += g.pVfs->szOsFile;
+    sqlite3_vfs_register(&devsym_vfs, 0);
+  }
+  if( iDeviceChar>=0 ){
+    g.iDeviceChar = iDeviceChar;
+  }
+  if( iSectorSize>=0 ){
+    g.iSectorSize = iSectorSize;
+  }
+}
+
+#endif
+
index 297ccf9bfc26d041e8a40288233e235068f66e5e..70d0a96511eb34b30725e5ac294a0ed7b8400fc7 100644 (file)
 # IO traffic generated by SQLite (making sure SQLite is not writing out
 # more database pages than it has to, stuff like that).
 #
-# $Id: io.test,v 1.13 2007/11/27 23:11:45 drh Exp $
+# $Id: io.test,v 1.14 2008/01/22 11:50:13 danielk1977 Exp $
 
 set testdir [file dirname $argv0]
 source $testdir/tester.tcl
 
+db close
+sqlite3_simulate_device
+sqlite3 db test.db -vfs devsym
+
 # Test summary:
 #
 # io-1.* -  Test that quick-balance does not journal pages unnecessarily.
@@ -157,7 +161,7 @@ do_test io-2.4.1 {
     BEGIN;
     INSERT INTO abc VALUES(5, 6);
   }
-  sqlite3 db2 test.db
+  sqlite3 db2 test.db -vfs devsym
   execsql { SELECT * FROM abc } db2
 } {1 2 3 4}
 do_test io-2.4.2 {
@@ -296,7 +300,7 @@ do_test io-2.9.2 {
   execsql { ROLLBACK; }
   db close
   file delete -force test.db test.db-journal
-  sqlite3 db test.db
+  sqlite3 db test.db -vfs devsym
   execsql {
     PRAGMA auto_vacuum = OFF;
     PRAGMA page_size = 2048;
@@ -369,7 +373,7 @@ ifcapable pager_pragmas {
   do_test io-3.1 {
     db close
     file delete -force test.db test.db-journal
-    sqlite3 db test.db
+    sqlite3 db test.db -vfs devsym
     db eval {
       PRAGMA auto_vacuum=OFF;
     }
@@ -526,7 +530,7 @@ foreach {char                 sectorsize pgsize} {
   db close
   file delete -force test.db test.db-journal
   sqlite3_simulate_device -char $char -sectorsize $sectorsize
-  sqlite3 db test.db
+  sqlite3 db test.db -vfs devsym
   db eval {
     PRAGMA auto_vacuum=OFF;
   }
index 074224b2e4c7f9b3a2295787b56e71774b4ae256..bd44449d2bd57f9e46403065dc10511f23787232 100644 (file)
@@ -9,7 +9,7 @@
 #
 #***********************************************************************
 #
-# $Id: mallocD.test,v 1.4 2007/10/09 08:29:33 danielk1977 Exp $
+# $Id: mallocD.test,v 1.5 2008/01/22 11:50:13 danielk1977 Exp $
 
 set testdir [file dirname $argv0]
 source $testdir/tester.tcl
@@ -23,7 +23,9 @@ ifcapable !memdebug {
 }
 source $testdir/malloc_common.tcl
 
+db close
 sqlite3_simulate_device -char atomic
+sqlite3 db test.db -vfs devsym
 
 set PREP { 
   PRAGMA page_size = 1024;