Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(687)

Unified Diff: third_party/sqlite/src/test/corruptC.test

Issue 949043002: Add //third_party/sqlite to dirs_to_snapshot, remove net_sql.patch (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/sqlite/src/test/corruptB.test ('k') | third_party/sqlite/src/test/corruptD.test » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/sqlite/src/test/corruptC.test
diff --git a/third_party/sqlite/src/test/corruptC.test b/third_party/sqlite/src/test/corruptC.test
index 05804263884a661648fb2208ca3b6e7dea1c3bc0..adf6f44c44863de6deda63d665ff120b693a25e5 100644
--- a/third_party/sqlite/src/test/corruptC.test
+++ b/third_party/sqlite/src/test/corruptC.test
@@ -17,7 +17,7 @@
#
# $Id: corruptC.test,v 1.14 2009/07/11 06:55:34 danielk1977 Exp $
-catch {file delete -force test.db test.db-journal test.bu}
+catch {forcedelete test.db test.db-journal test.bu}
set testdir [file dirname $argv0]
source $testdir/tester.tcl
@@ -27,6 +27,10 @@ source $testdir/tester.tcl
#
do_not_use_codec
+# These tests deal with corrupt database files
+#
+database_may_be_corrupt
+
# Construct a compact, dense database for testing.
#
do_test corruptC-1.1 {
@@ -58,16 +62,10 @@ proc random {range} {
return [expr {round(rand()*$range)}]
}
-# Copy file $from into $to
-#
-proc copy_file {from to} {
- file copy -force $from $to
-}
-
# Setup for the tests. Make a backup copy of the good database in test.bu.
#
db close
-copy_file test.db test.bu
+forcecopy test.db test.bu
sqlite3 db test.db
set fsize [file size test.db]
@@ -92,7 +90,7 @@ expr srand($qseed)
# test that a corrupt content offset size is handled (seed 5577)
do_test corruptC-2.1 {
db close
- copy_file test.bu test.db
+ forcecopy test.bu test.db
# insert corrupt byte(s)
hexio_write test.db 2053 [format %02x 0x04]
@@ -104,7 +102,7 @@ do_test corruptC-2.1 {
# test that a corrupt content offset size is handled (seed 5649)
do_test corruptC-2.2 {
db close
- copy_file test.bu test.db
+ forcecopy test.bu test.db
# insert corrupt byte(s)
hexio_write test.db 27 [format %02x 0x08]
@@ -125,7 +123,7 @@ do_test corruptC-2.2 {
# test that a corrupt free cell size is handled (seed 13329)
do_test corruptC-2.3 {
db close
- copy_file test.bu test.db
+ forcecopy test.bu test.db
# insert corrupt byte(s)
hexio_write test.db 1094 [format %02x 0x76]
@@ -137,7 +135,7 @@ do_test corruptC-2.3 {
# test that a corrupt free cell size is handled (seed 169571)
do_test corruptC-2.4 {
db close
- copy_file test.bu test.db
+ forcecopy test.bu test.db
# insert corrupt byte(s)
hexio_write test.db 3119 [format %02x 0xdf]
@@ -149,7 +147,7 @@ do_test corruptC-2.4 {
# test that a corrupt free cell size is handled (seed 169571)
do_test corruptC-2.5 {
db close
- copy_file test.bu test.db
+ forcecopy test.bu test.db
# insert corrupt byte(s)
hexio_write test.db 3119 [format %02x 0xdf]
@@ -169,7 +167,7 @@ Page 4: btreeInitPage() returns error code 11}}}
# test that a corrupt free cell size is handled (seed 169595)
do_test corruptC-2.6 {
db close
- copy_file test.bu test.db
+ forcecopy test.bu test.db
# insert corrupt byte(s)
hexio_write test.db 619 [format %02x 0xe2]
@@ -182,7 +180,7 @@ do_test corruptC-2.6 {
# corruption (seed 178692)
do_test corruptC-2.7 {
db close
- copy_file test.bu test.db
+ forcecopy test.bu test.db
# insert corrupt byte(s)
hexio_write test.db 3074 [format %02x 0xa0]
@@ -194,7 +192,7 @@ do_test corruptC-2.7 {
# corruption (seed 179069)
do_test corruptC-2.8 {
db close
- copy_file test.bu test.db
+ forcecopy test.bu test.db
# insert corrupt byte(s)
hexio_write test.db 1393 [format %02x 0x7d]
@@ -208,21 +206,25 @@ do_test corruptC-2.8 {
} {1 {database disk image is malformed}}
# corruption (seed 170434)
+#
+# UPDATE: Prior to 3.8.2, this used to return SQLITE_CORRUPT. It no longer
+# does. That is Ok, the point of these tests is to verify that no buffer
+# overruns or overreads can be caused by corrupt databases.
do_test corruptC-2.9 {
db close
- copy_file test.bu test.db
+ forcecopy test.bu test.db
# insert corrupt byte(s)
hexio_write test.db 2095 [format %02x 0xd6]
sqlite3 db test.db
catchsql {BEGIN; DELETE FROM t1 WHERE x>13; ROLLBACK;}
-} {1 {database disk image is malformed}}
+} {0 {}}
# corruption (seed 186504)
do_test corruptC-2.10 {
db close
- copy_file test.bu test.db
+ forcecopy test.bu test.db
# insert corrupt byte(s)
hexio_write test.db 3130 [format %02x 0x02]
@@ -234,7 +236,7 @@ do_test corruptC-2.10 {
# corruption (seed 1589)
do_test corruptC-2.11 {
db close
- copy_file test.bu test.db
+ forcecopy test.bu test.db
# insert corrupt byte(s)
hexio_write test.db 55 [format %02x 0xa7]
@@ -246,7 +248,7 @@ do_test corruptC-2.11 {
# corruption (seed 14166)
do_test corruptC-2.12 {
db close
- copy_file test.bu test.db
+ forcecopy test.bu test.db
# insert corrupt byte(s)
hexio_write test.db 974 [format %02x 0x2e]
@@ -258,7 +260,7 @@ do_test corruptC-2.12 {
# corruption (seed 218803)
do_test corruptC-2.13 {
db close
- copy_file test.bu test.db
+ forcecopy test.bu test.db
# insert corrupt byte(s)
hexio_write test.db 102 [format %02x 0x12]
@@ -269,7 +271,7 @@ do_test corruptC-2.13 {
do_test corruptC-2.14 {
db close
- copy_file test.bu test.db
+ forcecopy test.bu test.db
sqlite3 db test.db
set blob [string repeat abcdefghij 10000]
@@ -286,7 +288,7 @@ do_test corruptC-2.14 {
#
do_test corruptC-2.15 {
db close
- copy_file test.bu test.db
+ forcecopy test.bu test.db
hexio_write test.db 986 b9
sqlite3 db test.db
catchsql {SELECT count(*) FROM sqlite_master;}
@@ -300,7 +302,7 @@ for {set tn 0} {$tn<$fsize} {incr tn 1} {
# setup for test
db close
- copy_file test.bu test.db
+ forcecopy test.bu test.db
sqlite3 db test.db
# Seek to a random location in the file, and write a random single byte
« no previous file with comments | « third_party/sqlite/src/test/corruptB.test ('k') | third_party/sqlite/src/test/corruptD.test » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698