/ Check-in [07a0e4e9]
Login

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

Overview
Comment:Add tests to "permutations.test coverage-pager" to cover uncovered branches.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 07a0e4e9820a85bf1690214fef3577866c763f92
User & Date: dan 2013-04-06 11:03:09
Context
2013-04-06
18:06
Increase the default SQLITE_MAX_SCHEMA_RETRY to 50. Make sure that macro covers every case where a prepared statement might need to be reprepared due to a schema change. The sqlite3_exec() interface now uses sqlite3_prepare_v2(). check-in: c1d7304c user: drh tags: trunk
11:03
Add tests to "permutations.test coverage-pager" to cover uncovered branches. check-in: 07a0e4e9 user: dan tags: trunk
2013-04-05
20:40
Improve the code coverage of "permutations.test coverage-pager". check-in: b095e2cd user: dan tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to test/pager1.test.

  2241   2241         SAVEPOINT abc;
  2242   2242           CREATE TABLE t1(a, b);
  2243   2243         ROLLBACK TO abc;
  2244   2244       COMMIT;
  2245   2245     }
  2246   2246     db close
  2247   2247   } {}
  2248         -breakpoint
  2249   2248   do_test pager1-25-2 {
  2250   2249     faultsim_delete_and_reopen
  2251   2250     execsql {
  2252   2251       SAVEPOINT abc;
  2253   2252         CREATE TABLE t1(a, b);
  2254   2253       ROLLBACK TO abc;
  2255   2254       COMMIT;
................................................................................
  2539   2538     reset_db
  2540   2539     db func a_string a_string
  2541   2540     db eval $pragma
  2542   2541     do_execsql_test 34.$tn.1 {
  2543   2542       CREATE TABLE t1(a, b);
  2544   2543       INSERT INTO t1 VALUES(1, 2);
  2545   2544     }
  2546         -  breakpoint
  2547   2545     do_execsql_test 34.$tn.2 {
  2548   2546       BEGIN;
  2549   2547       INSERT INTO t1 VALUES(2, a_string($strsize));
  2550   2548       DELETE FROM t1 WHERE oid=2;
  2551   2549       COMMIT;
  2552   2550       PRAGMA integrity_check;
  2553   2551     } {ok}
................................................................................
  2601   2599     2   {file:one?mode=memory&cache=shared}
  2602   2600     3   {file:test1?cache=shared}
  2603   2601     4   {file:test2?another=parameter&yet=anotherone}
  2604   2602   } {
  2605   2603     do_test 37.$tn {
  2606   2604       catch { db close }
  2607   2605       sqlite3_shutdown
  2608         -      sqlite3_config_uri 1
  2609         -      sqlite3 db $uri
         2606  +    sqlite3_config_uri 1
         2607  +    sqlite3 db $uri
         2608  +
  2610   2609       db eval {
  2611   2610         CREATE TABLE t1(x);
  2612   2611         INSERT INTO t1 VALUES(1);
  2613   2612         SELECT * FROM t1;
  2614   2613       }
  2615   2614     } {1}
         2615  +
         2616  +  do_execsql_test 37.$tn.2 {
         2617  +    VACUUM;
         2618  +    SELECT * FROM t1;
         2619  +  } {1}
         2620  +
  2616   2621     db close
  2617   2622     sqlite3_shutdown
  2618   2623     sqlite3_config_uri 0
  2619   2624   }
  2620   2625   
  2621   2626   do_test 38.1 {
  2622   2627     catch { db close }
................................................................................
  2726   2731     sqlite3 db test.db
  2727   2732     execsql {
  2728   2733       PRAGMA cache_size = 1;
  2729   2734       DELETE FROM t1 WHERE rowid%4;
  2730   2735       PRAGMA integrity_check;
  2731   2736     }
  2732   2737   } {ok}
         2738  +db close
         2739  +tv delete
         2740  +
         2741  +set pending_prev [sqlite3_test_control_pending_byte 0x1000000]
         2742  +do_test 42.1 {
         2743  +  reset_db
         2744  +  execsql {
         2745  +    CREATE TABLE t1(x, y);
         2746  +    INSERT INTO t1 VALUES(randomblob(200), randomblob(200));
         2747  +    INSERT INTO t1 SELECT randomblob(200), randomblob(200) FROM t1;
         2748  +    INSERT INTO t1 SELECT randomblob(200), randomblob(200) FROM t1;
         2749  +    INSERT INTO t1 SELECT randomblob(200), randomblob(200) FROM t1;
         2750  +    INSERT INTO t1 SELECT randomblob(200), randomblob(200) FROM t1;
         2751  +    INSERT INTO t1 SELECT randomblob(200), randomblob(200) FROM t1;
         2752  +    INSERT INTO t1 SELECT randomblob(200), randomblob(200) FROM t1;
         2753  +    INSERT INTO t1 SELECT randomblob(200), randomblob(200) FROM t1;
         2754  +    INSERT INTO t1 SELECT randomblob(200), randomblob(200) FROM t1;
         2755  +    INSERT INTO t1 SELECT randomblob(200), randomblob(200) FROM t1;
         2756  +  }
         2757  +  db close
         2758  +  sqlite3_test_control_pending_byte 0x0010000
         2759  +  sqlite3 db test.db
         2760  +  db eval { PRAGMA mmap_limit = 0 }
         2761  +  catchsql { SELECT sum(length(y)) FROM t1 }
         2762  +} {1 {database disk image is malformed}}
         2763  +do_test 42.2 {
         2764  +  reset_db
         2765  +  execsql {
         2766  +    CREATE TABLE t1(x, y);
         2767  +    INSERT INTO t1 VALUES(randomblob(200), randomblob(200));
         2768  +    INSERT INTO t1 SELECT randomblob(200), randomblob(200) FROM t1;
         2769  +    INSERT INTO t1 SELECT randomblob(200), randomblob(200) FROM t1;
         2770  +    INSERT INTO t1 SELECT randomblob(200), randomblob(200) FROM t1;
         2771  +    INSERT INTO t1 SELECT randomblob(200), randomblob(200) FROM t1;
         2772  +    INSERT INTO t1 SELECT randomblob(200), randomblob(200) FROM t1;
         2773  +    INSERT INTO t1 SELECT randomblob(200), randomblob(200) FROM t1;
         2774  +    INSERT INTO t1 SELECT randomblob(200), randomblob(200) FROM t1;
         2775  +    INSERT INTO t1 SELECT randomblob(200), randomblob(200) FROM t1;
         2776  +  }
         2777  +  db close
         2778  +
         2779  +  testvfs tv -default 1
         2780  +  tv sectorsize 16384;
         2781  +  tv devchar [list]
         2782  +  sqlite3 db test.db -vfs tv
         2783  +  execsql { UPDATE t1 SET x = randomblob(200) }
         2784  +} {}
         2785  +db close
         2786  +tv delete
         2787  +sqlite3_test_control_pending_byte $pending_prev
         2788  +
         2789  +do_test 43.1 {
         2790  +  reset_db
         2791  +  execsql {
         2792  +    CREATE TABLE t1(x, y);
         2793  +    INSERT INTO t1 VALUES(1, 2);
         2794  +    CREATE TABLE t2(x, y);
         2795  +    INSERT INTO t2 VALUES(1, 2);
         2796  +    CREATE TABLE t3(x, y);
         2797  +    INSERT INTO t3 VALUES(1, 2);
         2798  +  }
         2799  +  db close
         2800  +  sqlite3 db test.db
         2801  +
         2802  +  db eval { PRAGMA mmap_limit = 0 }
         2803  +  db eval { SELECT * FROM t1 }
         2804  +  sqlite3_db_status db CACHE_MISS 0
         2805  +} {0 2 0}
         2806  +
         2807  +do_test 43.2 {
         2808  +  db eval { SELECT * FROM t2 }
         2809  +  sqlite3_db_status db CACHE_MISS 1
         2810  +} {0 3 0}
  2733   2811   
         2812  +do_test 43.3 {
         2813  +  db eval { SELECT * FROM t3 }
         2814  +  sqlite3_db_status db CACHE_MISS 0
         2815  +} {0 1 0}
  2734   2816   
  2735   2817   finish_test
         2818  +

Changes to test/pager2.test.

   114    114     }
   115    115   }
   116    116   db close
   117    117   tv delete
   118    118   
   119    119   
   120    120   #-------------------------------------------------------------------------
   121         -#
   122    121   # pager2-2.1: Test a ROLLBACK with journal_mode=off.
   123    122   # pager2-2.2: Test shrinking the database (auto-vacuum) with 
   124    123   #             journal_mode=off
   125    124   #
   126    125   do_test pager2-2.1 {
   127    126     faultsim_delete_and_reopen
   128    127     execsql {
................................................................................
   143    142       CREATE TABLE t1(a, b);
   144    143       INSERT INTO t1 VALUES(zeroblob(5000), zeroblob(5000));
   145    144       DELETE FROM t1;
   146    145       PRAGMA incremental_vacuum;
   147    146     }
   148    147     file size test.db
   149    148   } {3072}
          149  +
          150  +#-------------------------------------------------------------------------
          151  +# Test that shared in-memory databases seem to work.
          152  +#
          153  +db close
          154  +do_test pager2-3.1 {
          155  +  forcedelete test.db
          156  +  sqlite3_shutdown
          157  +  sqlite3_config_uri 1
          158  +
          159  +  sqlite3 db1 {file:test.db?mode=memory&cache=shared}
          160  +  sqlite3 db2 {file:test.db?mode=memory&cache=shared}
          161  +  sqlite3 db3 test.db
          162  +
          163  +  db1 eval { CREATE TABLE t1(a, b) }
          164  +  db2 eval { INSERT INTO t1 VALUES(1, 2) }
          165  +  list [catch { db3 eval { INSERT INTO t1 VALUES(3, 4) } } msg] $msg
          166  +} {1 {no such table: t1}}
   150    167   
   151    168   finish_test

Changes to test/pagerfault.test.

  1479   1479     }
  1480   1480   } -body {
  1481   1481     execsql COMMIT
  1482   1482   } -test {
  1483   1483     faultsim_test_result {0 {}}
  1484   1484   } 
  1485   1485   
         1486  +do_test pagerfault-35-pre {
         1487  +  faultsim_delete_and_reopen
         1488  +  execsql {
         1489  +    CREATE TABLE t1(x PRIMARY KEY, y);
         1490  +    INSERT INTO t1 VALUES(randomblob(200), randomblob(200));
         1491  +    INSERT INTO t1 SELECT randomblob(200), randomblob(200) FROM t1;
         1492  +    INSERT INTO t1 SELECT randomblob(200), randomblob(200) FROM t1;
         1493  +    INSERT INTO t1 SELECT randomblob(200), randomblob(200) FROM t1;
         1494  +  }
         1495  +  faultsim_save_and_close
         1496  +} {}
         1497  +testvfs tv -default 1
         1498  +tv sectorsize 8192;
         1499  +tv devchar [list]
         1500  +do_faultsim_test pagerfault-35 -prep {
         1501  +  faultsim_restore_and_reopen
         1502  +} -body {
         1503  +  execsql { UPDATE t1 SET x=randomblob(200) }
         1504  +} -test {
         1505  +  faultsim_test_result {0 {}}
         1506  +}
         1507  +catch {db close}
         1508  +tv delete
         1509  +
         1510  +sqlite3_shutdown
         1511  +sqlite3_config_uri 1
         1512  +do_test pagerfault-36-pre {
         1513  +  faultsim_delete_and_reopen
         1514  +  execsql {
         1515  +    CREATE TABLE t1(x PRIMARY KEY, y);
         1516  +    INSERT INTO t1 VALUES(randomblob(200), randomblob(200));
         1517  +    INSERT INTO t1 SELECT randomblob(200), randomblob(200) FROM t1;
         1518  +    INSERT INTO t1 SELECT randomblob(200), randomblob(200) FROM t1;
         1519  +    INSERT INTO t1 SELECT randomblob(200), randomblob(200) FROM t1;
         1520  +  }
         1521  +  faultsim_save_and_close
         1522  +} {}
         1523  +do_faultsim_test pagerfault-36 -prep {
         1524  +  faultsim_restore
         1525  +  sqlite3 db file:test.db?cache=shared
         1526  +  sqlite3 db2 file:test.db?cache=shared
         1527  +  db2 eval {
         1528  +    BEGIN;
         1529  +    SELECT count(*) FROM sqlite_master;
         1530  +  }
         1531  +  db eval {
         1532  +    PRAGMA cache_size = 1;
         1533  +    BEGIN;
         1534  +      UPDATE t1 SET x = randomblob(200);
         1535  +  }
         1536  +} -body {
         1537  +  execsql ROLLBACK db
         1538  +} -test {
         1539  +  catch { db eval {UPDATE t1 SET x = randomblob(200)} }
         1540  +  faultsim_test_result {0 {}}
         1541  +  catch { db close }
         1542  +  catch { db2 close }
         1543  +}
         1544  +
         1545  +sqlite3_shutdown
         1546  +sqlite3_config_uri 0
  1486   1547   
  1487   1548   finish_test
  1488   1549