libdb/lang/sql/sqlite/test/crash7.test

83 lines
2.3 KiB
Text
Raw Normal View History

2011-09-13 17:44:24 +00:00
# 2008 March 20
#
# The author disclaims copyright to this source code. In place of
# a legal notice, here is a blessing:
#
# 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: crash7.test,v 1.1 2008/04/03 14:36:26 danielk1977 Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
ifcapable !crashtest {
finish_test
return
}
proc signature {} {
return [db eval {SELECT count(*), md5sum(a), md5sum(b), md5sum(c) FROM abc}]
}
foreach f [list test.db test.db-journal] {
for {set ii 1} {$ii < 64} {incr ii} {
db close
file delete test.db
sqlite3 db test.db
set from_size [expr 1024 << ($ii&3)]
set to_size [expr 1024 << (($ii>>2)&3)]
execsql "
PRAGMA page_size = $from_size;
BEGIN;
CREATE TABLE abc(a PRIMARY KEY, b, c);
INSERT INTO abc VALUES(randomblob(100), randomblob(200), randomblob(1000));
INSERT INTO abc
SELECT randomblob(1000), randomblob(200), randomblob(100)
FROM abc;
INSERT INTO abc
SELECT randomblob(100), randomblob(200), randomblob(1000)
FROM abc;
INSERT INTO abc
SELECT randomblob(100), randomblob(200), randomblob(1000)
FROM abc;
INSERT INTO abc
SELECT randomblob(100), randomblob(200), randomblob(1000)
FROM abc;
INSERT INTO abc
SELECT randomblob(100), randomblob(200), randomblob(1000)
FROM abc WHERE [expr $ii&16];
INSERT INTO abc
SELECT randomblob(25), randomblob(45), randomblob(9456)
FROM abc WHERE [expr $ii&32];
INSERT INTO abc
SELECT randomblob(100), randomblob(200), randomblob(1000)
FROM abc WHERE [expr $ii&8];
INSERT INTO abc
SELECT randomblob(25), randomblob(45), randomblob(9456)
FROM abc WHERE [expr $ii&4];
COMMIT;
"
set sig [signature]
db close
do_test crash7-1.$ii.crash {
crashsql -file $f "
PRAGMA page_size = $to_size;
VACUUM;
"
} {1 {child process exited abnormally}}
sqlite3 db test.db
integrity_check crash7-1.$ii.integrity
}
}
finish_test