From: danielk1977 Date: Thu, 8 May 2008 15:58:06 +0000 (+0000) Subject: Add extra instrumentation to test_osinst.c. Also the --binarylog option to the test... X-Git-Tag: version-3.6.10~1071 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=374177eb3956b5c3af5cf2c2ba7476045a12f367;p=thirdparty%2Fsqlite.git Add extra instrumentation to test_osinst.c. Also the --binarylog option to the test scripts. (CVS 5106) FossilOrigin-Name: 8a99efc07f93bc11d21aa501349c81f0fd8abf7b --- diff --git a/manifest b/manifest index e280b17b54..1ecd4eb7cb 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Use\sa\s6-byte\srather\sthan\san\s8-byte\sencoding\sfor\sintegers\sbetween\n17592186044416\sand\s140737488355327.\s\sTicket\s#3100.\s(CVS\s5105) -D 2008-05-08T15:18:10 +C Add\sextra\sinstrumentation\sto\stest_osinst.c.\sAlso\sthe\s--binarylog\soption\sto\sthe\stest\sscripts.\s(CVS\s5106) +D 2008-05-08T15:58:06 F Makefile.arm-wince-mingw32ce-gcc ac5f7b2cef0cd850d6f755ba6ee4ab961b1fadf7 F Makefile.in 8b9b8263852f0217157f9042b8e3dae7427ec739 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654 @@ -156,7 +156,7 @@ F src/test_loadext.c 22065d601a18878e5542191001f0eaa5d77c0ed8 F src/test_malloc.c c92a65e8f9b31bb2b332448d92d2016c000a963d F src/test_md5.c bca40b727c57462ddb415e57c5323445a1bb1a40 F src/test_onefile.c 2fea6d22f13f5f286356c80c77ffd41f995f2b7a -F src/test_osinst.c 7129ca5f91e655020539b4e628cb578dd30ac5c7 +F src/test_osinst.c b2947f2ef6201ecc0a922cd2241880a955f5af0d F src/test_schema.c e3f93725f7c5b2cff84a69dc4332040dfbc8f81a F src/test_server.c a6ece6c835e7eae835054124e09e947e422b1ac5 F src/test_tclvar.c b2d1115e4d489179d3f029e765211b2ad527ba59 @@ -458,7 +458,7 @@ F test/tableapi.test 791f7e3891d9b70bdb43b311694bf5e9befcbc34 F test/tclsqlite.test 3dfb48f46de4353376fad835390b493ba066b4dc F test/tempdb.test b88ac8a19823cf771d742bf61eef93ef337c06b1 F test/temptable.test 19b851b9e3e64d91e9867619b2a3f5fffee6e125 -F test/tester.tcl a8975c66f1d1d4f4f23ee15e6e5845472d1c728f +F test/tester.tcl 11961673d7c9877f3314a8180e270913956f7085 F test/thread001.test 8fbd9559da0bbdc273e00318c7fd66c162020af7 F test/thread002.test 2c4ad2c386f60f6fe268cd91c769ee35b3c1fd0b F test/thread1.test 776c9e459b75ba905193b351926ac4019b049f35 @@ -634,7 +634,7 @@ F www/tclsqlite.tcl 8be95ee6dba05eabcd27a9d91331c803f2ce2130 F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0 F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b F www/whentouse.tcl fc46eae081251c3c181bd79c5faef8195d7991a5 -P ed06d90d8c4ee70ea6e99359317ac7bc1dcc4828 -R ea249fc8a3a9b71ffa0c52cbea6c6669 -U drh -Z 54cc5eff958cdf62777ff36a8bebe665 +P 0a4d26dede320d90a39133dce3d76ca3ee1a4ee6 +R a3498bd60c16481a0e5b89e536d0aa82 +U danielk1977 +Z 4b996eb3346ff3c422ad016b173a4ca3 diff --git a/manifest.uuid b/manifest.uuid index f2574b2212..d4265f815d 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -0a4d26dede320d90a39133dce3d76ca3ee1a4ee6 \ No newline at end of file +8a99efc07f93bc11d21aa501349c81f0fd8abf7b \ No newline at end of file diff --git a/src/test_osinst.c b/src/test_osinst.c index 09fe51cc3c..ab7bb54cf2 100644 --- a/src/test_osinst.c +++ b/src/test_osinst.c @@ -26,6 +26,7 @@ ** sqlite3_instvfs_get() ** ** sqlite3_instvfs_binarylog +** sqlite3_instvfs_binarylog_marker ** ** Tcl interface (omitted if SQLITE_TEST is not set): ** @@ -117,17 +118,22 @@ #define OS_NUMEVENTS 21 +#define BINARYLOG_STRING 30 +#define BINARYLOG_MARKER 31 + struct InstVfs { sqlite3_vfs base; sqlite3_vfs *pVfs; - + void *pClient; void (*xDel)(void *); - void (*xCall)(void *, int, sqlite3_int64, const char *, int, int, sqlite3_int64); + void (*xCall)(void *, int, int, sqlite3_int64, int, const char *, int, int, sqlite3_int64); /* Counters */ sqlite3_int64 aTime[OS_NUMEVENTS]; int aCount[OS_NUMEVENTS]; + + int iNextFileId; }; typedef struct InstVfs InstVfs; @@ -139,6 +145,7 @@ struct inst_file { sqlite3_file *pReal; InstVfs *pInstVfs; const char *zName; + int iFileId; /* File id number */ int flags; }; @@ -174,6 +181,8 @@ static int instRandomness(sqlite3_vfs*, int nByte, char *zOut); static int instSleep(sqlite3_vfs*, int microseconds); static int instCurrentTime(sqlite3_vfs*, double*); +static void binarylog_blob(sqlite3_vfs *, const char *, int); + static sqlite3_vfs inst_vfs = { 1, /* iVersion */ sizeof(inst_file), /* szOsFile */ @@ -238,7 +247,9 @@ __inline__ unsigned long long int osinst_hwtime(void){ pInstVfs->aTime[eEvent] += t; \ pInstVfs->aCount[eEvent] += 1; \ if( pInstVfs->xCall ){ \ - pInstVfs->xCall(pInstVfs->pClient, eEvent, t, p->zName, p->flags, A, B); \ + pInstVfs->xCall( \ + pInstVfs->pClient,eEvent,p->iFileId,t,rc,p->zName,p->flags,A,B \ + ); \ } \ return rc; \ } @@ -252,7 +263,7 @@ __inline__ unsigned long long int osinst_hwtime(void){ pInstVfs->aTime[eEvent] += t; \ pInstVfs->aCount[eEvent] += 1; \ if( pInstVfs->xCall ){ \ - pInstVfs->xCall(pInstVfs->pClient, eEvent, t, Z, flags, A, B); \ + pInstVfs->xCall(pInstVfs->pClient,eEvent,0, t, rc, Z, flags, A, B); \ } \ return rc; \ } @@ -306,7 +317,9 @@ static int instSync(sqlite3_file *pFile, int flags){ ** Return the current file-size of an inst-file. */ static int instFileSize(sqlite3_file *pFile, sqlite_int64 *pSize){ - OS_TIME_IO(OS_FILESIZE, 0, 0, p->pReal->pMethods->xFileSize(p->pReal, pSize)); + OS_TIME_IO(OS_FILESIZE, (int)(*pSize), 0, + p->pReal->pMethods->xFileSize(p->pReal, pSize) + ); } /* @@ -367,8 +380,10 @@ static int instOpen( p->pInstVfs = (InstVfs *)pVfs; p->zName = zName; p->flags = flags; + p->iFileId = ++p->pInstVfs->iNextFileId; - OS_TIME_VFS(OS_OPEN, zName, flags, 0, 0, + binarylog_blob(pVfs, zName, -1); + OS_TIME_VFS(OS_OPEN, zName, flags, p->iFileId, 0, REALVFS(pVfs)->xOpen(REALVFS(pVfs), zName, p->pReal, flags, pOutFlags) ); } @@ -379,6 +394,7 @@ static int instOpen( ** returning. */ static int instDelete(sqlite3_vfs *pVfs, const char *zPath, int dirSync){ + binarylog_blob(pVfs, zPath, -1); OS_TIME_VFS(OS_DELETE, zPath, 0, dirSync, 0, REALVFS(pVfs)->xDelete(REALVFS(pVfs), zPath, dirSync) ); @@ -389,6 +405,7 @@ static int instDelete(sqlite3_vfs *pVfs, const char *zPath, int dirSync){ ** is available, or false otherwise. */ static int instAccess(sqlite3_vfs *pVfs, const char *zPath, int flags){ + binarylog_blob(pVfs, zPath, -1); OS_TIME_VFS(OS_ACCESS, zPath, 0, flags, 0, REALVFS(pVfs)->xAccess(REALVFS(pVfs), zPath, flags) ); @@ -508,7 +525,17 @@ sqlite3_vfs *sqlite3_instvfs_create(const char *zName, const char *zParent){ void sqlite3_instvfs_configure( sqlite3_vfs *pVfs, - void (*xCall)(void*, int, sqlite3_int64, const char*, int, int, sqlite3_int64), + void (*xCall)( + void*, + int, /* File id */ + int, /* Event code */ + sqlite3_int64, + int, /* Return code */ + const char*, /* File name */ + int, + int, + sqlite3_int64 + ), void *pClient, void (*xDel)(void *) ){ @@ -608,7 +635,9 @@ static void put32bits(unsigned char *p, unsigned int v){ static void binarylog_xcall( void *p, int eEvent, + int iFileId, sqlite3_int64 nClick, + int return_code, const char *zName, int flags, int nByte, @@ -616,7 +645,7 @@ static void binarylog_xcall( ){ InstVfsBinaryLog *pLog = (InstVfsBinaryLog *)p; unsigned char *zRec; - if( (20+pLog->nBuf)>BINARYLOG_BUFFERSIZE ){ + if( (28+pLog->nBuf)>BINARYLOG_BUFFERSIZE ){ sqlite3_file *pFile = pLog->pOut; pFile->pMethods->xWrite(pFile, pLog->zBuf, pLog->nBuf, pLog->iOffset); pLog->iOffset += pLog->nBuf; @@ -624,11 +653,13 @@ static void binarylog_xcall( } zRec = (unsigned char *)&pLog->zBuf[pLog->nBuf]; put32bits(&zRec[0], eEvent); - put32bits(&zRec[4], (int)nClick); - put32bits(&zRec[8], flags); - put32bits(&zRec[12], nByte); - put32bits(&zRec[16], (int)iOffset); - pLog->nBuf += 20; + put32bits(&zRec[4], (int)iFileId); + put32bits(&zRec[8], (int)nClick); + put32bits(&zRec[12], return_code); + put32bits(&zRec[16], flags); + put32bits(&zRec[20], nByte); + put32bits(&zRec[24], (int)iOffset); + pLog->nBuf += 28; } static void binarylog_xdel(void *p){ @@ -646,6 +677,51 @@ static void binarylog_xdel(void *p){ sqlite3_free(pLog); } +static void binarylog_blob( + sqlite3_vfs *pVfs, + const char *zBlob, + int nBlob +){ + unsigned char *zRec; + int nWrite; + InstVfs *pInstVfs = (InstVfs *)pVfs; + InstVfsBinaryLog *pLog; + + if( pVfs->xOpen!=instOpen || pInstVfs->xCall!=binarylog_xcall ){ + return; + } + + pLog = (InstVfsBinaryLog *)pInstVfs->pClient; + if( nBlob<0 ){ + nBlob = strlen(zBlob); + } + nWrite = nBlob + 28; + + if( (nWrite+pLog->nBuf)>BINARYLOG_BUFFERSIZE ){ + sqlite3_file *pFile = pLog->pOut; + pFile->pMethods->xWrite(pFile, pLog->zBuf, pLog->nBuf, pLog->iOffset); + pLog->iOffset += pLog->nBuf; + pLog->nBuf = 0; + } + + zRec = (unsigned char *)&pLog->zBuf[pLog->nBuf]; + memset(zRec, 0, nWrite); + put32bits(&zRec[0], BINARYLOG_STRING); + put32bits(&zRec[4], (int)nBlob); + memcpy(&zRec[28], zBlob, nBlob); + pLog->nBuf += nWrite; +} + +void sqlite3_instvfs_binarylog_marker( + sqlite3_vfs *pVfs, + const char *zMarker +){ + InstVfs *pInstVfs = (InstVfs *)pVfs; + InstVfsBinaryLog *pLog = (InstVfsBinaryLog *)pInstVfs->pClient; + binarylog_blob(pVfs, zMarker, -1); + binarylog_xcall(pLog, BINARYLOG_MARKER, 0, 0, 0, 0, 0, 0, 0); +} + sqlite3_vfs *sqlite3_instvfs_binarylog( const char *zVfs, const char *zParentVfs, @@ -707,7 +783,9 @@ typedef struct InstVfsCall InstVfsCall; static void test_instvfs_xcall( void *p, int eEvent, + int iFileId, sqlite3_int64 nClick, + int return_code, const char *zName, int flags, int nByte, @@ -745,8 +823,8 @@ static int test_sqlite3_instvfs( Tcl_Obj *CONST objv[] ){ static const char *IV_strs[] = - { "create", "destroy", "reset", "report", "configure", "binarylog", 0 }; - enum IV_enum { IV_CREATE, IV_DESTROY, IV_RESET, IV_REPORT, IV_CONFIGURE, IV_BINARYLOG }; + { "create", "destroy", "reset", "report", "configure", "binarylog", "marker", 0 }; + enum IV_enum { IV_CREATE, IV_DESTROY, IV_RESET, IV_REPORT, IV_CONFIGURE, IV_BINARYLOG, IV_MARKER }; int iSub; if( objc<2 ){ @@ -808,6 +886,22 @@ static int test_sqlite3_instvfs( break; } + case IV_MARKER: { + sqlite3_vfs *p; + if( objc!=4 ){ + Tcl_WrongNumArgs(interp, 2, objv, "VFS MARKER"); + return TCL_ERROR; + } + p = sqlite3_vfs_find(Tcl_GetString(objv[2])); + if( !p || p->xOpen!=instOpen ){ + Tcl_AppendResult(interp, "no such vfs: ", Tcl_GetString(objv[2]), 0); + return TCL_ERROR; + } + sqlite3_instvfs_binarylog_marker(p, Tcl_GetString(objv[3])); + Tcl_ResetResult(interp); + break; + } + case IV_CONFIGURE: { InstVfsCall *pCall; diff --git a/test/tester.tcl b/test/tester.tcl index 0d38b6274d..20ec60865a 100644 --- a/test/tester.tcl +++ b/test/tester.tcl @@ -11,7 +11,7 @@ # This file implements some common TCL routines used for regression # testing the SQLite library # -# $Id: tester.tcl,v 1.119 2008/05/05 17:14:54 danielk1977 Exp $ +# $Id: tester.tcl,v 1.120 2008/05/08 15:58:06 danielk1977 Exp $ # # What for user input before continuing. This gives an opportunity @@ -88,9 +88,15 @@ for {set i 0} {$i<[llength $argv]} {incr i} { append s "(method TEXT, clicks INT, file TEXT, i32 INT, i64 INT);" puts $ostrace_fd $s sqlite3_instvfs configure ostrace ostrace_call + sqlite3_instvfs configure ostrace ostrace_call } set argv [lreplace $argv $i $i] } + if {[lindex $argv $i] eq "--binarylog"} { + set tester_do_binarylog 1 + sqlite3_instvfs binarylog -default binarylog ostrace.bin + set argv [lreplace $argv $i $i] + } } # @@ -159,6 +165,9 @@ proc omit_test {name reason} { proc do_test {name cmd expected} { global argv nErr nTest skip_test maxErr sqlite3_memdebug_settitle $name + if {$::tester_do_binarylog} { + sqlite3_instvfs marker binarylog "Start of $name" + } if {$skip_test} { set skip_test 0 return @@ -192,6 +201,9 @@ proc do_test {name cmd expected} { puts " Ok" } flush stdout + if {$::tester_do_binarylog} { + sqlite3_instvfs marker binarylog "End of $name" + } } # Run an SQL script. @@ -283,6 +295,9 @@ proc finalize_testing {} { puts "in your TCL build." puts "******************************************************************" } + if {[info exists ::tester_do_binarylog]} { + sqlite3_instvfs destroy binarylog + } if {$sqlite_open_file_count} { puts "$sqlite_open_file_count files were left open" incr nErr