Add the sqlite_current_time variable for testing purposes. (CVS 1156)

FossilOrigin-Name: 23fa407d50741bc0719259792398f28c1d0f12c2
This commit is contained in:
drh
2004-01-06 00:44:24 +00:00
parent b46d162d8d
commit e807febbc2
4 changed files with 25 additions and 12 deletions
+13 -3
View File
@@ -1616,6 +1616,14 @@ char *sqliteOsFullPathname(const char *zRelative){
#endif
}
/*
** The following variable, if set to a now-zero value, become the result
** returned from sqliteOsCurrentTime(). This is used for testing.
*/
#ifdef SQLITE_TEST
int sqlite_current_time = 0;
#endif
/*
** Find the current time (in Universal Coordinated Time). Write the
** current time and date as a Julian Day number into *prNow and
@@ -1626,7 +1634,6 @@ int sqliteOsCurrentTime(double *prNow){
time_t t;
time(&t);
*prNow = t/86400.0 + 2440587.5;
return 0;
#endif
#if OS_WIN
FILETIME ft;
@@ -1637,8 +1644,11 @@ int sqliteOsCurrentTime(double *prNow){
GetSystemTimeAsFileTime( &ft );
now = ((double)ft.dwHighDateTime) * 4294967296.0;
*prNow = (now + ft.dwLowDateTime)/864000000000.0 + 2305813.5;
#endif
#ifdef SQLITE_TEST
if( sqlite_current_time ){
*prNow = sqlite_current_time/86400.0 + 2440587.5;
}
#endif
return 0;
return 1;
}
+4 -1
View File
@@ -13,7 +13,7 @@
** is not included in the SQLite library. It is used for automated
** testing of the SQLite library.
**
** $Id: test1.c,v 1.30 2003/12/23 03:06:23 drh Exp $
** $Id: test1.c,v 1.31 2004/01/06 00:44:25 drh Exp $
*/
#include "sqliteInt.h"
#include "tcl.h"
@@ -887,6 +887,7 @@ static int test_breakpoint(
int Sqlitetest1_Init(Tcl_Interp *interp){
extern int sqlite_search_count;
extern int sqlite_open_file_count;
extern int sqlite_current_time;
static struct {
char *zName;
Tcl_CmdProc *xProc;
@@ -925,6 +926,8 @@ int Sqlitetest1_Init(Tcl_Interp *interp){
(char*)&sqlite_search_count, TCL_LINK_INT);
Tcl_LinkVar(interp, "sqlite_open_file_count",
(char*)&sqlite_open_file_count, TCL_LINK_INT);
Tcl_LinkVar(interp, "sqlite_current_time",
(char*)&sqlite_current_time, TCL_LINK_INT);
Tcl_LinkVar(interp, "sqlite_static_bind_value",
(char*)&sqlite_static_bind_value, TCL_LINK_STRING);
return TCL_OK;