/ Check-in [3873941c]
Login

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

Overview
Comment:Add a few more test cases to walfault2.test and walvfs.test.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 3873941c4fb9aa2d0de1129722c5fcdf2be1ea261677d4841ed99f896c778459
User & Date: dan 2018-12-24 20:00:27
Context
2018-12-25
11:17
Fix a typo in a comment that is used to generate session documentation. check-in: a1f50d57 user: drh tags: trunk
2018-12-24
20:00
Add a few more test cases to walfault2.test and walvfs.test. check-in: 3873941c user: dan tags: trunk
19:59
Change another fts5 assert() that may fail with a corrupt database to an assert_nc(). check-in: d9653380 user: dan tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to test/permutations.test.

   433    433     wal.test wal2.test wal3.test wal4.test wal5.test
   434    434     wal64k.test wal6.test wal7.test wal8.test wal9.test
   435    435     walbak.test walbig.test walblock.test walcksum.test walcrash2.test
   436    436     walcrash3.test walcrash4.test walcrash.test walfault.test walhook.test
   437    437     walmode.test walnoshm.test waloverwrite.test walpersist.test 
   438    438     walprotocol2.test walprotocol.test walro2.test walrofault.test 
   439    439     walro.test walshared.test walslow.test walvfs.test
          440  +  walfault2.test
   440    441   
   441    442     nockpt.test
   442    443   } 
   443    444   
   444    445   test_suite "coverage-pager" -description {
   445    446     Coverage tests for file pager.c.
   446    447   } -files {

Added test/walfault2.test.

            1  +# 2010 May 03
            2  +#
            3  +# The author disclaims copyright to this source code.  In place of
            4  +# a legal notice, here is a blessing:
            5  +#
            6  +#    May you do good and not evil.
            7  +#    May you find forgiveness for yourself and forgive others.
            8  +#    May you share freely, never taking more than you give.
            9  +#
           10  +#***********************************************************************
           11  +# This file implements regression tests for SQLite library.  The
           12  +# focus of this file is testing the operation of the library in
           13  +# "PRAGMA journal_mode=WAL" mode.
           14  +#
           15  +
           16  +set testdir [file dirname $argv0]
           17  +source $testdir/tester.tcl
           18  +source $testdir/malloc_common.tcl
           19  +source $testdir/lock_common.tcl
           20  +
           21  +ifcapable !wal {finish_test ; return }
           22  +set testprefix walfault2
           23  +
           24  +#-------------------------------------------------------------------------
           25  +# Inject faults while truncating the wal file.
           26  +#
           27  +do_execsql_test 1.0 {
           28  +  PRAGMA auto_vacuum = 0;
           29  +  CREATE TABLE t1(a, b);
           30  +  PRAGMA journal_mode = wal;
           31  +  WITH s(i) AS (
           32  +    SELECT 1 UNION ALL SELECT i+1 FROM s LIMIT 30
           33  +  )
           34  +  INSERT INTO t1 SELECT randomblob(400), randomblob(400) FROM s;
           35  +} {wal}
           36  +faultsim_save_and_close
           37  +
           38  +do_faultsim_test 1 -prep {
           39  +  faultsim_restore
           40  +  sqlite3 db file:test.db?psow=0 -uri 1
           41  +  file_control_powersafe_overwrite db 0
           42  +  execsql {
           43  +    PRAGMA wal_checkpoint;
           44  +    PRAGMA journal_size_limit = 10000;
           45  +    PRAGMA synchronous = full;
           46  +  }
           47  +} -body {
           48  +  execsql { INSERT INTO t1 VALUES(1,1) }
           49  +} -test {
           50  +  faultsim_test_result {0 {}}
           51  +}
           52  +
           53  +#-------------------------------------------------------------------------
           54  +# Inject faults while rewriting checksums.
           55  +#
           56  +reset_db
           57  +do_execsql_test 2.0 {
           58  +  PRAGMA auto_vacuum = 0;
           59  +  CREATE TABLE t1(a, b);
           60  +  PRAGMA journal_mode = wal;
           61  +  WITH s(i) AS (
           62  +    SELECT 1 UNION ALL SELECT i+1 FROM s LIMIT 30
           63  +  )
           64  +  INSERT INTO t1 SELECT randomblob(400), randomblob(400) FROM s;
           65  +} {wal}
           66  +faultsim_save_and_close
           67  +
           68  +do_faultsim_test 2 -prep {
           69  +  faultsim_restore_and_reopen
           70  +  execsql {
           71  +    PRAGMA cache_size = 2;
           72  +    BEGIN;
           73  +    UPDATE t1 SET a=randomblob(400);
           74  +    UPDATE t1 SET b=randomblob(400);
           75  +    UPDATE t1 SET a=randomblob(400);
           76  +    UPDATE t1 SET b=randomblob(400);
           77  +    UPDATE t1 SET a=randomblob(400);
           78  +    UPDATE t1 SET b=randomblob(400);
           79  +    UPDATE t1 SET a=randomblob(400);
           80  +    UPDATE t1 SET b=randomblob(400);
           81  +  }
           82  +} -body {
           83  +  execsql COMMIT
           84  +} -test {
           85  +  faultsim_test_result {0 {}}
           86  +}
           87  +
           88  +
           89  +
           90  +finish_test

Changes to test/walvfs.test.

   233    233   do_test 5.4 {
   234    234     vfs_set_readmark db main 1 100
   235    235     execsql { SELECT count(*) FROM t1 }
   236    236   } {20}
   237    237   
   238    238   #-------------------------------------------------------------------------
   239    239   # Cause an SQLITE_PROTOCOL while attempting to restart the wal file.
          240  +#
   240    241   reset_db
   241    242   tvfs filter {}
   242    243   db close
   243    244   sqlite3 db test.db -vfs tvfs
   244    245   do_execsql_test 6.0 {
   245    246     PRAGMA auto_vacuum = 0;
   246    247     PRAGMA page_size = 1024;
................................................................................
   269    270     return SQLITE_OK
   270    271   }
   271    272   
   272    273   puts "# WARNING: This next test takes around 12 seconds"
   273    274   do_catchsql_test 6.2 {
   274    275     INSERT INTO t1 VALUES(1);
   275    276   } {1 {locking protocol}}
          277  +
          278  +#-------------------------------------------------------------------------
          279  +# Check that a checkpoint fails if it cannot get the CHECKPOINTER lock
          280  +#
          281  +reset_db
          282  +tvfs filter {}
          283  +db close
          284  +sqlite3 db test.db -vfs tvfs
          285  +do_execsql_test 7.0 {
          286  +  PRAGMA auto_vacuum = 0;
          287  +  PRAGMA page_size = 1024;
          288  +  CREATE TABLE t1(x);
          289  +  PRAGMA journal_mode = wal;
          290  +  WITH s(i) AS (
          291  +      SELECT 1 UNION ALL SELECT i+1 FROM s LIMIT 20
          292  +  )
          293  +  INSERT INTO t1 SELECT randomblob(750) FROM s;
          294  +} {wal}
          295  +
          296  +tvfs script xShmLock
          297  +tvfs filter xShmLock
          298  +proc xShmLock {method file handle spec} {
          299  +  if {$spec=="1 1 lock exclusive"} {
          300  +    return SQLITE_BUSY
          301  +  }
          302  +  return SQLITE_OK
          303  +}
          304  +
          305  +do_execsql_test 7.1 {
          306  +  PRAGMA wal_checkpoint
          307  +} {1 -1 -1}
   276    308   
   277    309   db close
   278    310   tvfs delete
   279    311   finish_test
   280    312