/ Check-in [b092f2a7]
Login

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

Overview
Comment:Add tests to pagerfault.test.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:b092f2a74bdc77c1f90ad3b4448cb68a891ecf63
User & Date: dan 2010-07-14 08:20:36
Context
2010-07-14
14:48
On unix, try to create the *-wal and *-shm files with the same permissions as the associated database file. check-in: e5d180ee user: dan tags: trunk
08:20
Add tests to pagerfault.test. check-in: b092f2a7 user: dan tags: trunk
07:06
Test that a corrupted WAL hash-table does not put the library into an infinite loop. check-in: c73886ed user: dan tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to test/pagerfault.test.

24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
...
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
...
974
975
976
977
978
979
980
981







































































982
proc a_string {n} {
  global a_string_counter
  incr a_string_counter
  string range [string repeat "${a_string_counter}." $n] 1 $n
}
db func a_string a_string


if 1 {

#-------------------------------------------------------------------------
# Test fault-injection while rolling back a hot-journal file.
#
do_test pagerfault-1-pre1 {
  execsql {
    PRAGMA journal_mode = DELETE;
    PRAGMA cache_size = 10;
................................................................................
    RELEASE trans;
  }
} -test {
  faultsim_test_result {0 {}}
  faultsim_integrity_check
}

}


#-------------------------------------------------------------------------
# Test fault injection when writing to a database file that resides on
# a file-system with a sector-size larger than the database page-size.
#
do_test pagerfault-12-pre1 {
  testvfs ss_layer -default 1
................................................................................
    db eval { INSERT INTO t0 SELECT a+1, b FROM t0 }
    db eval { INSERT INTO t0 SELECT a+2, b FROM t0 }
  }
} -test {
  faultsim_test_result {0 {}}
}









































































finish_test







<
<
<







 







<
<







 








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

24
25
26
27
28
29
30



31
32
33
34
35
36
37
...
547
548
549
550
551
552
553


554
555
556
557
558
559
560
...
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
proc a_string {n} {
  global a_string_counter
  incr a_string_counter
  string range [string repeat "${a_string_counter}." $n] 1 $n
}
db func a_string a_string




#-------------------------------------------------------------------------
# Test fault-injection while rolling back a hot-journal file.
#
do_test pagerfault-1-pre1 {
  execsql {
    PRAGMA journal_mode = DELETE;
    PRAGMA cache_size = 10;
................................................................................
    RELEASE trans;
  }
} -test {
  faultsim_test_result {0 {}}
  faultsim_integrity_check
}




#-------------------------------------------------------------------------
# Test fault injection when writing to a database file that resides on
# a file-system with a sector-size larger than the database page-size.
#
do_test pagerfault-12-pre1 {
  testvfs ss_layer -default 1
................................................................................
    db eval { INSERT INTO t0 SELECT a+1, b FROM t0 }
    db eval { INSERT INTO t0 SELECT a+2, b FROM t0 }
  }
} -test {
  faultsim_test_result {0 {}}
}


#-------------------------------------------------------------------------
# Test fault-injection and rollback when the nReserve header value 
# is non-zero.
#
do_test pagerfault-21-pre1 {
  faultsim_delete_and_reopen
  execsql {
    PRAGMA page_size = 1024;
    PRAGMA journal_mode = WAL;
    PRAGMA journal_mode = DELETE;
  }
  db close
  hexio_write test.db 20    10
  hexio_write test.db 105 03F0
  sqlite3 db test.db
  db func a_string a_string
  execsql {
    CREATE TABLE t0(a PRIMARY KEY, b UNIQUE);
    INSERT INTO t0 VALUES(a_string(222), a_string(333));
    INSERT INTO t0 VALUES(a_string(223), a_string(334));
    INSERT INTO t0 VALUES(a_string(224), a_string(335));
    INSERT INTO t0 VALUES(a_string(225), a_string(336));
  }
  faultsim_save_and_close
} {}

do_faultsim_test pagerfault-21 -prep {
  faultsim_restore_and_reopen
} -body {
  execsql { INSERT INTO t0 SELECT a||'x', b||'x' FROM t0 }
} -test {
  faultsim_test_result {0 {}}
  faultsim_integrity_check
}
ifcapable crashtest {
  faultsim_delete_and_reopen
  execsql {
    PRAGMA page_size = 1024;
    PRAGMA journal_mode = WAL;
    PRAGMA journal_mode = DELETE;
  }
  db close
  hexio_write test.db 20    10
  hexio_write test.db 105 03F0

  sqlite3 db test.db
  db func a_string a_string
  execsql {
    CREATE TABLE t0(a PRIMARY KEY, b UNIQUE);
    INSERT INTO t0 VALUES(a_string(222), a_string(333));
    INSERT INTO t0 VALUES(a_string(223), a_string(334));
  }
  faultsim_save_and_close

  for {set iTest 1} {$iTest<50} {incr iTest} {
    do_test pagerfault-21.crash.$iTest.1 {
      crashsql -delay 1 -file test.db -seed $iTest {
        BEGIN;
          CREATE TABLE t1(a PRIMARY KEY, b UNIQUE);
          INSERT INTO t1 SELECT a, b FROM t0;
        COMMIT;
      }
    } {1 {child process exited abnormally}}
    do_test pagerfault-22.$iTest.2 {
      sqlite3 db test.db
      execsql { PRAGMA integrity_check }
    } {ok}
    db close
  }
}

finish_test