Index: test/threadtest3.c ================================================================== --- test/threadtest3.c +++ test/threadtest3.c @@ -1,43 +1,43 @@ - /* +** 2010-07-22 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +************************************************************************* +** ** The code in this file runs a few multi-threaded test cases using the ** SQLite library. It can be compiled to an executable on unix using the ** following command: ** ** gcc -O2 threadtest3.c sqlite3.c -ldl -lpthread -lm ** -** Then run the compiled program. The exit status is non-zero if any tests -** failed (hopefully there is also some output to stdout to clarify what went -** wrong). -** -** There are three parts to the code in this file, in the following order: -** -** 1. Code for the SQL aggregate function md5sum() copied from -** tclsqlite.c in the SQLite distribution. The names of all the -** types and functions in this section begin with "MD5" or "md5". -** -** 2. A set of utility functions that may be used to implement -** multi-threaded test cases. These are all called by test code -** via macros that help with error reporting. The macros are defined -** immediately below this comment. -** -** 3. The test code itself. And a main() routine to drive the test -** code. -*/ - -/************************************************************************* -** Start of test code/infrastructure interface macros. -** -** The following macros constitute the interface between the test -** programs and the test infrastructure. Test infrastructure code -** does not itself use any of these macros. Test code should not -** call any of the macroname_x() functions directly. -** -** See the header comments above the corresponding macroname_x() -** function for a description of each interface. -*/ +** Even though threadtest3.c is the only C source code file mentioned on +** the compiler command-line, #include macros are used to pull in additional +** C code files named "tt3_*.c". +** +** After compiling, run this program with an optional argument telling +** which test to run. All tests are run if no argument is given. The +** argument can be a glob pattern to match multiple tests. Examples: +** +** ./a.out -- Run all tests +** ./a.out walthread3 -- Run the "walthread3" test +** ./a.out 'wal*' -- Run all of the wal* tests +** ./a.out --help -- List all available tests +** +** The exit status is non-zero if any test fails. +*/ + +/* +** The "Set Error Line" macro. +*/ +#define SEL(e) ((e)->iLine = ((e)->rc ? (e)->iLine : __LINE__)) /* Database functions */ #define opendb(w,x,y,z) (SEL(w), opendb_x(w,x,y,z)) #define closedb(y,z) (SEL(y), closedb_x(y,z)) @@ -389,13 +389,13 @@ MD5Final(digest,p); MD5DigestToBase16(digest, zBuf); sqlite3_result_text(context, zBuf, -1, SQLITE_TRANSIENT); } -/************************************************************************* +/* ** End of copied md5sum() code. -*/ +**************************************************************************/ typedef sqlite3_int64 i64; typedef struct Error Error; typedef struct Sqlite Sqlite; @@ -446,11 +446,12 @@ } static void print_err(Error *p){ if( p->rc!=SQLITE_OK ){ printf("Error: (%d) \"%s\" at line %d\n", p->rc, p->zErr, p->iLine); - nGlobalErr++; + if( sqlite3_strglob("* - no such table: *",p->zErr)!=0 ) nGlobalErr++; + fflush(stdout); } } static void print_and_free_err(Error *p){ print_err(p); @@ -783,10 +784,11 @@ rc = pthread_join(p->tid, &ret); if( rc!=0 ){ if( pErr->rc==SQLITE_OK ) system_error(pErr, rc); }else{ printf("Thread %d says: %s\n", p->iTid, (ret==0 ? "..." : (char *)ret)); + fflush(stdout); } sqlite3_free(p); } pThreads->pThread = 0; } @@ -896,15 +898,10 @@ } } return ret; } -/* -** The "Set Error Line" macro. -*/ -#define SEL(e) ((e)->iLine = ((e)->rc ? (e)->iLine : __LINE__)) - /************************************************************************* ************************************************************************** ************************************************************************** ** End infrastructure. Begin tests. @@ -1425,13 +1422,13 @@ #include "tt3_vacuum.c" #include "tt3_stress.c" int main(int argc, char **argv){ struct ThreadTest { - void (*xTest)(int); - const char *zTest; - int nMs; + void (*xTest)(int); /* Routine for running this test */ + const char *zTest; /* Name of this test */ + int nMs; /* How long to run this test, in milliseconds */ } aTest[] = { { walthread1, "walthread1", 20000 }, { walthread2, "walthread2", 20000 }, { walthread3, "walthread3", 20000 }, { walthread4, "walthread4", 20000 }, @@ -1450,11 +1447,11 @@ { stress1, "stress1", 10000 }, { stress2, "stress2", 60000 }, }; int i; - int bTestfound = 0; + int nTestfound = 0; sqlite3_config(SQLITE_CONFIG_MULTITHREAD); sqlite3_config(SQLITE_CONFIG_MULTITHREAD); for(i=0; i0 ? 255 : 0); usage: printf("Usage: %s [testname|testprefix*]...\n", argv[0]); printf("Available tests are:\n"); @@ -1483,7 +1481,5 @@ printf(" %s\n", aTest[i].zTest); } return 254; } - - Index: test/tt3_checkpoint.c ================================================================== --- test/tt3_checkpoint.c +++ test/tt3_checkpoint.c @@ -1,7 +1,7 @@ /* -** 2001 September 15 +** 2011-02-02 ** ** The author disclaims copyright to this source code. In place of ** a legal notice, here is a blessing: ** ** May you do good and not evil. @@ -144,7 +144,5 @@ if( ctx.nMaxFrame>CHECKPOINT_STARVATION_FRAMELIMIT+10 ){ test_error(&err, "WAL grew too large - %d frames", ctx.nMaxFrame); } print_and_free_err(&err); } - -