1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-05 15:55:57 +03:00

Move the test (sqlite3_simulate_device) functionality out of the main code and into a test vfs. (CVS 4737)

FossilOrigin-Name: 17e7bd6c3f507ffc6b56f54ae8c70730e8246f39
This commit is contained in:
danielk1977
2008-01-22 11:50:13 +00:00
parent c4dd3fd280
commit bf2609781b
9 changed files with 385 additions and 58 deletions

View File

@@ -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