Make sure to flag benign malloc failures in the Windows VFS as such. Expand use of the DO_OS_MALLOC_TEST to cover the VFS functions that can now return an out of memory error. Support an experimental --match option to the test suite that will run only those tests matching the specified pattern.
FossilOrigin-Name: 76dec8aa9dbbc39e0a7c3b358b58ce7f7a477a2b
This commit is contained in:
parent
5f075388de
commit
6c3c1a0951
18
manifest
18
manifest
@ -1,5 +1,5 @@
|
||||
C Remove\suse\sof\smalloc\sand\sfree\sfrom\sthe\sWindows\sVFS.\s\sAlso,\sprevent\ssqlite3BtreeOpen\sfrom\sassuming\sthat\ssqlite3OsFullPathname\scannot\sfail.
|
||||
D 2011-11-11T23:31:04.676
|
||||
C Make\ssure\sto\sflag\sbenign\smalloc\sfailures\sin\sthe\sWindows\sVFS\sas\ssuch.\s\sExpand\suse\sof\sthe\sDO_OS_MALLOC_TEST\sto\scover\sthe\sVFS\sfunctions\sthat\scan\snow\sreturn\san\sout\sof\smemory\serror.\s\sSupport\san\sexperimental\s--match\soption\sto\sthe\stest\ssuite\sthat\swill\srun\sonly\sthose\stests\smatching\sthe\sspecified\spattern.
|
||||
D 2011-11-12T03:17:40.954
|
||||
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
|
||||
F Makefile.in 5b4a3e12a850b021547e43daf886b25133b44c07
|
||||
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
|
||||
@ -162,12 +162,12 @@ F src/mutex_os2.c 882d735098c07c8c6a5472b8dd66e19675fe117f
|
||||
F src/mutex_unix.c b4f4e923bb8de93ec3f251fadb50855f23df9579
|
||||
F src/mutex_w32.c 5e54f3ba275bcb5d00248b8c23107df2e2f73e33
|
||||
F src/notify.c 976dd0f6171d4588e89e874fcc765e92914b6d30
|
||||
F src/os.c 5d9b02782ed36345348d6fe21d7762ed3a9cfd2a
|
||||
F src/os.c 28bbdab2170dfce84d86c45456a18eab1d0f99a9
|
||||
F src/os.h 9dbed8c2b9c1f2f2ebabc09e49829d4777c26bf9
|
||||
F src/os_common.h 92815ed65f805560b66166e3583470ff94478f04
|
||||
F src/os_os2.c 4a75888ba3dfc820ad5e8177025972d74d7f2440
|
||||
F src/os_unix.c 4fbb91726165e105c1679a2660f49a3f4c376e4f
|
||||
F src/os_win.c ee8ba0846294f154e0822095512a665cdb197c8a
|
||||
F src/os_win.c a22b88d2c088c09a678a471abafa8d60dbf56803
|
||||
F src/pager.c db33d4bf1e3e019c34c220971cc6c3aa07c30f54
|
||||
F src/pager.h 9f81b08efb06db4ba8be69446e10b005c351373d
|
||||
F src/parse.y 12b7ebd61ea54f0e1b1083ff69cc2c8ce9353d58
|
||||
@ -229,7 +229,7 @@ F src/test_superlock.c 2b97936ca127d13962c3605dbc9a4ef269c424cd
|
||||
F src/test_syscall.c a992d8c80ea91fbf21fb2dd570db40e77dd7e6ae
|
||||
F src/test_tclvar.c f4dc67d5f780707210d6bb0eb6016a431c04c7fa
|
||||
F src/test_thread.c 35022393dd54d147b998b6b7f7e945b01114d666
|
||||
F src/test_vfs.c b0baec983bd6f872715a4b44c8f39104fec333af
|
||||
F src/test_vfs.c 27b7d9de40630f603b9e2cf9ef2a7c81d31c4515
|
||||
F src/test_vfstrace.c 0b884e06094a746da729119a2cabdc7aa790063d
|
||||
F src/test_wholenumber.c 6129adfbe7c7444f2e60cc785927f3aa74e12290
|
||||
F src/test_wsd.c 41cadfd9d97fe8e3e4e44f61a4a8ccd6f7ca8fe9
|
||||
@ -707,7 +707,7 @@ F test/tclsqlite.test 5ebcbb0dccc3fbc1edc3bba84c38e2c2d574c5aa
|
||||
F test/tempdb.test 19d0f66e2e3eeffd68661a11c83ba5e6ace9128c
|
||||
F test/temptable.test 51edd31c65ed1560dd600b1796e8325df96318e2
|
||||
F test/temptrigger.test 26670ed7a39cf2296a7f0a9e0a1d7bdb7abe936d
|
||||
F test/tester.tcl 0b2999b578964297663de4870babbbee29225622
|
||||
F test/tester.tcl 001051eaf28c1040800f588a64c63e0bd0e1f36b
|
||||
F test/thread001.test 7cc2ce08f9cde95964736d11e91f9ab610f82f91
|
||||
F test/thread002.test e630504f8a06c00bf8bbe68528774dd96aeb2e58
|
||||
F test/thread003.test ee4c9efc3b86a6a2767516a37bd64251272560a7
|
||||
@ -974,7 +974,7 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06
|
||||
F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
|
||||
F tool/warnings-clang.sh 9f406d66e750e8ac031c63a9ef3248aaa347ef2a
|
||||
F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381
|
||||
P ed88fb00240de75457c0da19e87c12082622ca17
|
||||
R a35825c17aca6258f92039304b464c67
|
||||
P 8966ec1797be63d1305628d459bdad5be08cf3ca
|
||||
R b05037fbfa7e2180ed81bf446e380e48
|
||||
U mistachkin
|
||||
Z 93813e17596e2d1608777ccc9fc54b6a
|
||||
Z 1660438f613633eeb0e91d69e2a176bd
|
||||
|
@ -1 +1 @@
|
||||
8966ec1797be63d1305628d459bdad5be08cf3ca
|
||||
76dec8aa9dbbc39e0a7c3b358b58ce7f7a477a2b
|
13
src/os.c
13
src/os.c
@ -27,11 +27,18 @@
|
||||
** The following functions are instrumented for malloc() failure
|
||||
** testing:
|
||||
**
|
||||
** sqlite3OsOpen()
|
||||
** sqlite3OsRead()
|
||||
** sqlite3OsWrite()
|
||||
** sqlite3OsSync()
|
||||
** sqlite3OsFileSize()
|
||||
** sqlite3OsLock()
|
||||
** sqlite3OsCheckReservedLock()
|
||||
** sqlite3OsFileControl()
|
||||
** sqlite3OsShmMap()
|
||||
** sqlite3OsOpen()
|
||||
** sqlite3OsDelete()
|
||||
** sqlite3OsAccess()
|
||||
** sqlite3OsFullPathname()
|
||||
**
|
||||
*/
|
||||
#if defined(SQLITE_TEST)
|
||||
@ -91,6 +98,7 @@ int sqlite3OsCheckReservedLock(sqlite3_file *id, int *pResOut){
|
||||
return id->pMethods->xCheckReservedLock(id, pResOut);
|
||||
}
|
||||
int sqlite3OsFileControl(sqlite3_file *id, int op, void *pArg){
|
||||
DO_OS_MALLOC_TEST(id);
|
||||
return id->pMethods->xFileControl(id, op, pArg);
|
||||
}
|
||||
int sqlite3OsSectorSize(sqlite3_file *id){
|
||||
@ -116,6 +124,7 @@ int sqlite3OsShmMap(
|
||||
int bExtend, /* True to extend file if necessary */
|
||||
void volatile **pp /* OUT: Pointer to mapping */
|
||||
){
|
||||
DO_OS_MALLOC_TEST(id);
|
||||
return id->pMethods->xShmMap(id, iPage, pgsz, bExtend, pp);
|
||||
}
|
||||
|
||||
@ -141,6 +150,7 @@ int sqlite3OsOpen(
|
||||
return rc;
|
||||
}
|
||||
int sqlite3OsDelete(sqlite3_vfs *pVfs, const char *zPath, int dirSync){
|
||||
DO_OS_MALLOC_TEST(0);
|
||||
return pVfs->xDelete(pVfs, zPath, dirSync);
|
||||
}
|
||||
int sqlite3OsAccess(
|
||||
@ -158,6 +168,7 @@ int sqlite3OsFullPathname(
|
||||
int nPathOut,
|
||||
char *zPathOut
|
||||
){
|
||||
DO_OS_MALLOC_TEST(0);
|
||||
zPathOut[0] = 0;
|
||||
return pVfs->xFullPathname(pVfs, zPath, nPathOut, zPathOut);
|
||||
}
|
||||
|
36
src/os_win.c
36
src/os_win.c
@ -155,11 +155,11 @@ static int getSectorSize(
|
||||
|
||||
/*
|
||||
** The following variable is (normally) set once and never changes
|
||||
** thereafter. It records whether the operating system is Win95
|
||||
** thereafter. It records whether the operating system is Win9x
|
||||
** or WinNT.
|
||||
**
|
||||
** 0: Operating system unknown.
|
||||
** 1: Operating system is Win95.
|
||||
** 1: Operating system is Win9x.
|
||||
** 2: Operating system is WinNT.
|
||||
**
|
||||
** In order to facilitate testing on a WinNT system, the test fixture
|
||||
@ -954,7 +954,7 @@ static char *unicodeToUtf8(LPCWSTR zWideFilename){
|
||||
}
|
||||
|
||||
/*
|
||||
** Convert an ansi string to Microsoft Unicode, based on the
|
||||
** Convert an ANSI string to Microsoft Unicode, based on the
|
||||
** current codepage settings for file apis.
|
||||
**
|
||||
** Space to hold the returned string is obtained
|
||||
@ -1067,12 +1067,14 @@ static int getLastErrorMsg(DWORD lastErrno, int nBuf, char *zBuf){
|
||||
0);
|
||||
if( dwLen > 0 ){
|
||||
/* allocate a buffer and convert to UTF8 */
|
||||
sqlite3BeginBenignMalloc();
|
||||
zOut = unicodeToUtf8(zTempWide);
|
||||
sqlite3EndBenignMalloc();
|
||||
/* free the system buffer allocated by FormatMessage */
|
||||
osLocalFree(zTempWide);
|
||||
}
|
||||
/* isNT() is 1 if SQLITE_OS_WINCE==1, so this else is never executed.
|
||||
** Since the ASCII version of these Windows API do not exist for WINCE,
|
||||
** Since the ANSI version of these Windows API do not exist for WINCE,
|
||||
** it's important to not reference them for WINCE builds.
|
||||
*/
|
||||
#if SQLITE_OS_WINCE==0
|
||||
@ -1089,7 +1091,9 @@ static int getLastErrorMsg(DWORD lastErrno, int nBuf, char *zBuf){
|
||||
0);
|
||||
if( dwLen > 0 ){
|
||||
/* allocate a buffer and convert to UTF8 */
|
||||
sqlite3BeginBenignMalloc();
|
||||
zOut = sqlite3_win32_mbcs_to_utf8(zTemp);
|
||||
sqlite3EndBenignMalloc();
|
||||
/* free the system buffer allocated by FormatMessage */
|
||||
osLocalFree(zTemp);
|
||||
}
|
||||
@ -1832,7 +1836,7 @@ static int winFileSize(sqlite3_file *id, sqlite3_int64 *pSize){
|
||||
/*
|
||||
** Acquire a reader lock.
|
||||
** Different API routines are called depending on whether or not this
|
||||
** is Win95 or WinNT.
|
||||
** is Win9x or WinNT.
|
||||
*/
|
||||
static int getReadLock(winFile *pFile){
|
||||
int res;
|
||||
@ -2908,7 +2912,7 @@ static int getTempname(int nBuf, char *zBuf){
|
||||
return SQLITE_IOERR_NOMEM;
|
||||
}
|
||||
/* isNT() is 1 if SQLITE_OS_WINCE==1, so this else is never executed.
|
||||
** Since the ASCII version of these Windows API do not exist for WINCE,
|
||||
** Since the ANSI version of these Windows API do not exist for WINCE,
|
||||
** it's important to not reference them for WINCE builds.
|
||||
*/
|
||||
#if SQLITE_OS_WINCE==0
|
||||
@ -3098,7 +3102,7 @@ static int winOpen(
|
||||
NULL))==INVALID_HANDLE_VALUE &&
|
||||
retryIoerr(&cnt) ){}
|
||||
/* isNT() is 1 if SQLITE_OS_WINCE==1, so this else is never executed.
|
||||
** Since the ASCII version of these Windows API do not exist for WINCE,
|
||||
** Since the ANSI version of these Windows API do not exist for WINCE,
|
||||
** it's important to not reference them for WINCE builds.
|
||||
*/
|
||||
#if SQLITE_OS_WINCE==0
|
||||
@ -3202,7 +3206,7 @@ static int winDelete(
|
||||
(rc = osDeleteFileW(zConverted))==0 && retryIoerr(&cnt) ){}
|
||||
rc = rc ? SQLITE_OK : SQLITE_ERROR;
|
||||
/* isNT() is 1 if SQLITE_OS_WINCE==1, so this else is never executed.
|
||||
** Since the ASCII version of these Windows API do not exist for WINCE,
|
||||
** Since the ANSI version of these Windows API do not exist for WINCE,
|
||||
** it's important to not reference them for WINCE builds.
|
||||
*/
|
||||
#if SQLITE_OS_WINCE==0
|
||||
@ -3273,7 +3277,7 @@ static int winAccess(
|
||||
}
|
||||
}
|
||||
/* isNT() is 1 if SQLITE_OS_WINCE==1, so this else is never executed.
|
||||
** Since the ASCII version of these Windows API do not exist for WINCE,
|
||||
** Since the ANSI version of these Windows API do not exist for WINCE,
|
||||
** it's important to not reference them for WINCE builds.
|
||||
*/
|
||||
#if SQLITE_OS_WINCE==0
|
||||
@ -3362,7 +3366,7 @@ static int winFullPathname(
|
||||
zOut = unicodeToUtf8(zTemp);
|
||||
sqlite3_free(zTemp);
|
||||
/* isNT() is 1 if SQLITE_OS_WINCE==1, so this else is never executed.
|
||||
** Since the ASCII version of these Windows API do not exist for WINCE,
|
||||
** Since the ANSI version of these Windows API do not exist for WINCE,
|
||||
** it's important to not reference them for WINCE builds.
|
||||
*/
|
||||
#if SQLITE_OS_WINCE==0
|
||||
@ -3415,11 +3419,16 @@ static int getSectorSize(
|
||||
** size.
|
||||
*/
|
||||
SimulateIOErrorBenign(1);
|
||||
sqlite3BeginBenignMalloc();
|
||||
rc = winFullPathname(pVfs, zRelative, MAX_PATH, zFullpath);
|
||||
sqlite3EndBenignMalloc();
|
||||
SimulateIOErrorBenign(0);
|
||||
if( rc == SQLITE_OK )
|
||||
{
|
||||
void *zConverted = convertUtf8Filename(zFullpath);
|
||||
void *zConverted;
|
||||
sqlite3BeginBenignMalloc();
|
||||
zConverted = convertUtf8Filename(zFullpath);
|
||||
sqlite3EndBenignMalloc();
|
||||
if( zConverted ){
|
||||
if( isNT() ){
|
||||
/* trim path to just drive reference */
|
||||
@ -3479,7 +3488,7 @@ static void *winDlOpen(sqlite3_vfs *pVfs, const char *zFilename){
|
||||
if( isNT() ){
|
||||
h = osLoadLibraryW((LPCWSTR)zConverted);
|
||||
/* isNT() is 1 if SQLITE_OS_WINCE==1, so this else is never executed.
|
||||
** Since the ASCII version of these Windows API do not exist for WINCE,
|
||||
** Since the ANSI version of these Windows API do not exist for WINCE,
|
||||
** it's important to not reference them for WINCE builds.
|
||||
*/
|
||||
#if SQLITE_OS_WINCE==0
|
||||
@ -3662,8 +3671,6 @@ static int winGetLastError(sqlite3_vfs *pVfs, int nBuf, char *zBuf){
|
||||
return getLastErrorMsg(osGetLastError(), nBuf, zBuf);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
** Initialize and deinitialize the operating system interface.
|
||||
*/
|
||||
@ -3707,6 +3714,7 @@ int sqlite3_os_init(void){
|
||||
sqlite3_vfs_register(&winVfs, 1);
|
||||
return SQLITE_OK;
|
||||
}
|
||||
|
||||
int sqlite3_os_end(void){
|
||||
return SQLITE_OK;
|
||||
}
|
||||
|
@ -988,7 +988,7 @@ static int testvfs_obj_cmd(
|
||||
switch( aSubcmd[i].eCmd ){
|
||||
case CMD_SHM: {
|
||||
Tcl_Obj *pObj;
|
||||
int i;
|
||||
int i, rc;
|
||||
TestvfsBuffer *pBuffer;
|
||||
char *zName;
|
||||
if( objc!=3 && objc!=4 ){
|
||||
@ -996,10 +996,16 @@ static int testvfs_obj_cmd(
|
||||
return TCL_ERROR;
|
||||
}
|
||||
zName = ckalloc(p->pParent->mxPathname);
|
||||
p->pParent->xFullPathname(
|
||||
rc = p->pParent->xFullPathname(
|
||||
p->pParent, Tcl_GetString(objv[2]),
|
||||
p->pParent->mxPathname, zName
|
||||
);
|
||||
if( rc!=SQLITE_OK ){
|
||||
Tcl_AppendResult(interp, "failed to get full path: ",
|
||||
Tcl_GetString(objv[2]), 0);
|
||||
ckfree(zName);
|
||||
return TCL_ERROR;
|
||||
}
|
||||
for(pBuffer=p->pBuffer; pBuffer; pBuffer=pBuffer->pNext){
|
||||
if( 0==strcmp(pBuffer->zFile, zName) ) break;
|
||||
}
|
||||
|
@ -57,7 +57,7 @@
|
||||
# Commands providing a lower level interface to the global test counters:
|
||||
#
|
||||
# set_test_counter COUNTER ?VALUE?
|
||||
# omit_test TESTNAME REASON
|
||||
# omit_test TESTNAME REASON ?APPEND?
|
||||
# fail_test TESTNAME
|
||||
# incr_ntest
|
||||
#
|
||||
@ -274,6 +274,7 @@ if {[info exists cmdlinearg]==0} {
|
||||
# --file-retries=N
|
||||
# --file-retry-delay=N
|
||||
# --start=[$permutation:]$testfile
|
||||
# --match=$pattern
|
||||
#
|
||||
set cmdlinearg(soft-heap-limit) 0
|
||||
set cmdlinearg(maxerror) 1000
|
||||
@ -284,6 +285,7 @@ if {[info exists cmdlinearg]==0} {
|
||||
set cmdlinearg(file-retries) 0
|
||||
set cmdlinearg(file-retry-delay) 0
|
||||
set cmdlinearg(start) ""
|
||||
set cmdlinearg(match) ""
|
||||
|
||||
set leftover [list]
|
||||
foreach a $argv {
|
||||
@ -336,6 +338,12 @@ if {[info exists cmdlinearg]==0} {
|
||||
}
|
||||
if {$::G(start:file) == ""} {unset ::G(start:file)}
|
||||
}
|
||||
{^-+match=.+$} {
|
||||
foreach {dummy cmdlinearg(match)} [split $a =] break
|
||||
|
||||
set ::G(match) $cmdlinearg(match)
|
||||
if {$::G(match) == ""} {unset ::G(match)}
|
||||
}
|
||||
default {
|
||||
lappend leftover $a
|
||||
}
|
||||
@ -414,9 +422,11 @@ if {0==[info exists ::SLAVE]} {
|
||||
|
||||
# Record the fact that a sequence of tests were omitted.
|
||||
#
|
||||
proc omit_test {name reason} {
|
||||
proc omit_test {name reason {append 1}} {
|
||||
set omitList [set_test_counter omit_list]
|
||||
if {$append} {
|
||||
lappend omitList [list $name $reason]
|
||||
}
|
||||
set_test_counter omit_list $omitList
|
||||
}
|
||||
|
||||
@ -471,6 +481,8 @@ proc do_test {name cmd expected} {
|
||||
incr_ntest
|
||||
puts -nonewline $name...
|
||||
flush stdout
|
||||
|
||||
if {![info exists ::G(match)] || [string match $::G(match) $name]} {
|
||||
if {[catch {uplevel #0 "$cmd;\n"} result]} {
|
||||
puts "\nError: $result"
|
||||
fail_test $name
|
||||
@ -480,6 +492,10 @@ proc do_test {name cmd expected} {
|
||||
} else {
|
||||
puts " Ok"
|
||||
}
|
||||
} else {
|
||||
puts " Omitted"
|
||||
omit_test $name "pattern mismatch" 0
|
||||
}
|
||||
flush stdout
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user