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

Side by Side Diff: third_party/sqlite/sqlite-src-3080704/test/dbstatus2.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 # 2011 September 20
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 # Tests for the sqlite3_db_status() function
13 #
14
15 set testdir [file dirname $argv0]
16 source $testdir/tester.tcl
17
18 set ::testprefix dbstatus2
19
20 do_execsql_test 1.0 {
21 PRAGMA page_size = 1024;
22 PRAGMA auto_vacuum = 0;
23
24 CREATE TABLE t1(a PRIMARY KEY, b);
25 INSERT INTO t1 VALUES(1, randomblob(600));
26 INSERT INTO t1 VALUES(2, randomblob(600));
27 INSERT INTO t1 VALUES(3, randomblob(600));
28 }
29
30 proc db_hit_miss {db {reset 0}} {
31 set nHit [sqlite3_db_status $db CACHE_HIT $reset]
32 set nMiss [sqlite3_db_status $db CACHE_MISS $reset]
33 list $nHit $nMiss
34 }
35
36 proc db_write {db {reset 0}} {
37 sqlite3_db_status $db CACHE_WRITE $reset
38 }
39
40 do_test 1.1 {
41 db close
42 sqlite3 db test.db
43 execsql { PRAGMA mmap_size = 0 }
44 expr {[file size test.db] / 1024}
45 } 6
46
47 do_test 1.2 {
48 execsql { SELECT b FROM t1 WHERE a=2 }
49 db_hit_miss db
50 } {{0 2 0} {0 4 0}}
51
52 do_test 1.3 {
53 execsql { SELECT b FROM t1 WHERE a=2 }
54 db_hit_miss db
55 } {{0 6 0} {0 4 0}}
56
57 do_test 1.4 {
58 execsql { SELECT b FROM t1 WHERE a=2 }
59 db_hit_miss db
60 } {{0 10 0} {0 4 0}}
61
62 do_test 1.5 {
63 db_hit_miss db 1
64 } {{0 10 0} {0 4 0}}
65
66 do_test 1.6 {
67 db_hit_miss db 0
68 } {{0 0 0} {0 0 0}}
69
70 do_test 1.7 {
71 set fd [db incrblob main t1 b 1]
72 fconfigure $fd -translation binary
73 set len [string length [read $fd]]
74 close $fd
75 set len
76 } 600
77 do_test 1.8 { sqlite3_db_status db CACHE_HIT 0 } {0 2 0}
78 do_test 1.9 { sqlite3_db_status db CACHE_MISS 0 } {0 1 0}
79
80 do_test 2.1 { db_write db } {0 0 0}
81 do_test 2.2 {
82 execsql { INSERT INTO t1 VALUES(4, randomblob(600)) }
83 db_write db
84 } {0 4 0}
85 do_test 2.3 { db_write db 1 } {0 4 0}
86 do_test 2.4 { db_write db 0 } {0 0 0}
87 do_test 2.5 { db_write db 1 } {0 0 0}
88
89 ifcapable wal {
90 do_test 2.6 {
91 execsql { PRAGMA journal_mode = WAL }
92 db_write db 1
93 } {0 1 0}
94 }
95 do_test 2.7 {
96 execsql { INSERT INTO t1 VALUES(5, randomblob(600)) }
97 db_write db
98 } {0 4 0}
99 do_test 2.8 { db_write db 1 } {0 4 0}
100 do_test 2.9 { db_write db 0 } {0 0 0}
101
102 finish_test
OLDNEW
« no previous file with comments | « third_party/sqlite/sqlite-src-3080704/test/dbstatus.test ('k') | third_party/sqlite/sqlite-src-3080704/test/default.test » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698