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

Side by Side Diff: third_party/sqlite/sqlite-src-3080704/test/shell4.test

Issue 883353008: [sql] Import reference version of SQLite 3.8.7.4. (Closed) Base URL: http://chromium.googlesource.com/chromium/src.git@master
Patch Set: Hold back encoding change which is messing up patch. 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
1 # 2010 July 28 1 # 2010 July 28
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 #***********************************************************************
11 # 11 #
12 # The focus of this file is testing the CLI shell tool. 12 # The focus of this file is testing the CLI shell tool.
13 # These tests are specific to the .stats command. 13 # These tests are specific to the .stats command.
14 # 14 #
15 # $Id: shell4.test,v 1.7 2009/07/17 16:54:48 shaneh Exp $ 15 # $Id: shell4.test,v 1.7 2009/07/17 16:54:48 shaneh Exp $
16 # 16 #
17 17
18 # Test plan: 18 # Test plan:
19 # 19 #
20 # shell4-1.*: Basic tests specific to the "stats" command. 20 # shell4-1.*: Basic tests specific to the "stats" command.
21 # 21 #
22 22 set testdir [file dirname $argv0]
23 set CLI "./sqlite3" 23 source $testdir/tester.tcl
24 24 if {$tcl_platform(platform)=="windows"} {
25 proc do_test {name cmd expected} { 25 set CLI "sqlite3.exe"
26 puts -nonewline "$name ..." 26 } else {
27 set res [uplevel $cmd] 27 set CLI "./sqlite3"
28 if {$res eq $expected} {
29 puts Ok
30 } else {
31 puts Error
32 puts " Got: $res"
33 puts " Expected: $expected"
34 exit
35 }
36 } 28 }
37 29 if {![file executable $CLI]} {
38 proc catchcmd {db {cmd ""}} { 30 finish_test
39 global CLI 31 return
40 set out [open cmds.txt w]
41 puts $out $cmd
42 close $out
43 set line "exec $CLI $db < cmds.txt"
44 set rc [catch { eval $line } msg]
45 list $rc $msg
46 } 32 }
47 33 db close
48 file delete -force test.db test.db.journal 34 forcedelete test.db test.db-journal test.db-wal
35 sqlite3 db test.db
49 36
50 #---------------------------------------------------------------------------- 37 #----------------------------------------------------------------------------
51 # Test cases shell4-1.*: Tests specific to the "stats" command. 38 # Test cases shell4-1.*: Tests specific to the "stats" command.
52 # 39 #
53 40
54 # should default to off 41 # should default to off
55 do_test shell4-1.1.1 { 42 do_test shell4-1.1.1 {
56 set res [catchcmd "test.db" ".show"] 43 set res [catchcmd "test.db" ".show"]
57 list [regexp {stats: off} $res] 44 list [regexp {stats: off} $res]
58 } {1} 45 } {1}
(...skipping 10 matching lines...) Expand all
69 } {1} 56 } {1}
70 57
71 do_test shell4-1.2.2 { 58 do_test shell4-1.2.2 {
72 set res [catchcmd "-stats test.db" ".show"] 59 set res [catchcmd "-stats test.db" ".show"]
73 list [regexp {stats: off} $res] 60 list [regexp {stats: off} $res]
74 } {0} 61 } {0}
75 62
76 # .stats ON|OFF Turn stats on or off 63 # .stats ON|OFF Turn stats on or off
77 do_test shell4-1.3.1 { 64 do_test shell4-1.3.1 {
78 catchcmd "test.db" ".stats" 65 catchcmd "test.db" ".stats"
79 } {1 {Error: unknown command or invalid arguments: "stats". Enter ".help" for h elp}} 66 } {1 {Usage: .stats on|off}}
80 do_test shell4-1.3.2 { 67 do_test shell4-1.3.2 {
81 catchcmd "test.db" ".stats ON" 68 catchcmd "test.db" ".stats ON"
82 } {0 {}} 69 } {0 {}}
83 do_test shell4-1.3.3 { 70 do_test shell4-1.3.3 {
84 catchcmd "test.db" ".stats OFF" 71 catchcmd "test.db" ".stats OFF"
85 } {0 {}} 72 } {0 {}}
86 do_test shell4-1.3.4 { 73 do_test shell4-1.3.4 {
87 # too many arguments 74 # too many arguments
88 catchcmd "test.db" ".stats OFF BAD" 75 catchcmd "test.db" ".stats OFF BAD"
89 } {1 {Error: unknown command or invalid arguments: "stats". Enter ".help" for h elp}} 76 } {1 {Usage: .stats on|off}}
90 77
91 # NB. whitespace is important 78 # NB. whitespace is important
92 do_test shell4-1.4.1 { 79 do_test shell4-1.4.1 {
93 set res [catchcmd "test.db" {.show}] 80 set res [catchcmd "test.db" {.show}]
94 list [regexp {stats: off} $res] 81 list [regexp {stats: off} $res]
95 } {1} 82 } {1}
96 83
97 do_test shell4-1.4.2 { 84 do_test shell4-1.4.2 {
98 set res [catchcmd "test.db" {.stats ON 85 set res [catchcmd "test.db" {.stats ON
99 .show 86 .show
(...skipping 19 matching lines...) Expand all
119 # make sure stats are present when on 106 # make sure stats are present when on
120 do_test shell4-1.5.2 { 107 do_test shell4-1.5.2 {
121 set res [catchcmd "test.db" {.stats ON 108 set res [catchcmd "test.db" {.stats ON
122 SELECT 1; 109 SELECT 1;
123 }] 110 }]
124 list [regexp {Memory Used} $res] \ 111 list [regexp {Memory Used} $res] \
125 [regexp {Heap Usage} $res] \ 112 [regexp {Heap Usage} $res] \
126 [regexp {Autoindex Inserts} $res] 113 [regexp {Autoindex Inserts} $res]
127 } {1 1 1} 114 } {1 1 1}
128 115
129 puts "CLI tests completed successfully" 116 finish_test
OLDNEW
« no previous file with comments | « third_party/sqlite/sqlite-src-3080704/test/shell3.test ('k') | third_party/sqlite/sqlite-src-3080704/test/shell5.test » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698