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

Enhance SQLITE_TESTCTRL_LOCALTIME_FAULT so that is able to install an

alternative localtime() interface so that the localtime logic an be better
tested.

FossilOrigin-Name: 6e25cb0890e8cdc63c9a21e841844d066267fc32ad143527843f7c8d05612b53
This commit is contained in:
drh
2022-02-10 21:26:53 +00:00
parent eadccaa926
commit d7e185ce5d
7 changed files with 49 additions and 19 deletions

View File

@@ -4161,13 +4161,27 @@ int sqlite3_test_control(int op, ...){
break;
}
/* sqlite3_test_control(SQLITE_TESTCTRL_LOCALTIME_FAULT, int onoff);
/* sqlite3_test_control(SQLITE_TESTCTRL_LOCALTIME_FAULT, onoff, xAlt);
**
** If parameter onoff is non-zero, subsequent calls to localtime()
** and its variants fail. If onoff is zero, undo this setting.
** If parameter onoff is 1, subsequent calls to localtime() fail.
** If 2, then invoke xAlt() instead of localtime(). If 0, normal
** processing.
**
** xAlt arguments are void pointers, but they really want to be:
**
** int xAlt(const time_t*, struct tm*);
**
** xAlt should write results in to struct tm object of its 2nd argument
** and return zero on success, or return non-zero on failure.
*/
case SQLITE_TESTCTRL_LOCALTIME_FAULT: {
sqlite3GlobalConfig.bLocaltimeFault = va_arg(ap, int);
if( sqlite3GlobalConfig.bLocaltimeFault==2 ){
sqlite3GlobalConfig.xAltLocaltime =
va_arg(ap, int(*)(const void*,void*));
}else{
sqlite3GlobalConfig.xAltLocaltime = 0;
}
break;
}