From d6846d75ca8a1b3a8d2ad83e347f919ccd1a92c7 Mon Sep 17 00:00:00 2001 From: danielk1977 Date: Wed, 11 Feb 2009 14:27:04 +0000 Subject: [PATCH] Fix the crashtest infrastructure so that it doesn't trigger the "don't write to the locking region" assert in os_unix.c. (CVS 6281) FossilOrigin-Name: b7fd4615cd41179484bd44d2f4bd7aef04977911 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/test6.c | 28 +++++++++++++++++++++++----- 3 files changed, 30 insertions(+), 12 deletions(-) diff --git a/manifest b/manifest index 6a1e047aa1..01500e0506 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Modify\sthe\stest_journal.c\scode\sto\s(1)\saccount\sfor\sthe\sbackup\scode\swriting\sto\sparts\sof\sthe\spending-byte\spage\swhen\schanging\sa\sdatabases\spage-size,\sand\s(2)\sto\savoid\sreading\sfrom\sthe\spending-byte\spage\sand\striggering\sthe\sassert\sin\sos_unix.c.\sChanges\sto\stest\scode\sonly.\s(CVS\s6280) -D 2009-02-11T07:38:12 +C Fix\sthe\scrashtest\sinfrastructure\sso\sthat\sit\sdoesn't\strigger\sthe\s"don't\swrite\sto\sthe\slocking\sregion"\sassert\sin\sos_unix.c.\s(CVS\s6281) +D 2009-02-11T14:27:04 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0 F Makefile.in c7a5a30fb6852bd7839b1024e1661da8549878ee F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654 @@ -169,7 +169,7 @@ F src/test2.c 71c22e2974f8094fe0fd1eba8f27872dde9b2a39 F src/test3.c 88a246b56b824275300e6c899634fbac1dc94b14 F src/test4.c f79ab52d27ff49b784b631a42e2ccd52cfd5c84c F src/test5.c 162a1cea2105a2c460a3f39fa6919617b562a288 -F src/test6.c 86d7918ccc2ff92ceb71cb59c6a078105f8885d2 +F src/test6.c 1a0a7a1f179469044b065b4a88aab9faee114101 F src/test7.c b94e68c2236de76889d82b8d7d8e00ad6a4d80b1 F src/test8.c 3637439424d0d21ff2dcf9b015c30fcc1e7bcb24 F src/test9.c 904ebe0ed1472d6bad17a81e2ecbfc20017dc237 @@ -701,7 +701,7 @@ F tool/speedtest16.c c8a9c793df96db7e4933f0852abb7a03d48f2e81 F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e -P 8b318b9385d0542ca56750b901c0c6b7d05ca634 -R 9a8fca6b31553509b67660a185c0a0d1 +P 4879621658c2c785ab7b12dbae780901496d3a78 +R a8af020a2a79f4fed6aeaceed6fc2c93 U danielk1977 -Z 710356677aa5921b82da35e3db1360ce +Z 998a7073c0859344b08ca02f400fe38c diff --git a/manifest.uuid b/manifest.uuid index 36f1c60cc3..f7444ba843 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -4879621658c2c785ab7b12dbae780901496d3a78 \ No newline at end of file +b7fd4615cd41179484bd44d2f4bd7aef04977911 \ No newline at end of file diff --git a/src/test6.c b/src/test6.c index cf6c2fcbde..ab3654d48c 100644 --- a/src/test6.c +++ b/src/test6.c @@ -14,7 +14,7 @@ ** the effect on the database file of an OS crash or power failure. This ** is used to test the ability of SQLite to recover from those situations. ** -** $Id: test6.c,v 1.42 2009/02/10 14:28:57 danielk1977 Exp $ +** $Id: test6.c,v 1.43 2009/02/11 14:27:04 danielk1977 Exp $ */ #if SQLITE_TEST /* This file is used for testing only */ #include "sqliteInt.h" @@ -129,6 +129,7 @@ struct CrashFile { const sqlite3_io_methods *pMethod; /* Must be first */ sqlite3_file *pRealFile; /* Underlying "real" file handle */ char *zName; + int flags; /* Flags the file was opened with */ /* Cache of the entire file. This is used to speed up OsRead() and ** OsFileSize() calls. Although both could be done by traversing the @@ -167,6 +168,22 @@ static void *crash_realloc(void *p, int n){ return (void *)Tcl_Realloc(p, (size_t)n); } +/* +** Wrapper around the sqlite3OsWrite() function that avoids writing to the +** 512 byte block begining at offset PENDING_BYTE. +*/ +static int writeDbFile(CrashFile *p, u8 *z, i64 iAmt, i64 iOff){ + int rc; + int iSkip = 0; + if( iOff==PENDING_BYTE && (p->flags&SQLITE_OPEN_MAIN_DB) ){ + iSkip = 512; + } + if( (iAmt-iSkip)>0 ){ + rc = sqlite3OsWrite(p->pRealFile, &z[iSkip], iAmt-iSkip, iOff+iSkip); + } + return rc; +} + /* ** Flush the write-list as if xSync() had been called on file handle ** pFile. If isCrash is true, simulate a crash. @@ -261,8 +278,8 @@ static int writeListSync(CrashFile *pFile, int isCrash){ switch( eAction ){ case 1: { /* Write out correctly */ if( pWrite->zBuf ){ - rc = sqlite3OsWrite( - pRealFile, pWrite->zBuf, pWrite->nBuf, pWrite->iOffset + rc = writeDbFile( + pWrite->pFile, pWrite->zBuf, pWrite->nBuf, pWrite->iOffset ); }else{ rc = sqlite3OsTruncate(pRealFile, pWrite->iOffset); @@ -307,8 +324,8 @@ static int writeListSync(CrashFile *pFile, int isCrash){ sqlite3_int64 i; for(i=iFirst; rc==SQLITE_OK && i<=iLast; i++){ sqlite3_randomness(g.iSectorSize, zGarbage); - rc = sqlite3OsWrite( - pRealFile, zGarbage, g.iSectorSize, i*g.iSectorSize + rc = writeDbFile( + pWrite->pFile, zGarbage, g.iSectorSize, i*g.iSectorSize ); } crash_free(zGarbage); @@ -559,6 +576,7 @@ static int cfOpen( pWrapper->pRealFile = pReal; rc = sqlite3OsFileSize(pReal, &iSize); pWrapper->iSize = (int)iSize; + pWrapper->flags = flags; } if( rc==SQLITE_OK ){ pWrapper->nData = (4096 + pWrapper->iSize); -- 2.47.2