]>
git.saurik.com Git - redis.git/blob - tests/test_helper.tcl
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
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
19 set ::external 0; # If "1" this means, we are running against external instance
20 set ::file ""; # If set, runs only the tests in this comma separated list
21 set ::curfile ""; # Hold the filename of the current suite
23 proc execute_tests name
{
24 set path
"tests/$name.tcl"
29 # Setup a list to hold a stack of server configs. When calls to start_server
30 # are nested, use "srv 0 pid" to get the pid of the inner server. To access
31 # outer servers, use "srv -1 pid" etcetera.
35 if {[string is integer
[lindex $args 0]]} {
36 set level
[lindex $args 0]
37 set property
[lindex $args 1]
39 set property
[lindex $args 0]
41 set srv
[lindex $::servers end
+$level]
42 dict get
$srv $property
45 # Provide easy access to the client for the inner server. It's possible to
46 # prepend the argument list with a negative level to access clients for
47 # servers running in outer blocks.
50 if {[string is integer
[lindex $args 0]]} {
51 set level
[lindex $args 0]
52 set args
[lrange $args 1 end
]
54 [srv
$level "client"] {*}$args
57 proc reconnect
{args
} {
58 set level
[lindex $args 0]
59 if {[string length
$level] == 0 ||
![string is integer
$level]} {
63 set srv
[lindex $::servers end
+$level]
64 set host
[dict get
$srv "host"]
65 set port
[dict get
$srv "port"]
66 set config
[dict get
$srv "config"]
67 set client
[redis
$host $port]
68 dict
set srv
"client" $client
70 # select the right db when we don't have to authenticate
71 if {![dict exists
$config "requirepass"]} {
75 # re-set $srv in the servers list
76 set ::servers [lreplace $::servers end
+$level 1 $srv]
79 proc redis_deferring_client
{args
} {
81 if {[llength $args] > 0 && [string is integer
[lindex $args 0]]} {
82 set level
[lindex $args 0]
83 set args
[lrange $args 1 end
]
86 # create client that defers reading reply
87 set client
[redis
[srv
$level "host"] [srv
$level "port"] 1]
89 # select the right db and read the response (OK)
95 # Provide easy access to INFO properties. Same semantic as "proc r".
98 if {[string is integer
[lindex $args 0]]} {
99 set level
[lindex $args 0]
100 set args
[lrange $args 1 end
]
102 status
[srv
$level "client"] [lindex $args 0]
106 catch {exec rm
-rf {*}[glob tests
/tmp
/redis.conf.
*]}
107 catch {exec rm
-rf {*}[glob tests
/tmp
/server.
*]}
110 proc execute_everything
{} {
111 execute_tests
"unit/auth"
112 execute_tests
"unit/protocol"
113 execute_tests
"unit/basic"
114 execute_tests
"unit/type/list"
115 execute_tests
"unit/type/set"
116 execute_tests
"unit/type/zset"
117 execute_tests
"unit/type/hash"
118 execute_tests
"unit/sort"
119 execute_tests
"unit/expire"
120 execute_tests
"unit/other"
121 execute_tests
"unit/cas"
122 execute_tests
"unit/quit"
123 execute_tests
"integration/replication"
124 execute_tests
"integration/aof"
125 # execute_tests "integration/redis-cli"
126 execute_tests
"unit/pubsub"
128 # run tests with VM enabled
129 set ::global_overrides {vm-enabled yes
}
130 execute_tests
"unit/protocol"
131 execute_tests
"unit/basic"
132 execute_tests
"unit/type/list"
133 execute_tests
"unit/type/set"
134 execute_tests
"unit/type/zset"
135 execute_tests
"unit/type/hash"
136 execute_tests
"unit/sort"
137 execute_tests
"unit/expire"
138 execute_tests
"unit/other"
139 execute_tests
"unit/cas"
145 if {[string length
$::file] > 0} {
146 foreach {file} [split $::file ,] {
154 puts "\n[expr $::num_tests] tests, $::num_passed passed, $::num_failed failed\n"
155 if {$::num_failed > 0} {
158 foreach {test
} $::tests_failed {
159 set header
[lindex $test 0]
161 append header
[join [lindex $test 1] ","]
164 if {$curheader ne
$header} {
165 set curheader
$header
169 set name
[lindex $test 2]
170 set msg
[lindex $test 3]
180 for {set j
0} {$j < [llength $argv]} {incr j
} {
181 set opt
[lindex $argv $j]
182 set arg
[lindex $argv [expr $j+1]]
183 if {$opt eq
{--tags}} {
185 if {[string index
$tag 0] eq
"-"} {
186 lappend ::denytags [string range
$tag 1 end
]
188 lappend ::allowtags $tag
192 } elseif
{$opt eq
{--valgrind}} {
194 } elseif
{$opt eq
{--file}} {
197 } elseif
{$opt eq
{--host}} {
201 } elseif
{$opt eq
{--port}} {
204 } elseif
{$opt eq
{--verbose}} {
207 puts "Wrong argument: $opt"
212 if {[catch { main
} err
]} {
213 if {[string length
$err] > 0} {
214 # only display error when not generated by the test suite
215 if {$err ne
"exception"} {