/ Check-in [b095e2cd]
Login

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

Overview
Comment:Improve the code coverage of "permutations.test coverage-pager".
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:b095e2cdb61ca8487255687f58fb1024d40f3986
User & Date: dan 2013-04-05 20:40:43
Context
2013-04-06
11:03
Add tests to "permutations.test coverage-pager" to cover uncovered branches. check-in: 07a0e4e9 user: dan tags: trunk
00:19
Add a prototype TH3-script-style test harness that starts multiple processes operating on the same database file at the same time. check-in: c318fafe user: drh tags: mptest
2013-04-05
20:40
Improve the code coverage of "permutations.test coverage-pager". check-in: b095e2cd user: dan tags: trunk
2013-04-04
19:32
Add further multi-client tests to mmap1.test. check-in: a107f75d user: dan tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/test_vfs.c.

   121    121   #define TESTVFS_DELETE_MASK       0x00000400
   122    122   #define TESTVFS_CLOSE_MASK        0x00000800
   123    123   #define TESTVFS_WRITE_MASK        0x00001000
   124    124   #define TESTVFS_TRUNCATE_MASK     0x00002000
   125    125   #define TESTVFS_ACCESS_MASK       0x00004000
   126    126   #define TESTVFS_FULLPATHNAME_MASK 0x00008000
   127    127   #define TESTVFS_READ_MASK         0x00010000
          128  +#define TESTVFS_UNLOCK_MASK       0x00020000
   128    129   
   129         -#define TESTVFS_ALL_MASK          0x0001FFFF
          130  +#define TESTVFS_ALL_MASK          0x0003FFFF
   130    131   
   131    132   
   132    133   #define TESTVFS_MAX_PAGES 1024
   133    134   
   134    135   /*
   135    136   ** A shared-memory buffer. There is one of these objects for each shared
   136    137   ** memory region opened by clients. If two clients open the same file,
................................................................................
   463    464     return sqlite3OsLock(p->pReal, eLock);
   464    465   }
   465    466   
   466    467   /*
   467    468   ** Unlock an tvfs-file.
   468    469   */
   469    470   static int tvfsUnlock(sqlite3_file *pFile, int eLock){
   470         -  TestvfsFd *p = tvfsGetFd(pFile);
   471         -  return sqlite3OsUnlock(p->pReal, eLock);
          471  +  TestvfsFd *pFd = tvfsGetFd(pFile);
          472  +  Testvfs *p = (Testvfs *)pFd->pVfs->pAppData;
          473  +  if( p->mask&TESTVFS_WRITE_MASK && tvfsInjectIoerr(p) ){
          474  +    return SQLITE_IOERR_UNLOCK;
          475  +  }
          476  +  return sqlite3OsUnlock(pFd->pReal, eLock);
   472    477   }
   473    478   
   474    479   /*
   475    480   ** Check if another file-handle holds a RESERVED lock on an tvfs-file.
   476    481   */
   477    482   static int tvfsCheckReservedLock(sqlite3_file *pFile, int *pResOut){
   478    483     TestvfsFd *p = tvfsGetFd(pFile);
................................................................................
  1097   1102           { "xWrite",        TESTVFS_WRITE_MASK },
  1098   1103           { "xRead",         TESTVFS_READ_MASK },
  1099   1104           { "xTruncate",     TESTVFS_TRUNCATE_MASK },
  1100   1105           { "xOpen",         TESTVFS_OPEN_MASK },
  1101   1106           { "xClose",        TESTVFS_CLOSE_MASK },
  1102   1107           { "xAccess",       TESTVFS_ACCESS_MASK },
  1103   1108           { "xFullPathname", TESTVFS_FULLPATHNAME_MASK },
         1109  +        { "xUnlock",       TESTVFS_UNLOCK_MASK },
  1104   1110         };
  1105   1111         Tcl_Obj **apElem = 0;
  1106   1112         int nElem = 0;
  1107   1113         int i;
  1108   1114         int mask = 0;
  1109   1115         if( objc!=3 ){
  1110   1116           Tcl_WrongNumArgs(interp, 2, objv, "LIST");

Changes to test/pager1.test.

    11     11   #
    12     12   
    13     13   set testdir [file dirname $argv0]
    14     14   source $testdir/tester.tcl
    15     15   source $testdir/lock_common.tcl
    16     16   source $testdir/malloc_common.tcl
    17     17   source $testdir/wal_common.tcl
           18  +set testprefix pager1
    18     19   
    19     20   # Do not use a codec for tests in this file, as the database file is
    20     21   # manipulated directly using tcl scripts (using the [hexio_write] command).
    21     22   #
    22     23   do_not_use_codec
    23     24   
    24     25   #
................................................................................
  1378   1379   
  1379   1380   #-------------------------------------------------------------------------
  1380   1381   # Test that regardless of the value returned by xSectorSize(), the
  1381   1382   # minimum effective sector-size is 512 and the maximum 65536 bytes.
  1382   1383   #
  1383   1384   testvfs tv -default 1
  1384   1385   foreach sectorsize {
         1386  +    16
  1385   1387       32   64   128   256   512   1024   2048 
  1386   1388       4096 8192 16384 32768 65536 131072 262144
  1387   1389   } {
  1388   1390     tv sectorsize $sectorsize
  1389   1391     tv devchar {}
  1390   1392     set eff $sectorsize
  1391   1393     if {$sectorsize < 512}   { set eff 512 }
................................................................................
  1400   1402         BEGIN;
  1401   1403           CREATE TABLE t1(a, b);
  1402   1404           CREATE TABLE t2(a, b);
  1403   1405           CREATE TABLE t3(a, b);
  1404   1406         COMMIT;
  1405   1407       }
  1406   1408       file size test.db-journal
  1407         -  } [expr $sectorsize > 65536 ? 65536 : $sectorsize]
         1409  +  } [expr $sectorsize > 65536 ? 65536 : ($sectorsize<32 ? 512 : $sectorsize)]
  1408   1410   
  1409   1411     do_test pager1-10.$sectorsize.2 {
  1410   1412       execsql { 
  1411   1413         INSERT INTO t3 VALUES(a_string(300), a_string(300));
  1412   1414         INSERT INTO t3 SELECT * FROM t3;        /*  2 */
  1413   1415         INSERT INTO t3 SELECT * FROM t3;        /*  4 */
  1414   1416         INSERT INTO t3 SELECT * FROM t3;        /*  8 */
................................................................................
  2518   2520     } {1 {disk I/O error}}
  2519   2521   
  2520   2522     do_test pager1-33.2 {
  2521   2523       file rename bak-journal test.db-journal
  2522   2524       execsql { SELECT * FROM t1 }
  2523   2525     } {one two}
  2524   2526   }
         2527  +
         2528  +#-------------------------------------------------------------------------
         2529  +# Test that appending pages to the database file then moving those pages
         2530  +# to the free-list before the transaction is committed does not cause
         2531  +# an error.
         2532  +#
         2533  +foreach {tn pragma strsize} {
         2534  +  1 { PRAGMA mmap_limit = 0 } 2400
         2535  +  2 { }                       2400
         2536  +  3 { PRAGMA mmap_limit = 0 } 4400
         2537  +  4 { }                       4400
         2538  +} {
         2539  +  reset_db
         2540  +  db func a_string a_string
         2541  +  db eval $pragma
         2542  +  do_execsql_test 34.$tn.1 {
         2543  +    CREATE TABLE t1(a, b);
         2544  +    INSERT INTO t1 VALUES(1, 2);
         2545  +  }
         2546  +  breakpoint
         2547  +  do_execsql_test 34.$tn.2 {
         2548  +    BEGIN;
         2549  +    INSERT INTO t1 VALUES(2, a_string($strsize));
         2550  +    DELETE FROM t1 WHERE oid=2;
         2551  +    COMMIT;
         2552  +    PRAGMA integrity_check;
         2553  +  } {ok}
         2554  +}
         2555  +
         2556  +#-------------------------------------------------------------------------
         2557  +#
         2558  +reset_db
         2559  +do_test 35 {
         2560  +  sqlite3 db test.db
         2561  +
         2562  +  execsql {
         2563  +    CREATE TABLE t1(x, y);
         2564  +    PRAGMA journal_mode = WAL;
         2565  +    INSERT INTO t1 VALUES(1, 2);
         2566  +  }
         2567  +
         2568  +  execsql {
         2569  +    BEGIN;
         2570  +      CREATE TABLE t2(a, b);
         2571  +  }
         2572  +
         2573  +  hexio_write test.db-shm [expr 16*1024] [string repeat 0055 8192]
         2574  +  catchsql ROLLBACK
         2575  +} {0 {}}
         2576  +
         2577  +do_multiclient_test tn {
         2578  +  sql1 {
         2579  +    PRAGMA auto_vacuum = 0;
         2580  +    CREATE TABLE t1(x, y);
         2581  +    INSERT INTO t1 VALUES(1, 2);
         2582  +  }
         2583  +
         2584  +  do_test 36.$tn.1 { 
         2585  +    sql2 { PRAGMA max_page_count = 2 }
         2586  +    list [catch { sql2 { CREATE TABLE t2(x) } } msg] $msg
         2587  +  } {1 {database or disk is full}}
         2588  +
         2589  +  sql1 { PRAGMA checkpoint_fullfsync = 1 }
         2590  +  sql1 { CREATE TABLE t2(x) }
         2591  +
         2592  +  do_test 36.$tn.2 { 
         2593  +    sql2 { INSERT INTO t2 VALUES('xyz') }
         2594  +    list [catch { sql2 { CREATE TABLE t3(x) } } msg] $msg
         2595  +  } {1 {database or disk is full}}
         2596  +}
         2597  +
         2598  +forcedelete test1 test2
         2599  +foreach {tn uri} {
         2600  +  1   {file:?mode=memory&cache=shared}
         2601  +  2   {file:one?mode=memory&cache=shared}
         2602  +  3   {file:test1?cache=shared}
         2603  +  4   {file:test2?another=parameter&yet=anotherone}
         2604  +} {
         2605  +  do_test 37.$tn {
         2606  +    catch { db close }
         2607  +    sqlite3_shutdown
         2608  +      sqlite3_config_uri 1
         2609  +      sqlite3 db $uri
         2610  +    db eval {
         2611  +      CREATE TABLE t1(x);
         2612  +      INSERT INTO t1 VALUES(1);
         2613  +      SELECT * FROM t1;
         2614  +    }
         2615  +  } {1}
         2616  +  db close
         2617  +  sqlite3_shutdown
         2618  +  sqlite3_config_uri 0
         2619  +}
         2620  +
         2621  +do_test 38.1 {
         2622  +  catch { db close }
         2623  +  forcedelete test.db
         2624  +  set fd [open test.db w]
         2625  +  puts $fd "hello world"
         2626  +  close $fd
         2627  +  sqlite3 db test.db
         2628  +  catchsql { CREATE TABLE t1(x) }
         2629  +} {1 {file is encrypted or is not a database}}
         2630  +do_test 38.2 {
         2631  +  catch { db close }
         2632  +  forcedelete test.db
         2633  +} {}
         2634  +
         2635  +do_test 39.1 {
         2636  +  sqlite3 db test.db
         2637  +  execsql {
         2638  +    PRAGMA auto_vacuum = 1;
         2639  +    CREATE TABLE t1(x);
         2640  +    INSERT INTO t1 VALUES('xxx');
         2641  +    INSERT INTO t1 VALUES('two');
         2642  +    INSERT INTO t1 VALUES(randomblob(400));
         2643  +    INSERT INTO t1 VALUES(randomblob(400));
         2644  +    INSERT INTO t1 VALUES(randomblob(400));
         2645  +    INSERT INTO t1 VALUES(randomblob(400));
         2646  +    BEGIN;
         2647  +    UPDATE t1 SET x = 'one' WHERE rowid=1;
         2648  +  }
         2649  +  set ::stmt [sqlite3_prepare db "SELECT * FROM t1 ORDER BY rowid" -1 dummy]
         2650  +  sqlite3_step $::stmt
         2651  +  sqlite3_column_text $::stmt 0
         2652  +} {one}
         2653  +do_test 39.2 {
         2654  +  execsql { CREATE TABLE t2(x) }
         2655  +  sqlite3_step $::stmt
         2656  +  sqlite3_column_text $::stmt 0
         2657  +} {two}
         2658  +do_test 39.3 {
         2659  +  sqlite3_finalize $::stmt
         2660  +  execsql COMMIT
         2661  +} {}
         2662  +
         2663  +do_execsql_test 39.4 {
         2664  +  PRAGMA auto_vacuum = 2;
         2665  +  CREATE TABLE t3(x);
         2666  +  CREATE TABLE t4(x);
         2667  +
         2668  +  DROP TABLE t2;
         2669  +  DROP TABLE t3;
         2670  +  DROP TABLE t4;
         2671  +}
         2672  +do_test 39.5 {
         2673  +  db close
         2674  +  sqlite3 db test.db
         2675  +  execsql {
         2676  +    PRAGMA cache_size = 1;
         2677  +    PRAGMA incremental_vacuum;
         2678  +    PRAGMA integrity_check;
         2679  +  }
         2680  +} {ok}
         2681  +
         2682  +do_test 40.1 {
         2683  +  reset_db
         2684  +  execsql {
         2685  +    PRAGMA auto_vacuum = 1;
         2686  +    CREATE TABLE t1(x PRIMARY KEY);
         2687  +    INSERT INTO t1 VALUES(randomblob(1200));
         2688  +    PRAGMA page_count;
         2689  +  }
         2690  +} {6}
         2691  +do_test 40.2 {
         2692  +  execsql {
         2693  +    INSERT INTO t1 VALUES(randomblob(1200));
         2694  +    INSERT INTO t1 VALUES(randomblob(1200));
         2695  +    INSERT INTO t1 VALUES(randomblob(1200));
         2696  +  }
         2697  +} {}
         2698  +do_test 40.3 {
         2699  +  db close
         2700  +  sqlite3 db test.db
         2701  +  execsql {
         2702  +    PRAGMA cache_size = 1;
         2703  +    CREATE TABLE t2(x);
         2704  +    PRAGMA integrity_check;
         2705  +  }
         2706  +} {ok}
         2707  +
         2708  +do_test 41.1 {
         2709  +  reset_db
         2710  +  execsql {
         2711  +    CREATE TABLE t1(x PRIMARY KEY);
         2712  +    INSERT INTO t1 VALUES(randomblob(200));
         2713  +    INSERT INTO t1 SELECT randomblob(200) FROM t1;
         2714  +    INSERT INTO t1 SELECT randomblob(200) FROM t1;
         2715  +    INSERT INTO t1 SELECT randomblob(200) FROM t1;
         2716  +    INSERT INTO t1 SELECT randomblob(200) FROM t1;
         2717  +    INSERT INTO t1 SELECT randomblob(200) FROM t1;
         2718  +    INSERT INTO t1 SELECT randomblob(200) FROM t1;
         2719  +  }
         2720  +} {}
         2721  +do_test 41.2 {
         2722  +  testvfs tv -default 1
         2723  +  tv sectorsize 16384;
         2724  +  tv devchar [list]
         2725  +  db close
         2726  +  sqlite3 db test.db
         2727  +  execsql {
         2728  +    PRAGMA cache_size = 1;
         2729  +    DELETE FROM t1 WHERE rowid%4;
         2730  +    PRAGMA integrity_check;
         2731  +  }
         2732  +} {ok}
         2733  +
  2525   2734   
  2526   2735   finish_test

Changes to test/pagerfault.test.

  1241   1241     flush $::channel
  1242   1242   } -test {
  1243   1243     catchsql { UPDATE t2 SET a = a_string(800), b = a_string(800) }
  1244   1244     catch { close $::channel }
  1245   1245     catchsql { ROLLBACK }
  1246   1246     faultsim_integrity_check
  1247   1247   }
         1248  +
  1248   1249   
  1249   1250   #-------------------------------------------------------------------------
  1250   1251   #
  1251   1252   do_test pagerfault-28-pre {
  1252   1253     faultsim_delete_and_reopen
  1253   1254     db func a_string a_string
  1254   1255     execsql {
................................................................................
  1275   1276       COMMIT;
  1276   1277       CREATE TABLE t1(a PRIMARY KEY, b);
  1277   1278     }
  1278   1279     expr {[file size test.db-shm] >= 96*1024}
  1279   1280   } {1}
  1280   1281   faultsim_save_and_close
  1281   1282   
  1282         -do_faultsim_test pagerfault-28 -faults oom* -prep {
         1283  +do_faultsim_test pagerfault-28a -faults oom* -prep {
  1283   1284     faultsim_restore_and_reopen
  1284   1285     execsql { PRAGMA mmap_limit=0 }
  1285   1286   
  1286   1287     sqlite3 db2 test.db
  1287   1288     db2 eval { SELECT count(*) FROM t2 }
  1288   1289   
  1289   1290     db func a_string a_string
................................................................................
  1298   1299     execsql { ROLLBACK }
  1299   1300   } -test {
  1300   1301     db2 close
  1301   1302     sqlite3_finalize $::STMT
  1302   1303     catchsql { ROLLBACK }
  1303   1304     faultsim_integrity_check
  1304   1305   }
         1306  +
         1307  +faultsim_restore_and_reopen
         1308  +sqlite3 db2 test.db
         1309  +db2 eval {SELECT count(*) FROM t2}
         1310  +db close
         1311  +
         1312  +do_faultsim_test pagerfault-28b -faults oom* -prep {
         1313  +  sqlite3 db test.db
         1314  +} -body {
         1315  +  execsql { SELECT count(*) FROM t2 }
         1316  +} -test {
         1317  +  faultsim_test_result {0 2048}
         1318  +  db close
         1319  +}
         1320  +
         1321  +db2 close
         1322  +
         1323  +#-------------------------------------------------------------------------
         1324  +# Try this:
         1325  +#
         1326  +#    1) Put the pager in ERROR state (error during rollback)
         1327  +#
         1328  +#    2) Next time the connection is used inject errors into all xWrite() and
         1329  +#       xUnlock() calls. This causes the hot-journal rollback to fail and
         1330  +#       the pager to declare its locking state UNKNOWN.
         1331  +#
         1332  +#    3) Same again.
         1333  +#
         1334  +#    4a) Stop injecting errors. Allow the rollback to succeed. Check that
         1335  +#        the database is Ok. Or, 
         1336  +#
         1337  +#    4b) Close and reopen the db. Check that the db is Ok.
         1338  +#
         1339  +proc custom_injectinstall {} {
         1340  +  testvfs custom -default true
         1341  +  custom filter {xWrite xUnlock}
         1342  +}
         1343  +proc custom_injectuninstall {} {
         1344  +  catch {db  close}
         1345  +  catch {db2 close}
         1346  +  custom delete
         1347  +}
         1348  +proc custom_injectstart {iFail} {
         1349  +  custom ioerr $iFail 1
         1350  +}
         1351  +proc custom_injectstop {} {
         1352  +  custom ioerr
         1353  +}
         1354  +set ::FAULTSIM(custom)          [list      \
         1355  +  -injectinstall   custom_injectinstall    \
         1356  +  -injectstart     custom_injectstart      \
         1357  +  -injectstop      custom_injectstop       \
         1358  +  -injecterrlist   {{1 {disk I/O error}}}  \
         1359  +  -injectuninstall custom_injectuninstall  \
         1360  +]
         1361  +
         1362  +do_test pagerfault-29-pre {
         1363  +  faultsim_delete_and_reopen
         1364  +  db func a_string a_string
         1365  +  execsql {
         1366  +    PRAGMA page_size = 1024;
         1367  +    PRAGMA cache_size = 5;
         1368  +
         1369  +    BEGIN;
         1370  +      CREATE TABLE t2(a UNIQUE, b UNIQUE);
         1371  +      INSERT INTO t2 VALUES( a_string(800), a_string(800) );
         1372  +      INSERT INTO t2 SELECT a_string(800), a_string(800) FROM t2;
         1373  +      INSERT INTO t2 SELECT a_string(800), a_string(800) FROM t2;
         1374  +      INSERT INTO t2 SELECT a_string(800), a_string(800) FROM t2;
         1375  +      INSERT INTO t2 SELECT a_string(800), a_string(800) FROM t2;
         1376  +    COMMIT;
         1377  +  }
         1378  +  expr {[file size test.db] >= 50*1024}
         1379  +} {1}
         1380  +faultsim_save_and_close
         1381  +foreach {tn tt} {
         1382  +  29 { catchsql ROLLBACK }
         1383  +  30 { db close ; sqlite3 db test.db }
         1384  +} {
         1385  +  do_faultsim_test pagerfault-$tn -faults custom -prep {
         1386  +    faultsim_restore_and_reopen
         1387  +      db func a_string a_string
         1388  +      execsql {
         1389  +        PRAGMA cache_size = 5;
         1390  +        BEGIN;
         1391  +        UPDATE t2 SET a = a_string(799);
         1392  +      }
         1393  +  } -body {
         1394  +    catchsql ROLLBACK
         1395  +    catchsql ROLLBACK
         1396  +    catchsql ROLLBACK
         1397  +  } -test {
         1398  +    eval $::tt
         1399  +    if {"ok" != [db one {PRAGMA integrity_check}]} {
         1400  +      error "integrity check failed"
         1401  +    }
         1402  +  }
         1403  +}
         1404  +
         1405  +do_test pagerfault-31-pre {
         1406  +  sqlite3_shutdown
         1407  +  sqlite3_config_uri 1
         1408  +} {SQLITE_OK}
         1409  +do_faultsim_test pagerfault-31 -faults oom* -body {
         1410  +  sqlite3 db {file:one?mode=memory&cache=shared}
         1411  +  db eval {
         1412  +    CREATE TABLE t1(x);
         1413  +    INSERT INTO t1 VALUES(1);
         1414  +    SELECT * FROM t1;
         1415  +  }
         1416  +} -test {
         1417  +  faultsim_test_result {0 1} {1 {}}
         1418  +  catch { db close }
         1419  +}
         1420  +sqlite3_shutdown
         1421  +sqlite3_config_uri 0
         1422  +
         1423  +do_test pagerfault-32-pre {
         1424  +  reset_db
         1425  +  execsql {
         1426  +    CREATE TABLE t1(x);
         1427  +    INSERT INTO t1 VALUES('one');
         1428  +  }
         1429  +} {}
         1430  +faultsim_save_and_close
         1431  +
         1432  +do_faultsim_test pagerfault-32 -prep {
         1433  +  faultsim_restore_and_reopen
         1434  +  db eval { SELECT * FROM t1; }
         1435  +} -body {
         1436  +  execsql { SELECT * FROM t1; }
         1437  +} -test {
         1438  +  faultsim_test_result {0 one}
         1439  +}
         1440  +sqlite3_shutdown
         1441  +sqlite3_config_uri 0
         1442  +
         1443  +do_faultsim_test pagerfault-33a -prep {
         1444  +  sqlite3 db :memory:
         1445  +  execsql {
         1446  +    CREATE TABLE t1(a, b);
         1447  +    INSERT INTO t1 VALUES(1, 2);
         1448  +  }
         1449  +} -body {
         1450  +  execsql { VACUUM }
         1451  +} -test {
         1452  +  faultsim_test_result {0 {}}
         1453  +} 
         1454  +do_faultsim_test pagerfault-33b -prep {
         1455  +  sqlite3 db ""
         1456  +  execsql {
         1457  +    CREATE TABLE t1(a, b);
         1458  +    INSERT INTO t1 VALUES(1, 2);
         1459  +  }
         1460  +} -body {
         1461  +  execsql { VACUUM }
         1462  +} -test {
         1463  +  faultsim_test_result {0 {}}
         1464  +} 
         1465  +
         1466  +do_test pagerfault-34-pre {
         1467  +  reset_db
         1468  +  execsql {
         1469  +    CREATE TABLE t1(x PRIMARY KEY);
         1470  +  }
         1471  +} {}
         1472  +faultsim_save_and_close
         1473  +do_faultsim_test pagerfault-34 -prep {
         1474  +  faultsim_restore_and_reopen
         1475  +  execsql {
         1476  +    BEGIN;
         1477  +      INSERT INTO t1 VALUES( randomblob(4000) );
         1478  +      DELETE FROM t1;
         1479  +  }
         1480  +} -body {
         1481  +  execsql COMMIT
         1482  +} -test {
         1483  +  faultsim_test_result {0 {}}
         1484  +} 
         1485  +
  1305   1486   
  1306   1487   finish_test
  1307   1488   

Changes to test/wal.test.

  1564   1564     # WAL file now contains a single frame - the new root page for table t1.
  1565   1565     # It would be two frames (the new root page and a padding frame) if the
  1566   1566     # ZERO_DAMAGE flag were not set.
  1567   1567     do_test 24.5 {
  1568   1568       file size test.db-wal
  1569   1569     } [wal_file_size 1 1024]
  1570   1570   }
  1571         -
  1572         -reset_db
  1573         -do_test 25 {
  1574         -  sqlite3 db test.db
  1575         -
  1576         -  execsql {
  1577         -    CREATE TABLE t1(x, y);
  1578         -    PRAGMA journal_mode = WAL;
  1579         -    INSERT INTO t1 VALUES(1, 2);
  1580         -  }
  1581         -
  1582         -  execsql {
  1583         -    BEGIN;
  1584         -      CREATE TABLE t2(a, b);
  1585         -  }
  1586         -
  1587         -  hexio_write test.db-shm [expr 16*1024] [string repeat 0055 8192]
  1588         -  catchsql ROLLBACK
  1589         -} {0 {}}
  1590         -
  1591   1571   
  1592   1572   db close
  1593   1573   sqlite3_shutdown
  1594   1574   test_sqlite3_log
  1595   1575   sqlite3_initialize
  1596   1576   
  1597   1577   finish_test

Changes to test/walfault.test.

   544    544     }
   545    545   } -test {
   546    546     faultsim_test_result {0 {0 9 9}}
   547    547     faultsim_integrity_check
   548    548     set nRow [db eval {SELECT count(*) FROM abc}]
   549    549     if {!(($nRow==2 && $testrc) || $nRow==3)} { error "Bad db content" }
   550    550   }
   551         -finish_test
          551  +
          552  +#-------------------------------------------------------------------------
          553  +# Test fault-handling when switching out of exclusive-locking mode.
          554  +#
          555  +do_test walfault-14-pre {
          556  +  faultsim_delete_and_reopen
          557  +  execsql {
          558  +    PRAGMA auto_vacuum = 0;
          559  +    PRAGMA journal_mode = WAL;
          560  +    BEGIN;
          561  +      CREATE TABLE abc(a PRIMARY KEY);
          562  +      INSERT INTO abc VALUES(randomblob(1500));
          563  +      INSERT INTO abc VALUES(randomblob(1500));
          564  +    COMMIT;
          565  +  }
          566  +  faultsim_save_and_close
          567  +} {}
          568  +do_faultsim_test walfault-14 -prep {
          569  +  faultsim_restore_and_reopen
          570  +  breakpoint
          571  +  execsql {
          572  +    SELECT count(*) FROM abc;
          573  +    PRAGMA locking_mode = exclusive;
          574  +    BEGIN;
          575  +      INSERT INTO abc VALUES(randomblob(1500));
          576  +    COMMIT;
          577  +  }
          578  +} -body {
          579  +  db eval { 
          580  +    PRAGMA locking_mode = normal;
          581  +    BEGIN;
          582  +      INSERT INTO abc VALUES(randomblob(1500));
          583  +    COMMIT;
          584  +  }
          585  +} -test {
          586  +  faultsim_integrity_check
          587  +  set nRow [db eval {SELECT count(*) FROM abc}]
          588  +  if {$nRow!=3 && $nRow!=4} { error "Bad db content" }
          589  +}
   552    590   
   553    591   finish_test