Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
42086667
Commit
42086667
authored
Mar 15, 2019
by
antirez
Browse files
HyperLogLog: dense/sparse repr parsing fuzz test.
parent
9f13b2bd
Changes
1
Hide whitespace changes
Inline
Side-by-side
tests/unit/hyperloglog.tcl
View file @
42086667
...
...
@@ -115,6 +115,35 @@ start_server {tags {"hll"}} {
set e
}
{
*WRONGTYPE*
}
test
{
Fuzzing dense/sparse encoding: Redis should always detect errors
}
{
for
{
set j 0
}
{
$j
< 10000
}
{
incr j
}
{
r del hll
set items
{}
set numitems
[
randomInt 3000
]
for
{
set i 0
}
{
$i
< $numitems
}
{
incr i
}
{
lappend items
[
expr
{
rand
()}]
}
r pfadd hll
{*}
$items
# Corrupt it in some random way.
for
{
set i 0
}
{
$i
< 5
}
{
incr i
}
{
set len
[
r strlen hll
]
set pos
[
randomInt $len
]
set byte
[
randstring 1 1 binary
]
r setrange hll $pos $byte
# Don't modify more bytes 50% of times
if
{
rand
()
< 0.5
}
break
}
# Use the hyperloglog to check if it crashes
# Redis in some way.
catch
{
r pfcount hll
r pfdebug getreg hll
}
}
}
test
{
PFADD, PFCOUNT, PFMERGE type checking works
}
{
r set foo bar
catch
{
r pfadd foo 1
}
e
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment