]>
git.saurik.com Git - redis.git/blob - test/support/util.tcl
1 proc randstring
{min max
{type
binary}} {
2 set len
[expr {$min+int
(rand
()*($max-$min+1))}]
4 if {$type eq
{binary}} {
7 } elseif
{$type eq
{alpha
}} {
10 } elseif
{$type eq
{compr
}} {
15 append output
[format "%c" [expr {$minval+int
(rand
()*($maxval-$minval+1))}]]
21 # Useful for some test
22 proc zlistAlikeSort
{a b
} {
23 if {[lindex $a 0] > [lindex $b 0]} {return 1}
24 if {[lindex $a 0] < [lindex $b 0]} {return -1}
25 string compare
[lindex $a 1] [lindex $b 1]
28 proc waitForBgsave r
{
31 if {[string match
{*bgsave_in_progress
:1*} $i]} {
32 puts -nonewline "\nWaiting for background save to finish... "
41 proc waitForBgrewriteaof r
{
44 if {[string match
{*bgrewriteaof_in_progress
:1*} $i]} {
45 puts -nonewline "\nWaiting for background AOF rewrite to finish... "
54 proc randomInt
{max
} {
55 expr {int
(rand
()*$max)}
59 set path
[expr {int
(rand
()*[llength $args])}]
60 uplevel 1 [lindex $args $path]
65 # Small enough to likely collide
68 # 32 bit compressible signed/unsigned
69 randpath
{randomInt
2000000000} {randomInt
4000000000}
72 randpath
{randomInt
1000000000000}
75 randpath
{randstring
0 256 alpha
} \
76 {randstring
0 256 compr
} \
77 {randstring
0 256 binary}
83 # Small enough to likely collide
86 # 32 bit compressible signed/unsigned
87 randpath
{randomInt
2000000000} {randomInt
4000000000}
90 randpath
{randomInt
1000000000000}
93 randpath
{randstring
1 256 alpha
} \
94 {randstring
1 256 compr
}
98 proc createComplexDataset
{r ops
} {
99 for {set j
0} {$j < $ops} {incr j
} {
104 set d
[expr {rand
()}]
106 set d
[expr {rand
()}]
108 set d
[expr {rand
()}]
110 set d
[expr {rand
()}]
112 set d
[expr {rand
()}]
114 randpath
{set d
+inf
} {set d
-inf}
138 randpath
{$r lpush
$k $v} \
145 randpath
{$r sadd
$k $v} \
149 randpath
{$r zadd
$k $d $v} \
153 randpath
{$r hset
$k $f $v} \