From: dan Date: Fri, 28 May 2010 04:16:28 +0000 (+0000) Subject: Add a test to walcksum.test to stress the checksum calculation. X-Git-Tag: version-3.7.2~332 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5f168a5d53c82b1d6b79024fc4ad25b741647d91;p=thirdparty%2Fsqlite.git Add a test to walcksum.test to stress the checksum calculation. FossilOrigin-Name: 778d0c1768f73057be912793631e0cf0575858fb --- diff --git a/manifest b/manifest index e92b974915..87e4c8efe4 100644 --- a/manifest +++ b/manifest @@ -1,8 +1,5 @@ ------BEGIN PGP SIGNED MESSAGE----- -Hash: SHA1 - -C Make\ssure\sthe\swal-index\smapping\sis\salways\slarge\senough\sto\scover\sthe\sentire\nactive\sarea\sof\sthe\swal-index. -D 2010-05-26T17:31:59 +C Add\sa\stest\sto\swalcksum.test\sto\sstress\sthe\schecksum\scalculation. +D 2010-05-28T04:16:28 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0 F Makefile.in a5cad1f8f3e021356bfcc6c77dc16f6f1952bbc3 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654 @@ -767,7 +764,7 @@ F test/vtab_shared.test 0eff9ce4f19facbe0a3e693f6c14b80711a4222d F test/wal.test be8ef043253ca735ffcabb92a7dac2d79ebfe8c1 F test/wal2.test a10f52b403117c2b9a1f7a11db527c53bb684a25 F test/walbak.test e7650a26eb4b8abeca9b145b1af1e63026dde432 -F test/walcksum.test a0712107b6a73397fc7e3f92d5b16e206caa7d3d +F test/walcksum.test a710d2c5c3f4e786d37d099790d8df8c47e270a3 F test/walcrash.test f6d5fb2bb108876f04848720a488065d9deef69f F test/walcrash2.test 14585ad1a2c85da2de721caa3b4deeea55213008 F test/walfault.test f71d4c9a13d4e27086aef55f1e0e94734ffa2f6a @@ -818,14 +815,7 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P 72de00731245277b2209103ec0a76e3d4f56530e -R 3803eb711e1482685c888c1d5aad25b9 -U drh -Z fbf41cb9ad1e3a86d51249de0c4212ff ------BEGIN PGP SIGNATURE----- -Version: GnuPG v1.4.6 (GNU/Linux) - -iD8DBQFL/VsSoxKgR168RlERAiiyAKCNIB2cx0oWfiSWhB7rYPl7wJQPNwCffewd -BG/+93y24TpcUQJKKPuyhOs= -=WCDR ------END PGP SIGNATURE----- +P 42705babba0e9d2ef078845854bebbd168f23366 +R 9d2a3bc8fc2778c92116dc9b4d28847f +U dan +Z 0d53d36af3414df9e04c32dec264ddf0 diff --git a/manifest.uuid b/manifest.uuid index 291c774fa3..c98509d939 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -42705babba0e9d2ef078845854bebbd168f23366 \ No newline at end of file +778d0c1768f73057be912793631e0cf0575858fb \ No newline at end of file diff --git a/test/walcksum.test b/test/walcksum.test index f21cf9fea9..0cded894eb 100644 --- a/test/walcksum.test +++ b/test/walcksum.test @@ -284,6 +284,12 @@ foreach endian {big little} { catch { db2 close } } +#------------------------------------------------------------------------- +# Test case walcksum-2.* tests that if a statement transaction is rolled +# back after frames are written to the WAL, and then (after writing some +# more) the outer transaction is committed, the WAL file is still correctly +# formatted (and can be recovered by a second process if required). +# do_test walcksum-2.1 { file delete -force test.db test.db-wal test.db-journal sqlite3 db test.db @@ -325,4 +331,58 @@ do_test walcksum-2.1 { catch { db close } catch { db2 close } +#------------------------------------------------------------------------- +# Test case walcksum-3.* tests that the checksum calculation detects single +# byte changes to frame or frame-header data and considers the frame +# invalid as a result. +# +do_test walcksum-3.1 { + file delete -force test.db test.db-wal test.db-journal + sqlite3 db test.db + + execsql { + PRAGMA synchronous = NORMAL; + PRAGMA page_size = 1024; + CREATE TABLE t1(a, b); + INSERT INTO t1 VALUES(1, randomblob(300)); + INSERT INTO t1 VALUES(2, randomblob(300)); + PRAGMA journal_mode = WAL; + INSERT INTO t1 VALUES(3, randomblob(300)); + } + + file size test.db-wal +} [log_file_size 1 1024] +do_test walcksum-3.2 { + file copy -force test.db-wal test2.db-wal + file copy -force test.db test2.db + sqlite3 db2 test2.db + execsql { SELECT a FROM t1 } db2 +} {1 2 3} +db2 close +file copy -force test.db test2.db +for {set incr 1} {$incr <= 255} {incr incr 21} { + do_test walcksum-3.3.$incr { + set FAIL 0 + for {set iOff 0} {$iOff < [log_file_size 1 1024]} {incr iOff} { + + file copy -force test.db-wal test2.db-wal + set fd [open test2.db-wal r+] + fconfigure $fd -encoding binary + fconfigure $fd -translation binary + + seek $fd $iOff + binary scan [read $fd 1] c x + seek $fd $iOff + puts -nonewline $fd [binary format c [expr {$x+$incr}]] + close $fd + + sqlite3 db2 test2.db + if { [execsql { SELECT a FROM t1 } db2] != "1 2" } {set FAIL 1} + db2 close + } + set FAIL + } {0} +} + finish_test +