1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-07-29 08:01:23 +03:00

Generic cleanups and fixes in SQLTester.

FossilOrigin-Name: fc5d3cc30d2b96da42ea10dfb39f1631ff93b8384514fffd641b343df51da2a6
This commit is contained in:
stephan
2023-08-10 04:24:12 +00:00
parent eda67031de
commit f703dfa381
7 changed files with 69 additions and 38 deletions

View File

@ -224,7 +224,7 @@ test: $(SQLite3Jni.class) $(sqlite3-jni.dll)
org.sqlite.jni.Tester1 $(if $(test.flags),-- $(test.flags),)
tester.scripts := $(sort $(wildcard $(dir.src)/tests/*.test))
tester.flags ?= --verbose
tester.flags ?= # --verbose
.PHONY: tester
ifeq (1,$(enable.tester))
tester: $(CLASS_FILES.tester) $(sqlite3-jni.dll)

View File

@ -166,7 +166,7 @@
https://docs.oracle.com/javase/8/docs/technotes/guides/jni/spec/design.html#jni_interface_functions_and_pointers
*/
#define JENV_OSELF JNIEnv * const env, jobject jSelf
#define JENV_CSELF JNIEnv * const env, jclass jSelf
#define JENV_CSELF JNIEnv * const env, jclass jKlazz
/* Helpers to account for -Xcheck:jni warnings about not having
checked for exceptions. */
#define IFTHREW if((*env)->ExceptionCheck(env))
@ -4203,7 +4203,7 @@ Java_org_sqlite_jni_SQLite3Jni_uncacheJniEnv(JENV_CSELF){
sqlite3.c instead of sqlite3.h.
*/
JNIEXPORT void JNICALL
Java_org_sqlite_jni_SQLite3Jni_init(JENV_CSELF, jclass klazzSjni){
Java_org_sqlite_jni_SQLite3Jni_init(JENV_CSELF){
enum JType {
JTYPE_INT,
JTYPE_BOOL
@ -4266,16 +4266,16 @@ Java_org_sqlite_jni_SQLite3Jni_init(JENV_CSELF, jclass klazzSjni){
for( pConfFlag = &aLimits[0]; pConfFlag->zName; ++pConfFlag ){
char const * zSig = (JTYPE_BOOL == pConfFlag->jtype) ? "Z" : "I";
fieldId = (*env)->GetStaticFieldID(env, klazzSjni, pConfFlag->zName, zSig);
fieldId = (*env)->GetStaticFieldID(env, jKlazz, pConfFlag->zName, zSig);
EXCEPTION_IS_FATAL("Missing an expected static member of the SQLite3Jni class.");
//MARKER(("Setting %s (field=%p) = %d\n", pConfFlag->zName, fieldId, pConfFlag->value));
assert(fieldId);
switch(pConfFlag->jtype){
case JTYPE_INT:
(*env)->SetStaticIntField(env, klazzSjni, fieldId, (jint)pConfFlag->value);
(*env)->SetStaticIntField(env, jKlazz, fieldId, (jint)pConfFlag->value);
break;
case JTYPE_BOOL:
(*env)->SetStaticBooleanField(env, klazzSjni, fieldId,
(*env)->SetStaticBooleanField(env, jKlazz, fieldId,
pConfFlag->value ? JNI_TRUE : JNI_FALSE);
break;
}

View File

@ -758,10 +758,10 @@ extern "C" {
/*
* Class: org_sqlite_jni_SQLite3Jni
* Method: init
* Signature: (Ljava/lang/Class;)V
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_org_sqlite_jni_SQLite3Jni_init
(JNIEnv *, jclass, jclass);
(JNIEnv *, jclass);
/*
* Class: org_sqlite_jni_SQLite3Jni

View File

@ -126,7 +126,7 @@ public final class SQLite3Jni {
//! Not used
private SQLite3Jni(){}
//! Called from static init code.
private static native void init(@NotNull Class<SQLite3Jni> c);
private static native void init();
/**
Each thread which uses the SQLite3 JNI APIs should call
@ -1457,6 +1457,6 @@ public final class SQLite3Jni {
static {
// This MUST come after the SQLITE_MAX_... values or else
// attempting to modify them silently fails.
init(SQLite3Jni.class);
init();
}
}

View File

@ -47,27 +47,56 @@ enum ResultRowMode {
NEWLINE
};
/**
Base exception type for test-related failures.
*/
class SQLTesterException extends RuntimeException {
public SQLTesterException(String msg){
private boolean bFatal = false;
SQLTesterException(String msg){
super(msg);
}
protected SQLTesterException(String msg, boolean fatal){
super(msg);
bFatal = fatal;
}
/**
Indicates whether the framework should consider this exception
type as immediately fatal to the test run or not.
*/
final boolean isFatal(){ return bFatal; }
}
/**
Generic test-failed exception.
*/
class TestScriptFailed extends SQLTesterException {
public TestScriptFailed(TestScript ts, String msg){
super(ts.getOutputPrefix()+": "+msg);
super(ts.getOutputPrefix()+": "+msg, true);
}
}
/**
Thrown when an unknown test command is encountered in a script.
*/
class UnknownCommand extends SQLTesterException {
public UnknownCommand(TestScript ts, String cmd){
super(ts.getOutputPrefix()+": unknown command: "+cmd);
super(ts.getOutputPrefix()+": unknown command: "+cmd, false);
}
}
/**
Thrown when an "incompatible directive" is found in a script. This
can be the presence of a C-preprocessor construct, specific
metadata tags within a test script's header, or specific test
constructs which are incompatible with this particular
implementation.
*/
class IncompatibleDirective extends SQLTesterException {
public IncompatibleDirective(TestScript ts, String line){
super(ts.getOutputPrefix()+": incompatible directive: "+line);
super(ts.getOutputPrefix()+": incompatible directive: "+line, false);
}
}
@ -124,6 +153,12 @@ class Outer {
test-script-interpreter.md.
This is a work in progress.
An instance of this application provides a core set of services
which TestScript instances use for processing testing logic.
TestScripts, in turn, delegate the concrete test work to Command
objects, which the TestScript parses on their behalf.
*/
public class SQLTester {
//! List of input script files.
@ -205,17 +240,10 @@ public class SQLTester {
outln("----->>>>> running [",f,"]");
try{
ts.run(this);
}catch(UnknownCommand e){
/* currently not fatal */
outln(e);
}catch(SQLTesterException e){
outln("EXCEPTION: ",e.getClass().getSimpleName(),": ",e.getMessage());
++nAbortedScript;
}catch(IncompatibleDirective e){
/* not fatal */
outln(e);
++nAbortedScript;
}catch(Exception e){
++nAbortedScript;
throw e;
if( e.isFatal() ) throw e;
}finally{
outln("<<<<<----- ",nTest," test(s) in ",ts.getFilename());
}
@ -266,7 +294,7 @@ public class SQLTester {
SQLTester affirmDbId(int n) throws IndexOutOfBoundsException {
if(n<0 || n>=aDb.length){
throw new IndexOutOfBoundsException("illegal db number.");
throw new IndexOutOfBoundsException("illegal db number: "+n);
}
return this;
}
@ -325,10 +353,13 @@ public class SQLTester {
tracking running totals.
*/
void reset(){
clearInputBuffer();
clearResultBuffer();
closeAllDbs();
nTest = 0;
nullView = "nil";
clearInputBuffer();
closeAllDbs();
emitColNames = false;
iCurrentDb = 0;
}
void setNullValue(String v){nullView = v;}