From 8d96eb0fac88d4304ac288dae7e73091046fcc8a Mon Sep 17 00:00:00 2001 From: danielk1977 Date: Mon, 2 Apr 2007 16:46:23 +0000 Subject: [PATCH] Add a different form of I/O tests. So far has failed to expose new bugs. (CVS 3802) FossilOrigin-Name: 9e1295428f476dba21c28149c7983f66a9134559 --- manifest | 13 +++---- manifest.uuid | 2 +- test/ioerr2.test | 91 ++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 99 insertions(+), 7 deletions(-) create mode 100644 test/ioerr2.test diff --git a/manifest b/manifest index 8954a185e2..0f42306dac 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C If\spreprocessor\smacro\sOS_OTHER\sis\sdefined,\sthen\signore\sOS_UNIX,\sOS_WIN,\sand\nOS_OS2.\s\sThis\smakes\sit\seasier\sto\sadd\sproprietary\sbackends..\s(CVS\s3801) -D 2007-04-02T16:45:13 +C Add\sa\sdifferent\sform\sof\sI/O\stests.\sSo\sfar\shas\sfailed\sto\sexpose\snew\sbugs.\s(CVS\s3802) +D 2007-04-02T16:46:23 F Makefile.in 2f2c3bf69faf0ae7b8e8af4f94f1986849034530 F Makefile.linux-gcc 2d8574d1ba75f129aba2019f0b959db380a90935 F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028 @@ -242,6 +242,7 @@ F test/insert4.test 0bb119fea2868afdcf78e4e3e3bfed27bbdb2430 F test/interrupt.test c38b7f7c17914f0cd6a119beed5d03bc3f47f9eb F test/intpkey.test af4fd826c4784ec5c93b444de07adea0254d0d30 F test/ioerr.test 491d42c49bbec598966d26b01ed7901f55e5ee2d +F test/ioerr2.test 5f672f7f37a424bb1e02bee4fdedfa319a95da29 F test/join.test af0443185378b64878750aa1cf4b83c216f246b4 F test/join2.test f2171c265e57ee298a27e57e7051d22962f9f324 F test/join3.test 6f0c774ff1ba0489e6c88a3e77b9d3528fb4fda0 @@ -448,7 +449,7 @@ F www/tclsqlite.tcl bb0d1357328a42b1993d78573e587c6dcbc964b9 F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0 F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b F www/whentouse.tcl 97e2b5cd296f7d8057e11f44427dea8a4c2db513 -P 93a41510f02dc5649dbbc22c4e4fbee545bd76d8 -R e5f04671943867fead15e12170770e3b -U drh -Z ae555aac32c377d06fe2669a353b0839 +P 4fdafd3f583b1ec4aa7fb6a9b5de2f52a375832b +R 6309f43590fc7c56f04de013101b9327 +U danielk1977 +Z d779504ae78400a04fd1f5a591901d17 diff --git a/manifest.uuid b/manifest.uuid index 77897000ae..59a2cacb1a 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -4fdafd3f583b1ec4aa7fb6a9b5de2f52a375832b \ No newline at end of file +9e1295428f476dba21c28149c7983f66a9134559 \ No newline at end of file diff --git a/test/ioerr2.test b/test/ioerr2.test new file mode 100644 index 0000000000..dd4e5db3ce --- /dev/null +++ b/test/ioerr2.test @@ -0,0 +1,91 @@ +# 2007 April 2 +# +# 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. +# +#*********************************************************************** +# This file implements regression tests for SQLite library. The +# focus of this file is testing for correct handling of I/O errors +# such as writes failing because the disk is full. +# +# The tests in this file use special facilities that are only +# available in the SQLite test fixture. +# +# $Id: ioerr2.test,v 1.1 2007/04/02 16:46:23 danielk1977 Exp $ + +set testdir [file dirname $argv0] +source $testdir/tester.tcl + +do_test ioerr2-1.1 { + execsql { + PRAGMA cache_size = 10; + PRAGMA default_cache_size = 10; + CREATE TABLE t1(a, b, PRIMARY KEY(a, b)); + INSERT INTO t1 VALUES(randstr(400,400),randstr(400,400)); + INSERT INTO t1 SELECT randstr(400,400), randstr(400,400) FROM t1; -- 2 + INSERT INTO t1 SELECT randstr(400,400), randstr(400,400) FROM t1; -- 4 + INSERT INTO t1 SELECT randstr(400,400), randstr(400,400) FROM t1; -- 8 + INSERT INTO t1 SELECT randstr(400,400), randstr(400,400) FROM t1; -- 16 + INSERT INTO t1 SELECT randstr(400,400), randstr(400,400) FROM t1; -- 32 + } +} {} + +set ::cksum [execsql {SELECT md5sum(a, b) FROM t1}] +proc check_db {testname} { + + # Make sure no I/O errors are simulated in this proc. + set ::sqlite_io_error_hit 0 + set ::sqlite_io_error_persist 0 + set ::sqlite_io_error_pending 0 + + # Run an integrity-check. If "disk I/O error" is returned, the + # pager must be in error state. In this case open a new database + # connection. Otherwise, try a ROLLBACK, in case a transaction + # is still active. + set rc [catch {execsql {PRAGMA integrity_check}} msg] + if {$rc && $msg eq "disk I/O error"} { + db close + sqlite3 db test.db + } else { + if {$rc} {error $msg} + catch {execsql ROLLBACK} + } + + # Check that the database checksum is still $::cksum, and that + # the integrity-check passes. + set ck [execsql {SELECT md5sum(a, b) FROM t1}] + do_test ${testname}.cksum [list set ck $ck] $::cksum + integrity_check ${testname}.integrity +} + +check_db ioerr2-2 + +set sql { + PRAGMA cache_size = 10; + PRAGMA default_cache_size = 10; + BEGIN; + DELETE FROM t1 WHERE (oid%7)==0; + INSERT INTO t1 SELECT randstr(400,400), randstr(400,400) + WHERE (random()%7)==0; + UPDATE t1 SET a = randstr(400,400), b = randstr(400,400) + WHERE (random()%7)==0; + ROLLBACK; +} + +foreach bPersist [list 0 1] { + set ::go 1 + for {set ::N 1} {$::go} {incr ::N} { + set ::sqlite_io_error_hit 0 + set ::sqlite_io_error_persist $bPersist + set ::sqlite_io_error_pending $::N + + foreach {::go res} [catchsql $sql] {} + check_db ioerr2-3.$bPersist.$::N + } +} + +finish_test