OLD | NEW |
1 # 2008 January 8 | 1 # 2008 January 8 |
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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 # Close and reopen the database right before the UPDATE statement. | 56 # Close and reopen the database right before the UPDATE statement. |
57 # On each repetition, introduce database corruption typical of | 57 # On each repetition, introduce database corruption typical of |
58 # what might be seen in a power loss or OS crash. | 58 # what might be seen in a power loss or OS crash. |
59 # | 59 # |
60 # Slowly increase the delay before the crash, repeating the test | 60 # Slowly increase the delay before the crash, repeating the test |
61 # over and over. Stop testing when the entire sequence of SQL | 61 # over and over. Stop testing when the entire sequence of SQL |
62 # statements runs to completing without hitting the crash. | 62 # statements runs to completing without hitting the crash. |
63 # | 63 # |
64 for {set cnt 1; set fin 0} {!$fin} {incr cnt} { | 64 for {set cnt 1; set fin 0} {!$fin} {incr cnt} { |
65 db close | 65 db close |
66 file delete -force test.db test.db-journal | 66 forcedelete test.db test.db-journal |
67 do_test crash4-1.$cnt.1 { | 67 do_test crash4-1.$cnt.1 { |
68 set seed [expr {int(abs(rand()*10000))}] | 68 set seed [expr {int(abs(rand()*10000))}] |
69 set delay [expr {int($cnt/50)+1}] | 69 set delay [expr {int($cnt/50)+1}] |
70 set file [expr {($cnt&1)?"test.db":"test.db-journal"}] | 70 set file [expr {($cnt&1)?"test.db":"test.db-journal"}] |
71 set c [crashsql -delay $delay -file $file -seed $seed -tclbody { | 71 set c [crashsql -delay $delay -file $file -seed $seed -tclbody { |
72 db eval {CREATE TABLE a(id INTEGER, name CHAR(50))} | 72 db eval {CREATE TABLE a(id INTEGER, name CHAR(50))} |
73 db eval {INSERT INTO a(id,name) VALUES(1,'one')} | 73 db eval {INSERT INTO a(id,name) VALUES(1,'one')} |
74 db eval {INSERT INTO a(id,name) VALUES(2,'two')} | 74 db eval {INSERT INTO a(id,name) VALUES(2,'two')} |
75 db eval {INSERT INTO a(id,name) VALUES(3,'three')} | 75 db eval {INSERT INTO a(id,name) VALUES(3,'three')} |
76 db eval {INSERT INTO a(id,name) VALUES(4,'four')} | 76 db eval {INSERT INTO a(id,name) VALUES(4,'four')} |
(...skipping 16 matching lines...) Expand all Loading... |
93 } {1 {child process exited abnormally}} | 93 } {1 {child process exited abnormally}} |
94 sqlite3 db test.db | 94 sqlite3 db test.db |
95 integrity_check crash4-1.$cnt.2 | 95 integrity_check crash4-1.$cnt.2 |
96 do_test crash4-1.$cnt.3 { | 96 do_test crash4-1.$cnt.3 { |
97 set x [lsearch $::crash4_cksum_set [allcksum db]] | 97 set x [lsearch $::crash4_cksum_set [allcksum db]] |
98 expr {$x>=0} | 98 expr {$x>=0} |
99 } {1} | 99 } {1} |
100 } | 100 } |
101 | 101 |
102 finish_test | 102 finish_test |
OLD | NEW |