/ Check-in [f0d95afc]
Login

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

Overview
Comment:Use symbolic names for tasks in mptester.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: f0d95afc73f8dbce8943dceb4a14b7de650c8823
User & Date: drh 2013-04-10 12:01:21
Context
2013-04-10
16:13
Add the sqlite3_strglob() interface. check-in: 41d6ff32 user: drh tags: trunk
12:01
Use symbolic names for tasks in mptester. check-in: f0d95afc user: drh tags: trunk
03:06
Fix typo in name of mptest executable files in clean targets. check-in: 4c7d9e1e user: mistachkin tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to mptest/crash02.subtest.

     1      1   /*
     2      2   ** This script is called from crash01.test and config02.test and perhaps other
     3      3   ** script.  After the database file has been set up, make a big rollback 
     4      4   ** journal in client 1, then crash client 1.
     5      5   ** Then in the other clients, do an integrity check.
     6      6   */
     7         ---task 1
            7  +--task 1 leave-hot-journal
     8      8     --sleep 5
     9      9     --finish
    10     10     PRAGMA cache_size=10;
    11     11     BEGIN;
    12     12     UPDATE t1 SET b=randomblob(20000);
    13     13     UPDATE t2 SET b=randomblob(20000);
    14     14     UPDATE t3 SET b=randomblob(20000);
................................................................................
    18     18     UPDATE t2 SET b=NULL;
    19     19     UPDATE t3 SET b=NULL;
    20     20     UPDATE t4 SET b=NULL;
    21     21     UPDATE t5 SET b=NULL;
    22     22     --print Task one crashing an incomplete transaction
    23     23     --exit 1
    24     24   --end
    25         ---task 2
           25  +--task 2 integrity_check-2
    26     26     SELECT count(*) FROM t1;
    27     27     --match 64
    28     28     --sleep 100
    29     29     PRAGMA integrity_check(10);
    30         -  --output
    31     30     --match ok
    32     31   --end
    33         ---task 3
           32  +--task 3 integrity_check-3
    34     33     SELECT count(*) FROM t1;
    35     34     --match 64
    36     35     --sleep 100
    37     36     PRAGMA integrity_check(10);
    38         -  --output
    39     37     --match ok
    40     38   --end
    41         ---task 4
           39  +--task 4 integrity_check-4
    42     40     SELECT count(*) FROM t1;
    43     41     --match 64
    44     42     --sleep 100
    45     43     PRAGMA integrity_check(10);
    46         -  --output
    47     44     --match ok
    48     45   --end
    49         ---task 5
           46  +--task 5 integrity_check-5
    50     47     SELECT count(*) FROM t1;
    51     48     --match 64
    52     49     --sleep 100
    53     50     PRAGMA integrity_check(10);
    54         -  --output
    55     51     --match ok
    56     52   --end
    57     53   --wait all

Changes to mptest/mptest.c.

   516    516   ** Look up the next task for client iClient in the database.
   517    517   ** Return the task script and the task number and mark that
   518    518   ** task as being under way.
   519    519   */
   520    520   static int startScript(
   521    521     int iClient,              /* The client number */
   522    522     char **pzScript,          /* Write task script here */
   523         -  int *pTaskId              /* Write task number here */
          523  +  int *pTaskId,             /* Write task number here */
          524  +  char **pzTaskName         /* Name of the task */
   524    525   ){
   525    526     sqlite3_stmt *pStmt = 0;
   526    527     int taskId;
   527    528     int rc;
   528    529     int totalTime = 0;
   529    530   
   530    531     *pzScript = 0;
................................................................................
   551    552       if( rc==SQLITE_ROW ){
   552    553         runSql("DELETE FROM client WHERE id=%d", iClient);
   553    554         g.iTimeout = DEFAULT_TIMEOUT;
   554    555         runSql("COMMIT TRANSACTION;");
   555    556         return SQLITE_DONE;
   556    557       }
   557    558       pStmt = prepareSql(
   558         -              "SELECT script, id FROM task"
          559  +              "SELECT script, id, name FROM task"
   559    560                 " WHERE client=%d AND starttime IS NULL"
   560    561                 " ORDER BY id LIMIT 1", iClient);
   561    562       rc = sqlite3_step(pStmt);
   562    563       if( rc==SQLITE_ROW ){
   563    564         int n = sqlite3_column_bytes(pStmt, 0);
   564    565         *pzScript = sqlite3_malloc(n+1);
   565    566         strcpy(*pzScript, (const char*)sqlite3_column_text(pStmt, 0));
   566    567         *pTaskId = taskId = sqlite3_column_int(pStmt, 1);
          568  +      *pzTaskName = sqlite3_mprintf("%s", sqlite3_column_text(pStmt, 2));
   567    569         sqlite3_finalize(pStmt);
   568    570         runSql("UPDATE task"
   569    571                "   SET starttime=strftime('%%Y-%%m-%%d %%H:%%M:%%f','now')"
   570    572                " WHERE id=%d;", taskId);
   571    573         g.iTimeout = DEFAULT_TIMEOUT;
   572    574         runSql("COMMIT TRANSACTION;");
   573    575         return SQLITE_OK;
................................................................................
   799    801       if( iClient>0 ){
   800    802         errorMessage("%stimeout waiting for client %d", zErrPrefix, iClient);
   801    803       }else{
   802    804         errorMessage("%stimeout waiting for all clients", zErrPrefix);
   803    805       }
   804    806     }
   805    807   }
          808  +
          809  +/* Return a pointer to the tail of a filename
          810  +*/
          811  +static char *filenameTail(char *z){
          812  +  int i, j;
          813  +  for(i=j=0; z[i]; i++) if( z[i]=='/' ) j = i+1;
          814  +  return z+j;
          815  +}
   806    816   
   807    817   /* Maximum number of arguments to a --command */
   808    818   #define MX_ARG 2
   809    819   
   810    820   /*
   811    821   ** Run a script.
   812    822   */
................................................................................
  1035   1045       ** Assign work to a client.  Start the client if it is not running
  1036   1046       ** already.
  1037   1047       */
  1038   1048       if( strcmp(zCmd, "task")==0 && iClient==0 ){
  1039   1049         int iTarget = atoi(azArg[0]);
  1040   1050         int iEnd;
  1041   1051         char *zTask;
         1052  +      char *zTName;
  1042   1053         iEnd = findEnd(zScript+ii+len, &lineno);
  1043   1054         if( iTarget<0 ){
  1044   1055           errorMessage("line %d of %s: bad client number: %d",
  1045   1056                        prevLine, zFilename, iTarget);
  1046   1057         }else{
  1047   1058           zTask = sqlite3_mprintf("%.*s", iEnd, zScript+ii+len);
         1059  +        if( nArg>1 ){
         1060  +          zTName = sqlite3_mprintf("%s", azArg[1]);
         1061  +        }else{
         1062  +          zTName = sqlite3_mprintf("%s:%d", filenameTail(zFilename), prevLine);
         1063  +        }
  1048   1064           startClient(iTarget);
  1049         -        runSql("INSERT INTO task(client,script)"
  1050         -               " VALUES(%d,'%q')", iTarget, zTask);
         1065  +        runSql("INSERT INTO task(client,script,name)"
         1066  +               " VALUES(%d,'%q',%Q)", iTarget, zTask, zTName);
  1051   1067           sqlite3_free(zTask);
         1068  +        sqlite3_free(zTName);
  1052   1069         }
  1053   1070         iEnd += tokenLength(zScript+ii+len+iEnd, &lineno);
  1054   1071         len += iEnd;
  1055   1072         iBegin = ii+len;
  1056   1073       }else
  1057   1074   
  1058   1075       /* error */{
................................................................................
  1213   1230     g.iTimeout = DEFAULT_TIMEOUT;
  1214   1231     if( g.bSqlTrace ) sqlite3_trace(g.db, sqlTraceCallback, 0);
  1215   1232     if( !g.bSync ) trySql("PRAGMA synchronous=OFF");
  1216   1233     if( iClient>0 ){
  1217   1234       if( n>0 ) unrecognizedArguments(argv[0], n, argv+2);
  1218   1235       if( g.iTrace ) logMessage("start-client");
  1219   1236       while(1){
  1220         -      char zTaskName[50];
  1221         -      rc = startScript(iClient, &zScript, &taskId);
         1237  +      char *zTaskName = 0;
         1238  +      rc = startScript(iClient, &zScript, &taskId, &zTaskName);
  1222   1239         if( rc==SQLITE_DONE ) break;
  1223         -      sqlite3_snprintf(sizeof(zTaskName), zTaskName, "client%02d-task-%d",
  1224         -                       iClient, taskId);
  1225         -      if( g.iTrace ) logMessage("begin %s", zTaskName);
         1240  +      if( g.iTrace ) logMessage("begin %s (%d)", zTaskName, taskId);
  1226   1241         runScript(iClient, taskId, zScript, zTaskName);
  1227         -      if( g.iTrace ) logMessage("end %s", zTaskName);
         1242  +      if( g.iTrace ) logMessage("end %s (%d)", zTaskName, taskId);
  1228   1243         finishScript(iClient, taskId, 0);
         1244  +      sqlite3_free(zTaskName);
  1229   1245         sqlite3_sleep(10);
  1230   1246       }
  1231   1247       if( g.iTrace ) logMessage("end-client");
  1232   1248     }else{
  1233   1249       sqlite3_stmt *pStmt;
  1234   1250       int iTimeout;
  1235   1251       if( n==0 ){
  1236   1252         fatalError("missing script filename");
  1237   1253       }
  1238   1254       if( n>1 ) unrecognizedArguments(argv[0], n, argv+2);
  1239   1255       runSql(
  1240   1256         "CREATE TABLE task(\n"
  1241   1257         "  id INTEGER PRIMARY KEY,\n"
         1258  +      "  name TEXT,\n"
  1242   1259         "  client INTEGER,\n"
  1243   1260         "  starttime DATE,\n"
  1244   1261         "  endtime DATE,\n"
  1245   1262         "  script TEXT\n"
  1246   1263         ");"
  1247   1264         "CREATE INDEX task_i1 ON task(client, starttime);\n"
  1248   1265         "CREATE INDEX task_i2 ON task(client, endtime);\n"

Changes to mptest/multiwrite01.test.

     1      1   /*
     2      2   ** This script sets up five different tasks all writing and updating
     3      3   ** the database at the same time, but each in its own table.
     4      4   */
     5         ---task 1
            5  +--task 1 build-t1
     6      6     DROP TABLE IF EXISTS t1;
     7      7     CREATE TABLE t1(a INTEGER PRIMARY KEY, b);
     8      8     --sleep 1
     9      9     INSERT INTO t1 VALUES(1, randomblob(2000));
    10     10     INSERT INTO t1 VALUES(2, randomblob(1000));
    11     11     --sleep 1
    12     12     INSERT INTO t1 SELECT a+2, randomblob(1500) FROM t1;
................................................................................
    30     30     SELECT a FROM t1 WHERE b='x17y';
    31     31     --match 17
    32     32     SELECT a FROM t1 WHERE b GLOB 'x2?y' ORDER BY b DESC LIMIT 5;
    33     33     --match 29 28 27 26 25
    34     34   --end
    35     35   
    36     36   
    37         ---task 2
           37  +--task 2 build-t2
    38     38     DROP TABLE IF EXISTS t2;
    39     39     CREATE TABLE t2(a INTEGER PRIMARY KEY, b);
    40     40     --sleep 1
    41     41     INSERT INTO t2 VALUES(1, randomblob(2000));
    42     42     INSERT INTO t2 VALUES(2, randomblob(1000));
    43     43     --sleep 1
    44     44     INSERT INTO t2 SELECT a+2, randomblob(1500) FROM t2;
................................................................................
    61     61     CREATE INDEX t2b ON t2(b);
    62     62     SELECT a FROM t2 WHERE b='x17y';
    63     63     --match 17
    64     64     SELECT a FROM t2 WHERE b GLOB 'x2?y' ORDER BY b DESC LIMIT 5;
    65     65     --match 29 28 27 26 25
    66     66   --end
    67     67   
    68         ---task 3
           68  +--task 3 build-t3
    69     69     DROP TABLE IF EXISTS t3;
    70     70     CREATE TABLE t3(a INTEGER PRIMARY KEY, b);
    71     71     --sleep 1
    72     72     INSERT INTO t3 VALUES(1, randomblob(2000));
    73     73     INSERT INTO t3 VALUES(2, randomblob(1000));
    74     74     --sleep 1
    75     75     INSERT INTO t3 SELECT a+2, randomblob(1500) FROM t3;
................................................................................
    92     92     CREATE INDEX t3b ON t3(b);
    93     93     SELECT a FROM t3 WHERE b='x17y';
    94     94     --match 17
    95     95     SELECT a FROM t3 WHERE b GLOB 'x2?y' ORDER BY b DESC LIMIT 5;
    96     96     --match 29 28 27 26 25
    97     97   --end
    98     98   
    99         ---task 4
           99  +--task 4 build-t4
   100    100     DROP TABLE IF EXISTS t4;
   101    101     CREATE TABLE t4(a INTEGER PRIMARY KEY, b);
   102    102     --sleep 1
   103    103     INSERT INTO t4 VALUES(1, randomblob(2000));
   104    104     INSERT INTO t4 VALUES(2, randomblob(1000));
   105    105     --sleep 1
   106    106     INSERT INTO t4 SELECT a+2, randomblob(1500) FROM t4;
................................................................................
   123    123     CREATE INDEX t4b ON t4(b);
   124    124     SELECT a FROM t4 WHERE b='x17y';
   125    125     --match 17
   126    126     SELECT a FROM t4 WHERE b GLOB 'x2?y' ORDER BY b DESC LIMIT 5;
   127    127     --match 29 28 27 26 25
   128    128   --end
   129    129   
   130         ---task 5
          130  +--task 5 build-t5
   131    131     DROP TABLE IF EXISTS t5;
   132    132     CREATE TABLE t5(a INTEGER PRIMARY KEY, b);
   133    133     --sleep 1
   134    134     INSERT INTO t5 VALUES(1, randomblob(2000));
   135    135     INSERT INTO t5 VALUES(2, randomblob(1000));
   136    136     --sleep 1
   137    137     INSERT INTO t5 SELECT a+2, randomblob(1500) FROM t5;