Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Use symbolic names for tasks in mptester. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
f0d95afc73f8dbce8943dceb4a14b7de |
User & Date: | drh 2013-04-10 12:01:21.074 |
Context
2013-04-10
| ||
16:13 | Add the sqlite3_strglob() interface. (check-in: 41d6ff32a6 user: drh tags: trunk) | |
12:01 | Use symbolic names for tasks in mptester. (check-in: f0d95afc73 user: drh tags: trunk) | |
03:06 | Fix typo in name of mptest executable files in clean targets. (check-in: 4c7d9e1ed8 user: mistachkin tags: trunk) | |
Changes
Changes to mptest/crash02.subtest.
1 2 3 4 5 6 | /* ** This script is called from crash01.test and config02.test and perhaps other ** script. After the database file has been set up, make a big rollback ** journal in client 1, then crash client 1. ** Then in the other clients, do an integrity check. */ | | | < | < | < | < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | /* ** This script is called from crash01.test and config02.test and perhaps other ** script. After the database file has been set up, make a big rollback ** journal in client 1, then crash client 1. ** Then in the other clients, do an integrity check. */ --task 1 leave-hot-journal --sleep 5 --finish PRAGMA cache_size=10; BEGIN; UPDATE t1 SET b=randomblob(20000); UPDATE t2 SET b=randomblob(20000); UPDATE t3 SET b=randomblob(20000); UPDATE t4 SET b=randomblob(20000); UPDATE t5 SET b=randomblob(20000); UPDATE t1 SET b=NULL; UPDATE t2 SET b=NULL; UPDATE t3 SET b=NULL; UPDATE t4 SET b=NULL; UPDATE t5 SET b=NULL; --print Task one crashing an incomplete transaction --exit 1 --end --task 2 integrity_check-2 SELECT count(*) FROM t1; --match 64 --sleep 100 PRAGMA integrity_check(10); --match ok --end --task 3 integrity_check-3 SELECT count(*) FROM t1; --match 64 --sleep 100 PRAGMA integrity_check(10); --match ok --end --task 4 integrity_check-4 SELECT count(*) FROM t1; --match 64 --sleep 100 PRAGMA integrity_check(10); --match ok --end --task 5 integrity_check-5 SELECT count(*) FROM t1; --match 64 --sleep 100 PRAGMA integrity_check(10); --match ok --end --wait all |
Changes to mptest/mptest.c.
︙ | ︙ | |||
516 517 518 519 520 521 522 | ** Look up the next task for client iClient in the database. ** Return the task script and the task number and mark that ** task as being under way. */ static int startScript( int iClient, /* The client number */ char **pzScript, /* Write task script here */ | | > | 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 | ** Look up the next task for client iClient in the database. ** Return the task script and the task number and mark that ** task as being under way. */ static int startScript( int iClient, /* The client number */ char **pzScript, /* Write task script here */ int *pTaskId, /* Write task number here */ char **pzTaskName /* Name of the task */ ){ sqlite3_stmt *pStmt = 0; int taskId; int rc; int totalTime = 0; *pzScript = 0; |
︙ | ︙ | |||
551 552 553 554 555 556 557 | if( rc==SQLITE_ROW ){ runSql("DELETE FROM client WHERE id=%d", iClient); g.iTimeout = DEFAULT_TIMEOUT; runSql("COMMIT TRANSACTION;"); return SQLITE_DONE; } pStmt = prepareSql( | | > | 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 | if( rc==SQLITE_ROW ){ runSql("DELETE FROM client WHERE id=%d", iClient); g.iTimeout = DEFAULT_TIMEOUT; runSql("COMMIT TRANSACTION;"); return SQLITE_DONE; } pStmt = prepareSql( "SELECT script, id, name FROM task" " WHERE client=%d AND starttime IS NULL" " ORDER BY id LIMIT 1", iClient); rc = sqlite3_step(pStmt); if( rc==SQLITE_ROW ){ int n = sqlite3_column_bytes(pStmt, 0); *pzScript = sqlite3_malloc(n+1); strcpy(*pzScript, (const char*)sqlite3_column_text(pStmt, 0)); *pTaskId = taskId = sqlite3_column_int(pStmt, 1); *pzTaskName = sqlite3_mprintf("%s", sqlite3_column_text(pStmt, 2)); sqlite3_finalize(pStmt); runSql("UPDATE task" " SET starttime=strftime('%%Y-%%m-%%d %%H:%%M:%%f','now')" " WHERE id=%d;", taskId); g.iTimeout = DEFAULT_TIMEOUT; runSql("COMMIT TRANSACTION;"); return SQLITE_OK; |
︙ | ︙ | |||
799 800 801 802 803 804 805 806 807 808 809 810 811 812 | if( iClient>0 ){ errorMessage("%stimeout waiting for client %d", zErrPrefix, iClient); }else{ errorMessage("%stimeout waiting for all clients", zErrPrefix); } } } /* Maximum number of arguments to a --command */ #define MX_ARG 2 /* ** Run a script. */ | > > > > > > > > | 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 | if( iClient>0 ){ errorMessage("%stimeout waiting for client %d", zErrPrefix, iClient); }else{ errorMessage("%stimeout waiting for all clients", zErrPrefix); } } } /* Return a pointer to the tail of a filename */ static char *filenameTail(char *z){ int i, j; for(i=j=0; z[i]; i++) if( z[i]=='/' ) j = i+1; return z+j; } /* Maximum number of arguments to a --command */ #define MX_ARG 2 /* ** Run a script. */ |
︙ | ︙ | |||
1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 | ** Assign work to a client. Start the client if it is not running ** already. */ if( strcmp(zCmd, "task")==0 && iClient==0 ){ int iTarget = atoi(azArg[0]); int iEnd; char *zTask; iEnd = findEnd(zScript+ii+len, &lineno); if( iTarget<0 ){ errorMessage("line %d of %s: bad client number: %d", prevLine, zFilename, iTarget); }else{ zTask = sqlite3_mprintf("%.*s", iEnd, zScript+ii+len); startClient(iTarget); | > > > > > > | | > | 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 | ** Assign work to a client. Start the client if it is not running ** already. */ if( strcmp(zCmd, "task")==0 && iClient==0 ){ int iTarget = atoi(azArg[0]); int iEnd; char *zTask; char *zTName; iEnd = findEnd(zScript+ii+len, &lineno); if( iTarget<0 ){ errorMessage("line %d of %s: bad client number: %d", prevLine, zFilename, iTarget); }else{ zTask = sqlite3_mprintf("%.*s", iEnd, zScript+ii+len); if( nArg>1 ){ zTName = sqlite3_mprintf("%s", azArg[1]); }else{ zTName = sqlite3_mprintf("%s:%d", filenameTail(zFilename), prevLine); } startClient(iTarget); runSql("INSERT INTO task(client,script,name)" " VALUES(%d,'%q',%Q)", iTarget, zTask, zTName); sqlite3_free(zTask); sqlite3_free(zTName); } iEnd += tokenLength(zScript+ii+len+iEnd, &lineno); len += iEnd; iBegin = ii+len; }else /* error */{ |
︙ | ︙ | |||
1213 1214 1215 1216 1217 1218 1219 | g.iTimeout = DEFAULT_TIMEOUT; if( g.bSqlTrace ) sqlite3_trace(g.db, sqlTraceCallback, 0); if( !g.bSync ) trySql("PRAGMA synchronous=OFF"); if( iClient>0 ){ if( n>0 ) unrecognizedArguments(argv[0], n, argv+2); if( g.iTrace ) logMessage("start-client"); while(1){ | | | < < | | > > | 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 | g.iTimeout = DEFAULT_TIMEOUT; if( g.bSqlTrace ) sqlite3_trace(g.db, sqlTraceCallback, 0); if( !g.bSync ) trySql("PRAGMA synchronous=OFF"); if( iClient>0 ){ if( n>0 ) unrecognizedArguments(argv[0], n, argv+2); if( g.iTrace ) logMessage("start-client"); while(1){ char *zTaskName = 0; rc = startScript(iClient, &zScript, &taskId, &zTaskName); if( rc==SQLITE_DONE ) break; if( g.iTrace ) logMessage("begin %s (%d)", zTaskName, taskId); runScript(iClient, taskId, zScript, zTaskName); if( g.iTrace ) logMessage("end %s (%d)", zTaskName, taskId); finishScript(iClient, taskId, 0); sqlite3_free(zTaskName); sqlite3_sleep(10); } if( g.iTrace ) logMessage("end-client"); }else{ sqlite3_stmt *pStmt; int iTimeout; if( n==0 ){ fatalError("missing script filename"); } if( n>1 ) unrecognizedArguments(argv[0], n, argv+2); runSql( "CREATE TABLE task(\n" " id INTEGER PRIMARY KEY,\n" " name TEXT,\n" " client INTEGER,\n" " starttime DATE,\n" " endtime DATE,\n" " script TEXT\n" ");" "CREATE INDEX task_i1 ON task(client, starttime);\n" "CREATE INDEX task_i2 ON task(client, endtime);\n" |
︙ | ︙ |
Changes to mptest/multiwrite01.test.
1 2 3 4 | /* ** This script sets up five different tasks all writing and updating ** the database at the same time, but each in its own table. */ | | | 1 2 3 4 5 6 7 8 9 10 11 12 | /* ** This script sets up five different tasks all writing and updating ** the database at the same time, but each in its own table. */ --task 1 build-t1 DROP TABLE IF EXISTS t1; CREATE TABLE t1(a INTEGER PRIMARY KEY, b); --sleep 1 INSERT INTO t1 VALUES(1, randomblob(2000)); INSERT INTO t1 VALUES(2, randomblob(1000)); --sleep 1 INSERT INTO t1 SELECT a+2, randomblob(1500) FROM t1; |
︙ | ︙ | |||
30 31 32 33 34 35 36 | SELECT a FROM t1 WHERE b='x17y'; --match 17 SELECT a FROM t1 WHERE b GLOB 'x2?y' ORDER BY b DESC LIMIT 5; --match 29 28 27 26 25 --end | | | 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | SELECT a FROM t1 WHERE b='x17y'; --match 17 SELECT a FROM t1 WHERE b GLOB 'x2?y' ORDER BY b DESC LIMIT 5; --match 29 28 27 26 25 --end --task 2 build-t2 DROP TABLE IF EXISTS t2; CREATE TABLE t2(a INTEGER PRIMARY KEY, b); --sleep 1 INSERT INTO t2 VALUES(1, randomblob(2000)); INSERT INTO t2 VALUES(2, randomblob(1000)); --sleep 1 INSERT INTO t2 SELECT a+2, randomblob(1500) FROM t2; |
︙ | ︙ | |||
61 62 63 64 65 66 67 | CREATE INDEX t2b ON t2(b); SELECT a FROM t2 WHERE b='x17y'; --match 17 SELECT a FROM t2 WHERE b GLOB 'x2?y' ORDER BY b DESC LIMIT 5; --match 29 28 27 26 25 --end | | | 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 | CREATE INDEX t2b ON t2(b); SELECT a FROM t2 WHERE b='x17y'; --match 17 SELECT a FROM t2 WHERE b GLOB 'x2?y' ORDER BY b DESC LIMIT 5; --match 29 28 27 26 25 --end --task 3 build-t3 DROP TABLE IF EXISTS t3; CREATE TABLE t3(a INTEGER PRIMARY KEY, b); --sleep 1 INSERT INTO t3 VALUES(1, randomblob(2000)); INSERT INTO t3 VALUES(2, randomblob(1000)); --sleep 1 INSERT INTO t3 SELECT a+2, randomblob(1500) FROM t3; |
︙ | ︙ | |||
92 93 94 95 96 97 98 | CREATE INDEX t3b ON t3(b); SELECT a FROM t3 WHERE b='x17y'; --match 17 SELECT a FROM t3 WHERE b GLOB 'x2?y' ORDER BY b DESC LIMIT 5; --match 29 28 27 26 25 --end | | | 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 | CREATE INDEX t3b ON t3(b); SELECT a FROM t3 WHERE b='x17y'; --match 17 SELECT a FROM t3 WHERE b GLOB 'x2?y' ORDER BY b DESC LIMIT 5; --match 29 28 27 26 25 --end --task 4 build-t4 DROP TABLE IF EXISTS t4; CREATE TABLE t4(a INTEGER PRIMARY KEY, b); --sleep 1 INSERT INTO t4 VALUES(1, randomblob(2000)); INSERT INTO t4 VALUES(2, randomblob(1000)); --sleep 1 INSERT INTO t4 SELECT a+2, randomblob(1500) FROM t4; |
︙ | ︙ | |||
123 124 125 126 127 128 129 | CREATE INDEX t4b ON t4(b); SELECT a FROM t4 WHERE b='x17y'; --match 17 SELECT a FROM t4 WHERE b GLOB 'x2?y' ORDER BY b DESC LIMIT 5; --match 29 28 27 26 25 --end | | | 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 | CREATE INDEX t4b ON t4(b); SELECT a FROM t4 WHERE b='x17y'; --match 17 SELECT a FROM t4 WHERE b GLOB 'x2?y' ORDER BY b DESC LIMIT 5; --match 29 28 27 26 25 --end --task 5 build-t5 DROP TABLE IF EXISTS t5; CREATE TABLE t5(a INTEGER PRIMARY KEY, b); --sleep 1 INSERT INTO t5 VALUES(1, randomblob(2000)); INSERT INTO t5 VALUES(2, randomblob(1000)); --sleep 1 INSERT INTO t5 SELECT a+2, randomblob(1500) FROM t5; |
︙ | ︙ |