btest: More verbose recursive-event output

I don't think something broken, but the one line output.
This commit is contained in:
Arne Welzel 2023-03-15 15:16:57 +01:00
parent 3269310e61
commit 9c5b439e8f
2 changed files with 40 additions and 14 deletions

View file

@ -1,2 +1,22 @@
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
10
XXXXXXXXXX.XXXXXX 0 1
XXXXXXXXXX.XXXXXX 1 2
XXXXXXXXXX.XXXXXX 0 3
XXXXXXXXXX.XXXXXX 1 4
XXXXXXXXXX.XXXXXX 0 5
XXXXXXXXXX.XXXXXX 1 6
XXXXXXXXXX.XXXXXX 0 7
XXXXXXXXXX.XXXXXX 1 8
XXXXXXXXXX.XXXXXX 0 9
XXXXXXXXXX.XXXXXX 1 10
XXXXXXXXXX.XXXXXX 0 11
XXXXXXXXXX.XXXXXX 1 12
XXXXXXXXXX.XXXXXX 0 13
XXXXXXXXXX.XXXXXX 1 14
XXXXXXXXXX.XXXXXX 0 15
XXXXXXXXXX.XXXXXX 1 16
XXXXXXXXXX.XXXXXX 0 17
XXXXXXXXXX.XXXXXX 1 18
XXXXXXXXXX.XXXXXX 0 19
XXXXXXXXXX.XXXXXX 1 20
unique_nt 11

View file

@ -1,32 +1,38 @@
# @TEST-EXEC: zeek -b %INPUT 2>&1 | grep -v termination | sort | uniq | wc -l | awk '{print $1}' >output
# @TEST-EXEC: zeek -b %INPUT >output
# @TEST-EXEC: btest-diff output
# In old version, the event would keep triggering endlessly, with the network
# time not moving forward and Zeek not terminating.
#
# Note that the output will not be 20 because we still execute two rounds
# of events every time we drain and also at startup several (currently 3)
# rounds of events drain with the same network_time.
redef exit_only_after_terminate=T;
global c = 0;
global last_nt = 0.0;
global unique_nt: set[double];
event test()
{
c += 1;
local nt = time_to_double(network_time());
if ( last_nt == 0.0 )
last_nt = nt;
add unique_nt[nt];
print fmt("%.5f %d %d", nt, nt != last_nt, c);
last_nt = nt;
if ( c == 20 )
{
print fmt("unique_nt %d", |unique_nt|);
terminate();
return;
}
print network_time();
event test();
}
event test();
}
event zeek_init()
{
event test();
}
{
event test();
}