/ Check-in [c3ab1a7e]
Login

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

Overview
Comment:Add a new I/O error test: ioerr4. (CVS 5097)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:c3ab1a7e2e40eb8f51f1b11bf0591e251d69882b
User & Date: drh 2008-05-07 13:28:38
Context
2008-05-07
14:49
If an error occurs within xAccess(), it should return -1. Remove an assert() that was preventing it from doing so. (CVS 5098) check-in: 3fbcef46 user: danielk1977 tags: trunk
13:28
Add a new I/O error test: ioerr4. (CVS 5097) check-in: c3ab1a7e user: drh tags: trunk
12:45
Fix a null-pointer dereference that can occur following a DISKFULL error while running VACUUM. (CVS 5096) check-in: 438d77a7 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Added test/ioerr4.test.

            1  +# 2007 December 19
            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 for correct handling of I/O errors
           13  +# during incremental vacuum with a shared cache.
           14  +#
           15  +# $Id: ioerr4.test,v 1.1 2008/05/07 13:28:38 drh Exp $
           16  +
           17  +set testdir [file dirname $argv0]
           18  +source $testdir/tester.tcl
           19  +
           20  +# This test requires both shared cache and incremental vacuum.
           21  +#
           22  +ifcapable {!shared_cache || !autovacuum} {
           23  +  finish_test
           24  +  return
           25  +}
           26  +
           27  +# Enable shared cache mode and incremental vacuum.
           28  +#
           29  +do_test ioerr4-1.1 {
           30  +  db close
           31  +  sqlite3_enable_shared_cache 1
           32  +} {0}
           33  +do_test ioerr4-1.2 {
           34  +  file delete -force test.db test.db-journal
           35  +  sqlite3 db test.db
           36  +  sqlite3 db2 test.db
           37  +  db eval {
           38  +    PRAGMA auto_vacuum=INCREMENTAL;
           39  +    CREATE TABLE a(i INTEGER, b BLOB);
           40  +  }
           41  +  db2 eval {
           42  +    SELECT name FROM sqlite_master
           43  +  }
           44  +} {a}
           45  +do_test ioerr4-1.3 {
           46  +  db eval {
           47  +    PRAGMA auto_vacuum;
           48  +  }
           49  +} {2}
           50  +
           51  +# Insert and delete many records in order to put lots of pages
           52  +# on the freelist.
           53  +#
           54  +do_test ioerr4-1.4 {
           55  +  db eval {
           56  +    INSERT INTO a VALUES(1, zeroblob(2000));
           57  +    INSERT INTO a VALUES(2, zeroblob(2000));
           58  +    INSERT INTO a SELECT i+2, zeroblob(2000) FROM a;
           59  +    INSERT INTO a SELECT i+4, zeroblob(2000) FROM a;
           60  +    INSERT INTO a SELECT i+8, zeroblob(2000) FROM a;
           61  +    INSERT INTO a SELECT i+16, zeroblob(2000) FROM a;
           62  +    SELECT count(*) FROM a;
           63  +  }
           64  +} {32}
           65  +do_test ioerr4-1.5 {
           66  +  db eval {
           67  +    PRAGMA freelist_count
           68  +  }
           69  +} {0}
           70  +do_test ioerr4-1.6 {
           71  +  db eval {
           72  +    DELETE FROM a;
           73  +    PRAGMA freelist_count;
           74  +  }
           75  +} {64}
           76  +
           77  +# Set up for an I/O error on incremental vacuum
           78  +# with two connections on shared cache.
           79  +#
           80  +db close
           81  +db2 close
           82  +file copy -force test.db test.db-bu
           83  +do_ioerr_test ioerr4-2 -tclprep {
           84  +  catch {db2 close}
           85  +  db close
           86  +  file delete -force test.db test.db-journal
           87  +  file copy -force test.db-bu test.db
           88  +  sqlite3_enable_shared_cache 1
           89  +  set ::DB [sqlite3 db test.db; sqlite3_connection_pointer db]
           90  +  db eval {PRAGMA auto_vacuum=INCREMENTAL}
           91  +  sqlite3 db2 test.db
           92  +} -tclbody {
           93  +  db eval {PRAGMA incremental_vacuum(5)}
           94  +}
           95  +
           96  +finish_test