]>
git.saurik.com Git - redis.git/blob - tests/unit/protocol.tcl
1 start_server
{tags
{"protocol"}} {
2 test
"Handle an empty query" {
6 assert_equal
"PONG" [r ping
]
9 test
"Negative multibulk length" {
13 assert_equal PONG
[r ping
]
16 test
"Out of range multibulk length" {
18 r write
"*20000000\r\n"
20 assert_error
"*invalid multibulk length*" {r
read}
23 test
"Wrong multibulk payload header" {
25 r write
"*3\r\n\$3\r\nSET\r\n\$1\r\nx\r\nfooz\r\n"
27 assert_error
"*expected '$', got 'f'*" {r
read}
30 test
"Negative multibulk payload length" {
32 r write
"*3\r\n\$3\r\nSET\r\n\$1\r\nx\r\n\$-10\r\n"
34 assert_error
"*invalid bulk length*" {r
read}
37 test
"Out of range multibulk payload length" {
39 r write
"*3\r\n\$3\r\nSET\r\n\$1\r\nx\r\n\$2000000000\r\n"
41 assert_error
"*invalid bulk length*" {r
read}
44 test
"Non-number multibulk payload length" {
46 r write
"*3\r\n\$3\r\nSET\r\n\$1\r\nx\r\n\$blabla\r\n"
48 assert_error
"*invalid bulk length*" {r
read}
51 test
"Multi bulk request not followed by bulk arguments" {
53 r write
"*1\r\nfoo\r\n"
55 assert_error
"*expected '$', got 'f'*" {r
read}
58 test
"Generic wrong number of args" {
60 assert_error
"*wrong*arguments*ping*" {r ping x y z
}
64 foreach seq
[list "\x00" "*\x00" "$\x00"] {
66 test
"Protocol desync regression test #$c" {
67 set s
[socket [srv
0 host
] [srv
0 port
]]
68 puts -nonewline $s $seq
69 set payload
[string repeat A
1024]"\n"
70 set test_start
[clock seconds
]
74 puts -nonewline $s payload
76 incr payload_size
[string length
$payload]
82 set elapsed
[expr {[clock seconds
]-$test_start}]
83 if {$elapsed > $test_time_limit} {
85 error "assertion:Redis did not closed connection after protocol desync"
95 start_server
{tags
{"regression"}} {
96 test
"Regression for a crash with blocking ops and pipelining" {
97 set rd
[redis_deferring_client
]
99 set proto
"*3\r\n\$5\r\nBLPOP\r\n\$6\r\nnolist\r\n\$1\r\n0\r\n"
100 puts -nonewline $fd $proto$proto