/ Check-in [98cb56e2]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Update the threadtest3 test program so that its output summary is compatible with releasetest.tcl. In threadtest3, do not record errors that contain the string "no such table" as being fatal errors, since they happen sometimes in a race condition in stress1.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 98cb56e2401ae7e113b071df8997ba62265821d3
User & Date: drh 2014-12-30 19:26:07
Context
2014-12-30
19:58
Ensure that when a file is extended using FCNTL_SIZE_HINT the last page is allocated on disk, even if the file will only use part of it. check-in: c7f84717 user: dan tags: trunk
19:26
Update the threadtest3 test program so that its output summary is compatible with releasetest.tcl. In threadtest3, do not record errors that contain the string "no such table" as being fatal errors, since they happen sometimes in a race condition in stress1. check-in: 98cb56e2 user: drh tags: trunk
18:07
Fix problems with the "inmemory_journal" permutation. check-in: 79693f04 user: dan tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to test/threadtest3.c.

     1         -
     2      1   /*
            2  +** 2010-07-22
            3  +**
            4  +** The author disclaims copyright to this source code.  In place of
            5  +** a legal notice, here is a blessing:
            6  +**
            7  +**    May you do good and not evil.
            8  +**    May you find forgiveness for yourself and forgive others.
            9  +**    May you share freely, never taking more than you give.
           10  +**
           11  +*************************************************************************
           12  +**
     3     13   ** The code in this file runs a few multi-threaded test cases using the
     4     14   ** SQLite library. It can be compiled to an executable on unix using the
     5     15   ** following command:
     6     16   **
     7     17   **   gcc -O2 threadtest3.c sqlite3.c -ldl -lpthread -lm
     8     18   **
     9         -** Then run the compiled program. The exit status is non-zero if any tests
    10         -** failed (hopefully there is also some output to stdout to clarify what went
    11         -** wrong).
           19  +** Even though threadtest3.c is the only C source code file mentioned on
           20  +** the compiler command-line, #include macros are used to pull in additional
           21  +** C code files named "tt3_*.c".
    12     22   **
    13         -** There are three parts to the code in this file, in the following order:
           23  +** After compiling, run this program with an optional argument telling
           24  +** which test to run.  All tests are run if no argument is given.  The
           25  +** argument can be a glob pattern to match multiple tests.  Examples:
    14     26   **
    15         -**   1. Code for the SQL aggregate function md5sum() copied from 
    16         -**      tclsqlite.c in the SQLite distribution. The names of all the 
    17         -**      types and functions in this section begin with "MD5" or "md5".
    18         -**
    19         -**   2. A set of utility functions that may be used to implement
    20         -**      multi-threaded test cases. These are all called by test code
    21         -**      via macros that help with error reporting. The macros are defined
    22         -**      immediately below this comment.
           27  +**        ./a.out                 -- Run all tests
           28  +**        ./a.out walthread3      -- Run the "walthread3" test
           29  +**        ./a.out 'wal*'          -- Run all of the wal* tests
           30  +**        ./a.out --help          -- List all available tests
    23     31   **
    24         -**   3. The test code itself. And a main() routine to drive the test 
    25         -**      code.
           32  +** The exit status is non-zero if any test fails.
           33  +*/
           34  +
           35  +/* 
           36  +** The "Set Error Line" macro.
    26     37   */
    27         -
    28         -/*************************************************************************
    29         -** Start of test code/infrastructure interface macros.
    30         -**
    31         -** The following macros constitute the interface between the test
    32         -** programs and the test infrastructure. Test infrastructure code 
    33         -** does not itself use any of these macros. Test code should not
    34         -** call any of the macroname_x() functions directly.
    35         -**
    36         -** See the header comments above the corresponding macroname_x()
    37         -** function for a description of each interface.
    38         -*/
           38  +#define SEL(e) ((e)->iLine = ((e)->rc ? (e)->iLine : __LINE__))
    39     39   
    40     40   /* Database functions */
    41     41   #define opendb(w,x,y,z)         (SEL(w), opendb_x(w,x,y,z))
    42     42   #define closedb(y,z)            (SEL(y), closedb_x(y,z))
    43     43   
    44     44   /* Functions to execute SQL */
    45     45   #define sql_script(x,y,z)       (SEL(x), sql_script_x(x,y,z))
................................................................................
   387    387     char zBuf[33];
   388    388     p = sqlite3_aggregate_context(context, sizeof(*p));
   389    389     MD5Final(digest,p);
   390    390     MD5DigestToBase16(digest, zBuf);
   391    391     sqlite3_result_text(context, zBuf, -1, SQLITE_TRANSIENT);
   392    392   }
   393    393   
   394         -/*************************************************************************
          394  +/*
   395    395   ** End of copied md5sum() code.
   396         -*/
          396  +**************************************************************************/
   397    397   
   398    398   typedef sqlite3_int64 i64;
   399    399   
   400    400   typedef struct Error Error;
   401    401   typedef struct Sqlite Sqlite;
   402    402   typedef struct Statement Statement;
   403    403   
................................................................................
   444    444     p->zErr = 0;
   445    445     p->rc = 0;
   446    446   }
   447    447   
   448    448   static void print_err(Error *p){
   449    449     if( p->rc!=SQLITE_OK ){
   450    450       printf("Error: (%d) \"%s\" at line %d\n", p->rc, p->zErr, p->iLine);
   451         -    nGlobalErr++;
          451  +    if( sqlite3_strglob("* - no such table: *",p->zErr)!=0 ) nGlobalErr++;
          452  +    fflush(stdout);
   452    453     }
   453    454   }
   454    455   
   455    456   static void print_and_free_err(Error *p){
   456    457     print_err(p);
   457    458     free_err(p);
   458    459   }
................................................................................
   781    782       pNext = p->pNext;
   782    783       int rc;
   783    784       rc = pthread_join(p->tid, &ret);
   784    785       if( rc!=0 ){
   785    786         if( pErr->rc==SQLITE_OK ) system_error(pErr, rc);
   786    787       }else{
   787    788         printf("Thread %d says: %s\n", p->iTid, (ret==0 ? "..." : (char *)ret));
          789  +      fflush(stdout);
   788    790       }
   789    791       sqlite3_free(p);
   790    792     }
   791    793     pThreads->pThread = 0;
   792    794   }
   793    795   
   794    796   static i64 filesize_x(
................................................................................
   894    896       }else{
   895    897         ret = (t >= timelimit);
   896    898       }
   897    899     }
   898    900     return ret;
   899    901   }
   900    902   
   901         -/* 
   902         -** The "Set Error Line" macro.
   903         -*/
   904         -#define SEL(e) ((e)->iLine = ((e)->rc ? (e)->iLine : __LINE__))
   905         -
   906    903   
   907    904   /*************************************************************************
   908    905   **************************************************************************
   909    906   **************************************************************************
   910    907   ** End infrastructure. Begin tests.
   911    908   */
   912    909   
................................................................................
  1423   1420   #include "tt3_index.c"
  1424   1421   #include "tt3_lookaside1.c"
  1425   1422   #include "tt3_vacuum.c"
  1426   1423   #include "tt3_stress.c"
  1427   1424   
  1428   1425   int main(int argc, char **argv){
  1429   1426     struct ThreadTest {
  1430         -    void (*xTest)(int);
  1431         -    const char *zTest;
  1432         -    int nMs;
         1427  +    void (*xTest)(int);   /* Routine for running this test */
         1428  +    const char *zTest;    /* Name of this test */
         1429  +    int nMs;              /* How long to run this test, in milliseconds */
  1433   1430     } aTest[] = {
  1434   1431       { walthread1, "walthread1", 20000 },
  1435   1432       { walthread2, "walthread2", 20000 },
  1436   1433       { walthread3, "walthread3", 20000 },
  1437   1434       { walthread4, "walthread4", 20000 },
  1438   1435       { walthread5, "walthread5",  1000 },
  1439   1436       { walthread5, "walthread5",  1000 },
................................................................................
  1448   1445       { lookaside1,          "lookaside1", 10000 },
  1449   1446       { vacuum1,             "vacuum1", 10000 },
  1450   1447       { stress1,             "stress1", 10000 },
  1451   1448       { stress2,             "stress2", 60000 },
  1452   1449     };
  1453   1450   
  1454   1451     int i;
  1455         -  int bTestfound = 0;
         1452  +  int nTestfound = 0;
  1456   1453   
  1457   1454     sqlite3_config(SQLITE_CONFIG_MULTITHREAD);
  1458   1455     sqlite3_config(SQLITE_CONFIG_MULTITHREAD);
  1459   1456   
  1460   1457     for(i=0; i<sizeof(aTest)/sizeof(aTest[0]); i++){
  1461   1458       char const *z = aTest[i].zTest;
  1462   1459       if( argc>1 ){
................................................................................
  1464   1461         for(iArg=1; iArg<argc; iArg++){
  1465   1462           if( 0==sqlite3_strglob(argv[iArg], z) ) break;
  1466   1463         }
  1467   1464         if( iArg==argc ) continue;
  1468   1465       }
  1469   1466   
  1470   1467       printf("Running %s for %d seconds...\n", z, aTest[i].nMs/1000);
         1468  +    fflush(stdout);
  1471   1469       aTest[i].xTest(aTest[i].nMs);
  1472         -    bTestfound++;
         1470  +    nTestfound++;
  1473   1471     }
  1474         -  if( bTestfound==0 ) goto usage;
         1472  +  if( nTestfound==0 ) goto usage;
  1475   1473   
  1476         -  printf("Total of %d errors across all tests\n", nGlobalErr);
         1474  +  printf("%d errors out of %d tests\n", nGlobalErr, nTestfound);
  1477   1475     return (nGlobalErr>0 ? 255 : 0);
  1478   1476   
  1479   1477    usage:
  1480   1478     printf("Usage: %s [testname|testprefix*]...\n", argv[0]);
  1481   1479     printf("Available tests are:\n");
  1482   1480     for(i=0; i<sizeof(aTest)/sizeof(aTest[0]); i++){
  1483   1481       printf("   %s\n", aTest[i].zTest);
  1484   1482     }
  1485   1483   
  1486   1484     return 254;
  1487   1485   }
  1488         -
  1489         -

Changes to test/tt3_checkpoint.c.

     1      1   /*
     2         -** 2001 September 15
            2  +** 2011-02-02
     3      3   **
     4      4   ** The author disclaims copyright to this source code.  In place of
     5      5   ** a legal notice, here is a blessing:
     6      6   **
     7      7   **    May you do good and not evil.
     8      8   **    May you find forgiveness for yourself and forgive others.
     9      9   **    May you share freely, never taking more than you give.
................................................................................
   142    142     CheckpointStarvationCtx ctx = { SQLITE_CHECKPOINT_RESTART, 0 };
   143    143     checkpoint_starvation_main(nMs, &ctx);
   144    144     if( ctx.nMaxFrame>CHECKPOINT_STARVATION_FRAMELIMIT+10 ){
   145    145       test_error(&err, "WAL grew too large - %d frames", ctx.nMaxFrame);
   146    146     }
   147    147     print_and_free_err(&err);
   148    148   }
   149         -
   150         -