Skip to content

Commit

Permalink
Fix clearing action for some aggregations
Browse files Browse the repository at this point in the history
  • Loading branch information
javierhonduco authored and danobi committed May 24, 2019
1 parent c4c6894 commit dcd657e
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/bpftrace.cpp
Expand Up @@ -890,7 +890,8 @@ int BPFtrace::clear_map(IMap &map)
std::vector<uint8_t> old_key;
try
{
if (map.type_.type == Type::hist)
if (map.type_.type == Type::hist || map.type_.type == Type::lhist ||
map.type_.type == Type::stats || map.type_.type == Type::avg)
// hist maps have 8 extra bytes for the bucket number
old_key = find_empty_key(map, map.key_.size() + 8);
else
Expand Down
20 changes: 20 additions & 0 deletions tests/runtime/other
Expand Up @@ -57,3 +57,23 @@ NAME struct positional string compare - not equal
RUN bpftrace -v -e 'BEGIN { if (str($1) != str($2)) { printf("I got %s\n", str($1));} else { printf("not equal\n");} exit();}' "hello" "hello"
EXPECT not equal
TIMEOUT 5

NAME lhist can be cleared
RUN bpftrace -e 'BEGIN{ @[1] = lhist(3,0,10,1); clear(@); exit() }'
EXPECT .*
TIMEOUT 1

NAME hist can be cleared
RUN bpftrace -e 'BEGIN{ @[1] = hist(1); clear(@); exit() }'
EXPECT .*
TIMEOUT 1

NAME stats can be cleared
RUN bpftrace -e 'BEGIN{ @[1] = stats(1); clear(@); exit() }'
EXPECT .*
TIMEOUT 1

NAME avg can be cleared
RUN bpftrace -e 'BEGIN{ @[1] = avg(1); clear(@); exit() }'
EXPECT .*
TIMEOUT 1

0 comments on commit dcd657e

Please sign in to comment.