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

Side by Side Diff: third_party/sqlite/sqlite-src-3080704/test/sortfault.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 unified diff | Download patch
OLDNEW
(Empty)
1 # 2014 March 25.
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 # This file implements regression tests for SQLite library.
12 #
13 # Specifically, it tests the effects of fault injection on the sorter
14 # module (code in vdbesort.c).
15 #
16
17 set testdir [file dirname $argv0]
18 source $testdir/tester.tcl
19 set testprefix sortfault
20
21 do_execsql_test 1.0 {
22 PRAGMA cache_size = 5;
23 }
24
25 foreach {tn mmap_limit nWorker tmpstore threadsmode fakeheap lookaside} {
26 1 0 0 file multithread false false
27 2 100000 0 file multithread false false
28 3 100000 1 file multithread false false
29 4 2000000 0 file singlethread false true
30 } {
31 if {$sqlite_options(threadsafe)} { set threadsmode singlethread }
32
33 db eval "PRAGMA threads=$nWorker"
34 sqlite3_config $threadsmode
35 if { $lookaside } {
36 sqlite3_config_lookaside 100 500
37 } else {
38 sqlite3_config_lookaside 0 0
39 }
40 sqlite3_initialize
41 sorter_test_fakeheap $fakeheap
42
43 set str [string repeat a 1000]
44 puts $threadsmode
45
46 do_faultsim_test 1.$tn -prep {
47 sqlite3 db test.db
48 sqlite3_test_control SQLITE_TESTCTRL_SORTER_MMAP db $::mmap_limit
49 execsql { PRAGMA cache_size = 5 }
50 } -body {
51 execsql {
52 WITH r(x,y) AS (
53 SELECT 1, $::str
54 UNION ALL
55 SELECT x+1, $::str FROM r
56 LIMIT 200
57 )
58 SELECT count(x), length(y) FROM r GROUP BY (x%5)
59 }
60 } -test {
61 faultsim_test_result {0 {40 1000 40 1000 40 1000 40 1000 40 1000}}
62 }
63
64 do_faultsim_test 2.$tn -faults oom* -prep {
65 sqlite3 db test.db
66 sqlite3_test_control SQLITE_TESTCTRL_SORTER_MMAP db $::mmap_limit
67 add_test_utf16bin_collate db
68 execsql { PRAGMA cache_size = 5 }
69 } -body {
70 execsql {
71 WITH r(x,y) AS (
72 SELECT 100, $::str
73 UNION ALL
74 SELECT x-1, $::str FROM r
75 LIMIT 100
76 )
77 SELECT count(x), length(y) FROM r GROUP BY y COLLATE utf16bin, (x%5)
78 }
79 } -test {
80 faultsim_test_result {0 {20 1000 20 1000 20 1000 20 1000 20 1000}}
81 }
82
83 if {$mmap_limit > 1000000} {
84 set str2 [string repeat $str 10]
85
86 sqlite3_memdebug_vfs_oom_test 0
87 sqlite3 db test.db
88 sqlite3_test_control SQLITE_TESTCTRL_SORTER_MMAP db $::mmap_limit
89 execsql { PRAGMA cache_size = 5 }
90
91 do_faultsim_test 3.$tn -faults oom-trans* -body {
92 execsql {
93 WITH r(x,y) AS (
94 SELECT 300, $::str2
95 UNION ALL
96 SELECT x-1, $::str2 FROM r
97 LIMIT 300
98 )
99 SELECT count(x), length(y) FROM r GROUP BY y, (x%5)
100 }
101 } -test {
102 faultsim_test_result {0 {60 10000 60 10000 60 10000 60 10000 60 10000}}
103 }
104
105 sqlite3_memdebug_vfs_oom_test 1
106 }
107 }
108
109 catch { db close }
110 sqlite3_shutdown
111 set t(0) singlethread
112 set t(1) multithread
113 set t(2) serialized
114 sqlite3_config $t($sqlite_options(threadsafe))
115 sqlite3_config_lookaside 100 500
116 sqlite3_initialize
117
118 #-------------------------------------------------------------------------
119 #
120 reset_db
121 do_execsql_test 4.0 {
122 CREATE TABLE t1(a, b, c);
123 INSERT INTO t1 VALUES(1, 2, 3);
124 }
125 do_test 4.1 {
126 for {set i 0} {$i < 256} {incr i} {
127 execsql {
128 INSERT INTO t1 SELECT
129 ((a<<3) + b) & 2147483647,
130 ((b<<3) + c) & 2147483647,
131 ((c<<3) + a) & 2147483647
132 FROM t1 ORDER BY rowid DESC LIMIT 1;
133 }
134 }
135 } {}
136
137 faultsim_save_and_close
138
139 do_faultsim_test 4.2 -faults oom* -prep {
140 faultsim_restore_and_reopen
141 } -body {
142 execsql { CREATE UNIQUE INDEX i1 ON t1(a,b,c) }
143 } -test {
144 faultsim_test_result {0 {}}
145 }
146
147 #-------------------------------------------------------------------------
148 #
149 reset_db
150 set a [string repeat a 500]
151 set b [string repeat b 500]
152 set c [string repeat c 500]
153 do_execsql_test 5.0 {
154 CREATE TABLE t1(a, b, c);
155 INSERT INTO t1 VALUES($a, $b, $c);
156 INSERT INTO t1 VALUES($c, $b, $a);
157 }
158
159 do_faultsim_test 5.1 -faults oom* -body {
160 execsql { SELECT * FROM t1 ORDER BY a }
161 } -test {
162 faultsim_test_result [list 0 [list $::a $::b $::c $::c $::b $::a]]
163 }
164
165 finish_test
OLDNEW
« no previous file with comments | « third_party/sqlite/sqlite-src-3080704/test/sort5.test ('k') | third_party/sqlite/sqlite-src-3080704/test/speed1.test » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698