]>
Commit | Line | Data |
---|---|---|
98578b57 PN |
1 | # Redis test suite. Copyright (C) 2009 Salvatore Sanfilippo antirez@gmail.com |
2 | # This softare is released under the BSD License. See the COPYING file for | |
3 | # more information. | |
4 | ||
5 | set tcl_precision 17 | |
ab72b483 | 6 | source tests/support/redis.tcl |
7 | source tests/support/server.tcl | |
8 | source tests/support/tmpfile.tcl | |
9 | source tests/support/test.tcl | |
10 | source tests/support/util.tcl | |
98578b57 PN |
11 | |
12 | set ::host 127.0.0.1 | |
47bebf15 | 13 | set ::port 16379 |
e59a64b8 | 14 | set ::traceleaks 0 |
c4669d25 | 15 | set ::valgrind 0 |
6e0e5bed PN |
16 | set ::denytags {} |
17 | set ::allowtags {} | |
7d04fc75 | 18 | set ::external 0; # If "1" this means, we are running against external instance |
9f1ae9ab | 19 | set ::file ""; # If set, runs only the tests in this comma separated list |
98578b57 PN |
20 | |
21 | proc execute_tests name { | |
ab72b483 | 22 | source "tests/$name.tcl" |
98578b57 PN |
23 | } |
24 | ||
1c4114be PN |
25 | # Setup a list to hold a stack of server configs. When calls to start_server |
26 | # are nested, use "srv 0 pid" to get the pid of the inner server. To access | |
27 | # outer servers, use "srv -1 pid" etcetera. | |
28 | set ::servers {} | |
f2dd4769 PN |
29 | proc srv {args} { |
30 | set level 0 | |
31 | if {[string is integer [lindex $args 0]]} { | |
32 | set level [lindex $args 0] | |
33 | set property [lindex $args 1] | |
34 | } else { | |
35 | set property [lindex $args 0] | |
36 | } | |
1c4114be PN |
37 | set srv [lindex $::servers end+$level] |
38 | dict get $srv $property | |
39 | } | |
40 | ||
41 | # Provide easy access to the client for the inner server. It's possible to | |
42 | # prepend the argument list with a negative level to access clients for | |
43 | # servers running in outer blocks. | |
98578b57 | 44 | proc r {args} { |
1c4114be PN |
45 | set level 0 |
46 | if {[string is integer [lindex $args 0]]} { | |
47 | set level [lindex $args 0] | |
48 | set args [lrange $args 1 end] | |
49 | } | |
50 | [srv $level "client"] {*}$args | |
51 | } | |
52 | ||
5eedc9c6 PN |
53 | proc redis_deferring_client {args} { |
54 | set level 0 | |
55 | if {[llength $args] > 0 && [string is integer [lindex $args 0]]} { | |
56 | set level [lindex $args 0] | |
57 | set args [lrange $args 1 end] | |
58 | } | |
59 | ||
60 | # create client that defers reading reply | |
61 | set client [redis [srv $level "host"] [srv $level "port"] 1] | |
62 | ||
63 | # select the right db and read the response (OK) | |
64 | $client select 9 | |
65 | $client read | |
66 | return $client | |
67 | } | |
68 | ||
1c4114be PN |
69 | # Provide easy access to INFO properties. Same semantic as "proc r". |
70 | proc s {args} { | |
71 | set level 0 | |
72 | if {[string is integer [lindex $args 0]]} { | |
73 | set level [lindex $args 0] | |
74 | set args [lrange $args 1 end] | |
75 | } | |
76 | status [srv $level "client"] [lindex $args 0] | |
98578b57 PN |
77 | } |
78 | ||
f166bb1d | 79 | proc cleanup {} { |
c4669d25 | 80 | catch {exec rm -rf {*}[glob tests/tmp/redis.conf.*]} |
81 | catch {exec rm -rf {*}[glob tests/tmp/server.*]} | |
f166bb1d PN |
82 | } |
83 | ||
9f1ae9ab | 84 | proc execute_everything {} { |
98578b57 PN |
85 | execute_tests "unit/auth" |
86 | execute_tests "unit/protocol" | |
87 | execute_tests "unit/basic" | |
88 | execute_tests "unit/type/list" | |
89 | execute_tests "unit/type/set" | |
90 | execute_tests "unit/type/zset" | |
91 | execute_tests "unit/type/hash" | |
92 | execute_tests "unit/sort" | |
93 | execute_tests "unit/expire" | |
94 | execute_tests "unit/other" | |
c20c189d | 95 | execute_tests "unit/cas" |
85ecc65e | 96 | execute_tests "integration/replication" |
53cbf66c | 97 | execute_tests "integration/aof" |
588cd980 | 98 | # execute_tests "integration/redis-cli" |
4589a823 | 99 | execute_tests "unit/pubsub" |
f166bb1d PN |
100 | |
101 | # run tests with VM enabled | |
d4507ec6 | 102 | set ::global_overrides {vm-enabled yes} |
f166bb1d PN |
103 | execute_tests "unit/protocol" |
104 | execute_tests "unit/basic" | |
105 | execute_tests "unit/type/list" | |
106 | execute_tests "unit/type/set" | |
107 | execute_tests "unit/type/zset" | |
108 | execute_tests "unit/type/hash" | |
109 | execute_tests "unit/sort" | |
110 | execute_tests "unit/expire" | |
111 | execute_tests "unit/other" | |
c20c189d | 112 | execute_tests "unit/cas" |
9f1ae9ab PN |
113 | } |
114 | ||
115 | proc main {} { | |
116 | cleanup | |
117 | ||
118 | if {[string length $::file] > 0} { | |
119 | foreach {file} [split $::file ,] { | |
120 | execute_tests $file | |
121 | } | |
122 | } else { | |
123 | execute_everything | |
124 | } | |
e39c8b50 PN |
125 | |
126 | cleanup | |
98578b57 PN |
127 | puts "\n[expr $::passed+$::failed] tests, $::passed passed, $::failed failed" |
128 | if {$::failed > 0} { | |
129 | puts "\n*** WARNING!!! $::failed FAILED TESTS ***\n" | |
e39c8b50 | 130 | exit 1 |
98578b57 | 131 | } |
98578b57 PN |
132 | } |
133 | ||
73bd6c58 PN |
134 | # parse arguments |
135 | for {set j 0} {$j < [llength $argv]} {incr j} { | |
136 | set opt [lindex $argv $j] | |
137 | set arg [lindex $argv [expr $j+1]] | |
138 | if {$opt eq {--tags}} { | |
139 | foreach tag $arg { | |
140 | if {[string index $tag 0] eq "-"} { | |
141 | lappend ::denytags [string range $tag 1 end] | |
142 | } else { | |
143 | lappend ::allowtags $tag | |
144 | } | |
145 | } | |
146 | incr j | |
9f1ae9ab PN |
147 | } elseif {$opt eq {--file}} { |
148 | set ::file $arg | |
149 | incr j | |
7d04fc75 | 150 | } elseif {$opt eq {--host}} { |
151 | set ::external 1 | |
152 | set ::host $arg | |
153 | incr j | |
154 | } elseif {$opt eq {--port}} { | |
155 | set ::port $arg | |
156 | incr j | |
73bd6c58 PN |
157 | } else { |
158 | puts "Wrong argument: $opt" | |
159 | exit 1 | |
160 | } | |
161 | } | |
162 | ||
436f18b6 PN |
163 | if {[catch { main } err]} { |
164 | if {[string length $err] > 0} { | |
165 | # only display error when not generated by the test suite | |
166 | if {$err ne "exception"} { | |
167 | puts $err | |
168 | } | |
169 | exit 1 | |
170 | } | |
171 | } |