1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-07-29 08:01:23 +03:00

Add some test cases simulating crashes with various storage medium sector sizes. (CVS 3704)

FossilOrigin-Name: c3c5f658cf9c69b6e81e63fbde5dd0a854be9fc7
This commit is contained in:
danielk1977
2007-03-19 15:04:54 +00:00
parent b94bf855b2
commit a8553141c9
3 changed files with 68 additions and 8 deletions

View File

@ -16,7 +16,7 @@
# specifically, the tests in this file verify this functionality
# for storage mediums with various sector sizes.
#
# $Id: crash2.test,v 1.2 2007/03/19 05:54:50 danielk1977 Exp $
# $Id: crash2.test,v 1.3 2007/03/19 15:04:54 danielk1977 Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
@ -60,5 +60,65 @@ for {set ii 0} {$ii < 5} {incr ii} {
} {ok}
}
proc signature {} {
return [db eval {SELECT count(*), md5sum(a), md5sum(b), md5sum(c) FROM abc}]
}
# Test case for crashing during journal sync with simulated
# sector-size values from 1024 to 8192.
#
do_test crash2-2.0 {
execsql BEGIN
for {set n 0} {$n < 1000} {incr n} {
execsql "INSERT INTO abc VALUES($n, [expr 2*$n], [expr 3*$n])"
}
execsql {
INSERT INTO abc SELECT * FROM abc;
INSERT INTO abc SELECT * FROM abc;
INSERT INTO abc SELECT * FROM abc;
INSERT INTO abc SELECT * FROM abc;
INSERT INTO abc SELECT * FROM abc;
}
execsql COMMIT
expr ([file size test.db] / 1024) > 450
} {1}
for {set i 1} {$i < 30} {incr i} {
set sig [signature]
set sector [expr 1024 * 1<<($i%4)]
do_test crash-2.$i.1 {
crashsql -blocksize $sector -delay [expr $i%5 + 1] -file test.db-journal "
BEGIN;
SELECT random() FROM abc LIMIT $i;
INSERT INTO abc SELECT randstr(10,10), 0, 0 FROM abc WHERE random()%2==0;
DELETE FROM abc WHERE random()%2!=0;
COMMIT;
"
} {1 {child process exited abnormally}}
do_test crash-2.$i.2 {
signature
} $sig
}
# Test case for crashing during database sync with simulated
# sector-size values from 1024 to 8192.
#
for {set i 1} {$i < 10} {incr i} {
set sig [signature]
set sector [expr 1024 * 1<<($i%4)]
do_test crash-3.$i.1 {
crashsql -blocksize $sector -file test.db "
BEGIN;
SELECT random() FROM abc LIMIT $i;
INSERT INTO abc SELECT randstr(10,10), 0, 0 FROM abc WHERE random()%2==0;
DELETE FROM abc WHERE random()%2!=0;
COMMIT;
"
} {1 {child process exited abnormally}}
do_test crash-3.$i.2 {
signature
} $sig
}
finish_test