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

Side by Side Diff: third_party/sqlite/src/ext/session/sessionfault2.test

Issue 2751253002: [sql] Import SQLite 3.17.0. (Closed)
Patch Set: also clang on Linux i386 Created 3 years, 9 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 unified diff | Download patch
OLDNEW
(Empty)
1 # 2016 March 31
2 #
3 # The author disclaims copyright to this source code. In place of
4 # a legal notice, here is a blessing:
5 #
6 # May you do good and not evil.
7 # May you find forgiveness for yourself and forgive others.
8 # May you share freely, never taking more than you give.
9 #
10 #***********************************************************************
11 #
12 # The focus of this file is testing the session module.
13 #
14
15 if {![info exists testdir]} {
16 set testdir [file join [file dirname [info script]] .. .. test]
17 }
18 source [file join [file dirname [info script]] session_common.tcl]
19 source $testdir/tester.tcl
20 ifcapable !session {finish_test; return}
21 set testprefix sessionfault2
22
23 do_execsql_test 1.0.0 {
24 CREATE TABLE t1(a PRIMARY KEY, b UNIQUE);
25 INSERT INTO t1 VALUES(1, 1);
26 INSERT INTO t1 VALUES(2, 2);
27 INSERT INTO t1 VALUES(3, 3);
28
29 CREATE TABLE t2(a PRIMARY KEY, b UNIQUE);
30 INSERT INTO t2 VALUES(1, 1);
31 INSERT INTO t2 VALUES(2, 2);
32 INSERT INTO t2 VALUES(3, 3);
33 }
34 faultsim_save_and_close
35
36 faultsim_restore_and_reopen
37 do_test 1.0.1 {
38 set ::C [changeset_from_sql {
39 UPDATE t1 SET b=4 WHERE a=3;
40 UPDATE t1 SET b=3 WHERE a=2;
41 UPDATE t1 SET b=2 WHERE a=1;
42 UPDATE t2 SET b=0 WHERE a=1;
43 UPDATE t2 SET b=1 WHERE a=2;
44 UPDATE t2 SET b=2 WHERE a=3;
45 }]
46 set {} {}
47 } {}
48
49 proc xConflict args { return "OMIT" }
50
51 do_faultsim_test 1 -faults oom-p* -prep {
52 faultsim_restore_and_reopen
53 } -body {
54 sqlite3changeset_apply db $::C xConflict
55 } -test {
56 faultsim_test_result {0 {}} {1 SQLITE_NOMEM}
57 faultsim_integrity_check
58
59 catch { db eval ROLLBACK }
60 set res [db eval {
61 SELECT * FROM t1;
62 SELECT * FROM t2;
63 }]
64
65 if {$testrc==0} {
66 if {$res != "1 2 2 3 3 4 1 0 2 1 3 2"} { error "data error" }
67 } else {
68 if {
69 $res != "1 2 2 3 3 4 1 0 2 1 3 2"
70 && $res != "1 1 2 2 3 3 1 1 2 2 3 3"
71 } { error "data error!! $res" }
72 }
73 }
74
75 #-------------------------------------------------------------------------
76 # OOM when applying a changeset for which one of the tables has a name
77 # 99 bytes in size. This happens to cause an extra malloc in within the
78 # sessions_strm permutation.
79 #
80 reset_db
81 set nm [string repeat t 99]
82 do_execsql_test 2.0.0 [string map "%TBL% $nm" {
83 CREATE TABLE %TBL%(a PRIMARY KEY, b UNIQUE);
84 }]
85 faultsim_save_and_close
86
87 faultsim_restore_and_reopen
88 do_test 1.0.1 {
89 set ::C [changeset_from_sql [string map "%TBL% $nm" {
90 INSERT INTO %TBL% VALUES(1, 2);
91 INSERT INTO %TBL% VALUES(3, 4);
92 }]]
93 set {} {}
94 } {}
95
96 proc xConflict args { return "OMIT" }
97 do_faultsim_test 2 -faults oom-p* -prep {
98 faultsim_restore_and_reopen
99 } -body {
100 sqlite3changeset_apply db $::C xConflict
101 } -test {
102 faultsim_test_result {0 {}} {1 SQLITE_NOMEM}
103 faultsim_integrity_check
104 }
105
106 finish_test
107
OLDNEW
« no previous file with comments | « third_party/sqlite/src/ext/session/sessionfault.test ('k') | third_party/sqlite/src/ext/session/sessionwor.test » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698