Chromium Code Reviews

Side by Side Diff: third_party/sqlite/src/test/incrvacuum_ioerr.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.
Jump to:
View unified diff |
« no previous file with comments | « third_party/sqlite/src/test/incrvacuum3.test ('k') | third_party/sqlite/src/test/index.test » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # 2001 October 12 1 # 2001 October 12
2 # 2 #
3 # The author disclaims copyright to this source code. In place of 3 # The author disclaims copyright to this source code. In place of
4 # a legal notice, here is a blessing: 4 # a legal notice, here is a blessing:
5 # 5 #
6 # May you do good and not evil. 6 # May you do good and not evil.
7 # May you find forgiveness for yourself and forgive others. 7 # May you find forgiveness for yourself and forgive others.
8 # May you share freely, never taking more than you give. 8 # May you share freely, never taking more than you give.
9 # 9 #
10 #*********************************************************************** 10 #***********************************************************************
(...skipping 90 matching lines...)
101 } -cleanup { 101 } -cleanup {
102 sqlite3 db test.db 102 sqlite3 db test.db
103 integrity_check incrvacuum-ioerr-2.$n.integritycheck 103 integrity_check incrvacuum-ioerr-2.$n.integritycheck
104 db close 104 db close
105 } 105 }
106 106
107 107
108 ifcapable shared_cache { 108 ifcapable shared_cache {
109 109
110 catch { db close } 110 catch { db close }
111 file delete -force test.db 111 forcedelete test.db
112 set ::enable_shared_cache [sqlite3_enable_shared_cache 1] 112 set ::enable_shared_cache [sqlite3_enable_shared_cache 1]
113 113
114 # Create two connections to a single shared-cache: 114 # Create two connections to a single shared-cache:
115 # 115 #
116 sqlite3 db1 test.db 116 sqlite3 db1 test.db
117 sqlite3 db2 test.db 117 sqlite3 db2 test.db
118 118
119 # Create a database with around 20 free pages. 119 # Create a database with around 20 free pages.
120 # 120 #
121 do_test incrvacuum-ioerr-4.0 { 121 do_test incrvacuum-ioerr-4.0 {
(...skipping 10 matching lines...)
132 execsql COMMIT db1 132 execsql COMMIT db1
133 execsql {DELETE FROM a WHERE oid} db1 133 execsql {DELETE FROM a WHERE oid} db1
134 } {} 134 } {}
135 135
136 set ::rc 1 136 set ::rc 1
137 for {set iTest 1} {$::rc && $iTest<2000} {incr iTest} { 137 for {set iTest 1} {$::rc && $iTest<2000} {incr iTest} {
138 138
139 # Figure out how big the database is and how many free pages it 139 # Figure out how big the database is and how many free pages it
140 # has before running incremental-vacuum. 140 # has before running incremental-vacuum.
141 # 141 #
142 set nPage [expr {[file size test.db]/1024}]
143 set nFree [execsql {pragma freelist_count} db1] 142 set nFree [execsql {pragma freelist_count} db1]
143 set nPage [execsql {pragma page_count} db1]
144 puts "nFree=$nFree nPage=$nPage"
144 145
145 # Now run incremental-vacuum to vacuum 5 pages from the db file. 146 # Now run incremental-vacuum to vacuum 5 pages from the db file.
146 # The iTest'th I/O call is set to fail. 147 # The iTest'th I/O call is set to fail.
147 # 148 #
148 set ::sqlite_io_error_pending $iTest 149 set ::sqlite_io_error_pending $iTest
149 set ::sqlite_io_error_persist 1 150 set ::sqlite_io_error_persist 1
150 do_test incrvacuum-ioerr-4.$iTest.1 { 151 do_test incrvacuum-ioerr-4.$iTest.1 {
151 set ::rc [catch {execsql {pragma incremental_vacuum(5)} db1} msg] 152 set ::rc [catch {execsql {pragma incremental_vacuum(5)} db1} msg]
152 expr {$::rc==0 || $msg eq "disk I/O error"} 153 expr {$::rc==0 || $msg eq "disk I/O error"}
153 } {1} 154 } {1}
154 155
155 set ::sqlite_io_error_pending 0 156 set ::sqlite_io_error_pending 0
156 set ::sqlite_io_error_persist 0 157 set ::sqlite_io_error_persist 0
157 set ::sqlite_io_error_hit 0 158 set ::sqlite_io_error_hit 0
158 set ::sqlite_io_error_hardhit 0 159 set ::sqlite_io_error_hardhit 0
159 160
160 set nFree2 [execsql {pragma freelist_count} db1] 161 set nFree2 [execsql {pragma freelist_count} db1]
161 set nPage2 [expr {[file size test.db]/1024}] 162 set nPage2 [execsql {pragma page_count} db1]
162 163
163 do_test incrvacuum-ioerr-4.$iTest.2 { 164 do_test incrvacuum-ioerr-4.$iTest.2 {
164 set shrink [expr {$nPage-$nPage2}] 165 set shrink [expr {$nPage-$nPage2}]
165 expr {$shrink==0 || $shrink==5} 166 expr {$shrink==0 || $shrink==5 || ($nFree<5 && $shrink==$nFree)}
166 } {1} 167 } {1}
167 168
168 do_test incrvacuum-ioerr-4.$iTest.3 { 169 do_test incrvacuum-ioerr-4.$iTest.3 {
169 expr {$nPage - $nPage2} 170 expr {$nPage - $nPage2}
170 } [expr {$nFree - $nFree2}] 171 } [expr {$nFree - $nFree2}]
171 } 172 }
172 173
173 # Close the two database connections and restore the default 174 # Close the two database connections and restore the default
174 # shared-cache mode setting. 175 # shared-cache mode setting.
175 # 176 #
176 db1 close 177 db1 close
177 db2 close 178 db2 close
178 sqlite3_enable_shared_cache $::enable_shared_cache 179 sqlite3_enable_shared_cache $::enable_shared_cache
179 } 180 }
180 181
181 finish_test 182 finish_test
OLDNEW
« no previous file with comments | « third_party/sqlite/src/test/incrvacuum3.test ('k') | third_party/sqlite/src/test/index.test » ('j') | no next file with comments »

Powered by Google App Engine