/ Check-in [c3c5f658]
Login

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

Overview
Comment:Add some test cases simulating crashes with various storage medium sector sizes. (CVS 3704)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: c3c5f658cf9c69b6e81e63fbde5dd0a854be9fc7
User & Date: danielk1977 2007-03-19 15:04:54
Context
2007-03-19
17:44
Modify the interface to the pager sub-system in preparation for performing IO in blocks based on sector-size, not database page-size. (CVS 3705) check-in: 7dc76588 user: danielk1977 tags: trunk
15:04
Add some test cases simulating crashes with various storage medium sector sizes. (CVS 3704) check-in: c3c5f658 user: danielk1977 tags: trunk
13:53
Fix some problems with test cases in shared_err.test. Also a real bug causing a segfault after an IO error in pager.c. (CVS 3703) check-in: 9f62ef1e user: danielk1977 tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Show Whitespace Changes Patch

Changes to test/crash2.test.

    12     12   #
    13     13   # The focus of this file is testing the ability of the database to
    14     14   # uses its rollback journal to recover intact (no database corruption)
    15     15   # from a power failure during the middle of a COMMIT. Even more
    16     16   # specifically, the tests in this file verify this functionality
    17     17   # for storage mediums with various sector sizes.
    18     18   #
    19         -# $Id: crash2.test,v 1.2 2007/03/19 05:54:50 danielk1977 Exp $
           19  +# $Id: crash2.test,v 1.3 2007/03/19 15:04:54 danielk1977 Exp $
    20     20   
    21     21   set testdir [file dirname $argv0]
    22     22   source $testdir/tester.tcl
    23     23   
    24     24   ifcapable !crashtest {
    25     25     finish_test
    26     26     return
................................................................................
    55     55       crashsql -file test.db -blocksize 2048 "
    56     56         [string repeat {SELECT random();} $ii]
    57     57         CREATE TABLE hij(h, i, j);
    58     58       "
    59     59       db eval {PRAGMA integrity_check}
    60     60     } {ok}
    61     61   }
           62  +
           63  +proc signature {} {
           64  +  return [db eval {SELECT count(*), md5sum(a), md5sum(b), md5sum(c) FROM abc}]
           65  +}
           66  +
           67  +# Test case for crashing during journal sync with simulated
           68  +# sector-size values from 1024 to 8192.
           69  +#
           70  +do_test crash2-2.0 {
           71  +  execsql BEGIN
           72  +  for {set n 0} {$n < 1000} {incr n} {
           73  +    execsql "INSERT INTO abc VALUES($n, [expr 2*$n], [expr 3*$n])"
           74  +  }
           75  +  execsql {
           76  +    INSERT INTO abc SELECT * FROM abc;
           77  +    INSERT INTO abc SELECT * FROM abc;
           78  +    INSERT INTO abc SELECT * FROM abc;
           79  +    INSERT INTO abc SELECT * FROM abc;
           80  +    INSERT INTO abc SELECT * FROM abc;
           81  +  }
           82  +  execsql COMMIT
           83  +  expr ([file size test.db] / 1024) > 450
           84  +} {1}
           85  +for {set i 1} {$i < 30} {incr i} {
           86  +  set sig [signature]
           87  +  set sector [expr 1024 * 1<<($i%4)]
           88  +  do_test crash-2.$i.1 {
           89  +     crashsql -blocksize $sector -delay [expr $i%5 + 1] -file test.db-journal "
           90  +       BEGIN;
           91  +       SELECT random() FROM abc LIMIT $i;
           92  +       INSERT INTO abc SELECT randstr(10,10), 0, 0 FROM abc WHERE random()%2==0;
           93  +       DELETE FROM abc WHERE random()%2!=0;
           94  +       COMMIT;
           95  +     "
           96  +  } {1 {child process exited abnormally}}
           97  +  do_test crash-2.$i.2 {
           98  +    signature
           99  +  } $sig
          100  +} 
          101  +
          102  +
          103  +# Test case for crashing during database sync with simulated
          104  +# sector-size values from 1024 to 8192.
          105  +#
          106  +for {set i 1} {$i < 10} {incr i} {
          107  +  set sig [signature]
          108  +  set sector [expr 1024 * 1<<($i%4)]
          109  +  do_test crash-3.$i.1 {
          110  +     crashsql -blocksize $sector -file test.db "
          111  +       BEGIN;
          112  +       SELECT random() FROM abc LIMIT $i;
          113  +       INSERT INTO abc SELECT randstr(10,10), 0, 0 FROM abc WHERE random()%2==0;
          114  +       DELETE FROM abc WHERE random()%2!=0;
          115  +       COMMIT;
          116  +     "
          117  +  } {1 {child process exited abnormally}}
          118  +  do_test crash-3.$i.2 {
          119  +    signature
          120  +  } $sig
          121  +} 
    62    122   
    63    123   finish_test
    64    124