1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-10 01:02:56 +03:00

Add the sqlite3_test_control() API. Use it to control the fault injector. (CVS 4758)

FossilOrigin-Name: 413ddade6a13f993cddc57389d1107d82fa19972
This commit is contained in:
drh
2008-01-31 14:43:24 +00:00
parent 820a90694e
commit ed13d98c8c
5 changed files with 96 additions and 18 deletions

View File

@@ -14,7 +14,7 @@
** other files are for internal use by SQLite and should not be
** accessed by users of the library.
**
** $Id: main.c,v 1.415 2008/01/31 13:35:49 drh Exp $
** $Id: main.c,v 1.416 2008/01/31 14:43:24 drh Exp $
*/
#include "sqliteInt.h"
#include <ctype.h>
@@ -1470,3 +1470,39 @@ int sqlite3_file_control(sqlite3 *db, const char *zDbName, int op, void *pArg){
sqlite3_mutex_leave(db->mutex);
return rc;
}
/*
** Interface to the testing logic.
*/
int sqlite3_test_control(int op, ...){
va_list ap;
int rc = 0;
va_start(ap, op);
switch( op ){
#ifndef SQLITE_OMIT_FAULTINJECTOR
case SQLITE_TESTCTRL_FAULT_CONFIG: {
int id = va_arg(ap, int);
int nDelay = va_arg(ap, int);
int nRepeat = va_arg(ap, int);
sqlite3FaultConfig(id, nDelay, nRepeat);
break;
}
case SQLITE_TESTCTRL_FAULT_FAILURES: {
int id = va_arg(ap, int);
rc = sqlite3FaultFailures(id);
break;
}
case SQLITE_TESTCTRL_FAULT_BENIGN_FAILURES: {
int id = va_arg(ap, int);
rc = sqlite3FaultBenignFailures(id);
break;
}
case SQLITE_TESTCTRL_FAULT_PENDING: {
int id = va_arg(ap, int);
rc = sqlite3FaultPending(id);
break;
}
#endif /* SQLITE_OMIT_FAULTINJECTOR */
}
va_end(ap);
}