a few more tests and ability to run a specific test in test-redis.tcl

This commit is contained in:
antirez 2009-12-14 13:48:24 -05:00
parent 49b99ab43e
commit fc77604c47
2 changed files with 59 additions and 7 deletions

View File

@ -57,7 +57,7 @@ redis-cli: $(CLIOBJ)
$(CC) -c $(CFLAGS) $(DEBUG) $(COMPILE_TIME) $< $(CC) -c $(CFLAGS) $(DEBUG) $(COMPILE_TIME) $<
clean: clean:
rm -rf $(PRGNAME) $(BENCHPRGNAME) $(CLIPRGNAME) *.o rm -rf $(PRGNAME) $(BENCHPRGNAME) $(CLIPRGNAME) *.o *.gcda *.gcno *.gcov
dep: dep:
$(CC) -MM *.c $(CC) -MM *.c
@ -80,5 +80,8 @@ log:
gprof: gprof:
make PROF="-pg" make PROF="-pg"
gcov:
make PROF="-fprofile-arcs -ftest-coverage"
32bitgprof: 32bitgprof:
make PROF="-pg" ARCH="-arch i386" make PROF="-pg" ARCH="-arch i386"

View File

@ -8,9 +8,12 @@ source redis.tcl
set ::passed 0 set ::passed 0
set ::failed 0 set ::failed 0
set ::testnum 0
proc test {name code okpattern} { proc test {name code okpattern} {
puts -nonewline [format "%-70s " $name] incr ::testnum
if {$::testnum < $::first || $::testnum > $::last} return
puts -nonewline [format "%-70s " "#$::testnum $name"]
flush stdout flush stdout
set retval [uplevel 1 $code] set retval [uplevel 1 $code]
if {$okpattern eq $retval || [string match $okpattern $retval]} { if {$okpattern eq $retval || [string match $okpattern $retval]} {
@ -53,6 +56,7 @@ proc main {server port} {
set r [redis $server $port] set r [redis $server $port]
$r select 9 $r select 9
set err "" set err ""
set res ""
# The following AUTH test should be enabled only when requirepass # The following AUTH test should be enabled only when requirepass
# <PASSWORD> is set in redis.conf and redis-server was started with # <PASSWORD> is set in redis.conf and redis-server was started with
@ -925,6 +929,14 @@ proc main {server port} {
list $aux1 $aux2 list $aux1 $aux2
} {{x y z} {y x z}} } {{x y z} {y x z}}
test {ZCARD basics} {
$r zcard ztmp
} {3}
test {ZCARD non existing key} {
$r zcard ztmp-blabla
} {0}
test {ZSCORE} { test {ZSCORE} {
set aux {} set aux {}
set err {} set err {}
@ -1225,7 +1237,6 @@ proc main {server port} {
if {$::failed > 0} { if {$::failed > 0} {
puts "\n*** WARNING!!! $::failed FAILED TESTS ***\n" puts "\n*** WARNING!!! $::failed FAILED TESTS ***\n"
} }
close $fd
} }
proc stress {} { proc stress {} {
@ -1262,8 +1273,48 @@ proc stress {} {
$r close $r close
} }
# Set a few configuration defaults
set ::host 127.0.0.1
set ::port 6379
set ::stress 0
set ::flush 0
set ::first 0
set ::last 1000000
# Parse arguments
for {set j 0} {$j < [llength $argv]} {incr j} {
set opt [lindex $argv $j]
set arg [lindex $argv [expr $j+1]]
set lastarg [expr {$arg eq {}}]
if {$opt eq {-h} && !$lastarg} {
set ::host $arg
incr j
} elseif {$opt eq {-p} && !$lastarg} {
set ::port $arg
incr j
} elseif {$opt eq {-stress}} {
set ::stress 1
} elseif {$opt eq {--flush}} {
set ::flush 1
} elseif {$opt eq {--first} && !$lastarg} {
set ::first $arg
incr j
} elseif {$opt eq {--last} && !$lastarg} {
set ::last $arg
incr j
} else {
echo "Wrong argument: $opt"
exit 1
}
}
# Before to run the test check if DB 9 and DB 10 are empty # Before to run the test check if DB 9 and DB 10 are empty
set r [redis] set r [redis]
if {$::flush} {
$r flushall
}
$r select 9 $r select 9
set db9size [$r dbsize] set db9size [$r dbsize]
$r select 10 $r select 10
@ -1277,10 +1328,8 @@ unset r
unset db9size unset db9size
unset db10size unset db10size
if {[llength $argv] == 0} { if {$::stress} {
main 127.0.0.1 6379
} elseif {[llength $argv] == 1 && [lindex $argv 0] eq {stress}} {
stress stress
} else { } else {
main [lindex $argv 0] [lindex $argv 1] main $::host $::port
} }