/ Check-in [08334f60]
Login

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

Overview
Comment:Extra coverage tests for btree.c. (CVS 5365)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 08334f60303e63b581fa7f1f00d3e8833f1710ca
User & Date: danielk1977 2008-07-08 12:07:33
Context
2008-07-08
14:17
Fix a compilation bug with SQLITE_OMIT_AUTOINIT. (CVS 5366) check-in: 94c95fad user: danielk1977 tags: trunk
12:07
Extra coverage tests for btree.c. (CVS 5365) check-in: 08334f60 user: danielk1977 tags: trunk
12:02
Make sqlite3_shutdown() a no-op if the library is not initialized. (CVS 5364) check-in: d725d3bb user: danielk1977 tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to test/corrupt2.test.

9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
...
309
310
311
312
313
314
315





















316
317
318
319
#
#***********************************************************************
# This file implements regression tests for SQLite library.
#
# This file implements tests to make sure SQLite does not crash or
# segfault if it sees a corrupt database file.
#
# $Id: corrupt2.test,v 1.9 2008/07/08 10:19:58 danielk1977 Exp $

set testdir [file dirname $argv0]
source $testdir/tester.tcl

# The following tests - corrupt2-1.* - create some databases corrupted in
# specific ways and ensure that SQLite detects them as corrupt.
#
................................................................................
    set nPage [expr [file size corrupt.db] / 1024]
    hexio_write corrupt.db [expr 1024 + ($nPage-3)*5] 010000000
  } -test {
    do_test corrupt2-6.3 {
      catchsql { pragma incremental_vacuum = 1 }
    } {1 {database disk image is malformed}}
  }






















}

finish_test







|







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>




9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
...
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
#
#***********************************************************************
# This file implements regression tests for SQLite library.
#
# This file implements tests to make sure SQLite does not crash or
# segfault if it sees a corrupt database file.
#
# $Id: corrupt2.test,v 1.10 2008/07/08 12:07:33 danielk1977 Exp $

set testdir [file dirname $argv0]
source $testdir/tester.tcl

# The following tests - corrupt2-1.* - create some databases corrupted in
# specific ways and ensure that SQLite detects them as corrupt.
#
................................................................................
    set nPage [expr [file size corrupt.db] / 1024]
    hexio_write corrupt.db [expr 1024 + ($nPage-3)*5] 010000000
  } -test {
    do_test corrupt2-6.3 {
      catchsql { pragma incremental_vacuum = 1 }
    } {1 {database disk image is malformed}}
  }

  corruption_test -sqlprep {
    PRAGMA auto_vacuum = 1;
    PRAGMA page_size = 1024;
    CREATE TABLE t1(a INTEGER PRIMARY KEY, b);
    INSERT INTO t1 VALUES(1, randomblob(2500));
    DELETE FROM t1 WHERE a = 1;
  } -corrupt {
    set nAppend [expr 1024*207 - [file size corrupt.db]]
    set fd [open corrupt.db r+]
    seek $fd 0 end
    puts -nonewline $fd [string repeat x $nAppend]
    close $fd
  } -test {
    do_test corrupt2-6.4 {
      catchsql { 
        BEGIN EXCLUSIVE;
        COMMIT;
      }
    } {1 {database disk image is malformed}}
  }

}

finish_test

Changes to test/incrblob_err.test.

5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
..
96
97
98
99
100
101
102
103






























104
#
#    May you do good and not evil.
#    May you find forgiveness for yourself and forgive others.
#    May you share freely, never taking more than you give.
#
#***********************************************************************
#
# $Id: incrblob_err.test,v 1.10 2008/06/25 14:31:53 drh Exp $
#

set testdir [file dirname $argv0]
source $testdir/tester.tcl

ifcapable {!incrblob  || !memdebug || !tclvar} {
  finish_test
................................................................................
  INSERT INTO blobs VALUES(1, $::data || $::data || $::data);
} -tclbody {
  set ::blob [db incrblob blobs v 1]
  seek $::blob -20 end
  puts -nonewline $::blob "12345678900987654321"
  close $::blob
}































finish_test







|







 








>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>

5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
..
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
#
#    May you do good and not evil.
#    May you find forgiveness for yourself and forgive others.
#    May you share freely, never taking more than you give.
#
#***********************************************************************
#
# $Id: incrblob_err.test,v 1.11 2008/07/08 12:07:33 danielk1977 Exp $
#

set testdir [file dirname $argv0]
source $testdir/tester.tcl

ifcapable {!incrblob  || !memdebug || !tclvar} {
  finish_test
................................................................................
  INSERT INTO blobs VALUES(1, $::data || $::data || $::data);
} -tclbody {
  set ::blob [db incrblob blobs v 1]
  seek $::blob -20 end
  puts -nonewline $::blob "12345678900987654321"
  close $::blob
}

do_ioerr_test incrblob_err-7 -cksum 1 -sqlprep {
  PRAGMA auto_vacuum = 1;
  CREATE TABLE blobs(k INTEGER PRIMARY KEY, v BLOB);
  INSERT INTO blobs VALUES(1, zeroblob(500 * 1020));
} -tclbody {
  # Read some data from the end of the large blob inserted into table 
  # "blobs". This forces the IO error to occur while reading a pointer
  # map page for the purposes of seeking to the end of the blob.
  #
  sqlite3 db2 test.db
  set ::blob [db2 incrblob blobs v 1]
  sqlite3_blob_read $::blob [expr 500*1020-20] 20
  close $::blob
}

do_ioerr_test incrblob_err-8 -cksum 1 -sqlprep {
  PRAGMA auto_vacuum = 1;
  CREATE TABLE blobs(k INTEGER PRIMARY KEY, v BLOB);
  INSERT INTO blobs VALUES(1, zeroblob(500 * 1020));
} -tclbody {
  # Read some data from the end of the large blob inserted into table 
  # "blobs". This forces the IO error to occur while reading a pointer
  # map page for the purposes of seeking to the end of the blob.
  #
  sqlite3 db2 test.db
  set ::blob [db2 incrblob blobs v 1]
  sqlite3_blob_write $::blob [expr 500*1020-20] 12345678900987654321
  close $::blob
}

finish_test

Changes to test/tester.tcl.

7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
...
786
787
788
789
790
791
792

793
794
795
796
797
798
799
#    May you find forgiveness for yourself and forgive others.
#    May you share freely, never taking more than you give.
#
#***********************************************************************
# This file implements some common TCL routines used for regression
# testing the SQLite library
#
# $Id: tester.tcl,v 1.128 2008/06/23 18:49:45 danielk1977 Exp $

#
# What for user input before continuing.  This gives an opportunity
# to connect profiling tools to the process.
#
for {set i 0} {$i<[llength $argv]} {incr i} {
  if {[regexp {^-+pause$} [lindex $argv $i] all value]} {
................................................................................

    # If an IO error occured, then the checksum of the database should
    # be the same as before the script that caused the IO error was run.
    #
    if {$::go && $::sqlite_io_error_hardhit && $::ioerropts(-cksum)} {
      do_test $testname.$n.6 {
        catch {db close}

        set ::DB [sqlite3 db test.db; sqlite3_connection_pointer db]
        cksum
      } $checksum
    }

    set ::sqlite_io_error_hardhit 0
    set ::sqlite_io_error_pending 0







|







 







>







7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
...
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
#    May you find forgiveness for yourself and forgive others.
#    May you share freely, never taking more than you give.
#
#***********************************************************************
# This file implements some common TCL routines used for regression
# testing the SQLite library
#
# $Id: tester.tcl,v 1.129 2008/07/08 12:07:33 danielk1977 Exp $

#
# What for user input before continuing.  This gives an opportunity
# to connect profiling tools to the process.
#
for {set i 0} {$i<[llength $argv]} {incr i} {
  if {[regexp {^-+pause$} [lindex $argv $i] all value]} {
................................................................................

    # If an IO error occured, then the checksum of the database should
    # be the same as before the script that caused the IO error was run.
    #
    if {$::go && $::sqlite_io_error_hardhit && $::ioerropts(-cksum)} {
      do_test $testname.$n.6 {
        catch {db close}
        catch {db2 close}
        set ::DB [sqlite3 db test.db; sqlite3_connection_pointer db]
        cksum
      } $checksum
    }

    set ::sqlite_io_error_hardhit 0
    set ::sqlite_io_error_pending 0