zeek/testing/btest/spicy/terminate-session.zeek
Benjamin Bannier 8049d3a002 Speed up Spicy-related tests.
This patch changes invocations of `spicyz` and similar Spicy tools in
tests which perform compilation to use debug mode via passing `-d`. This
in turn leads to Spicy compiling generated C++ code in debug as opposed
to release mode which typically seems to require less CPU time and RAM.
For a local test running with `btest -j 16` and no caching via
`HILTI_CXX_COMPILER_LAUNCER` this sped up running of BTests under
`spicy/` by about 40s on my machine (120s vs 160s).
2023-05-25 14:59:10 +02:00

41 lines
1.1 KiB
Text

# @TEST-REQUIRES: have-spicy
#
# @TEST-EXEC: spicyz -d -o test.hlto test.spicy test.evt
# @TEST-EXEC: zeek -b -r ${TRACES}/dns/long-connection.pcap Zeek::Spicy test.hlto base/protocols/conn %INPUT
# @TEST-EXEC: cat conn.log | zeek-cut uid -C > conn.log2 && mv conn.log2 conn.log
# @TEST-EXEC: btest-diff conn.log
#
# @TEST-DOC: Validate that `terminate_session` indeed flushes Zeek-side connection state
#
# We expect to see two conn.log entries instead of one.
redef likely_server_ports += { 53/udp }; # avoid flipping direction after termination
redef udp_inactivity_timeout = 24hrs; # avoid long gaps to trigger removal
# @TEST-START-FILE test.spicy
module Test;
import zeek;
public type Foo = unit {
on %done {
self.context().counter = self.context().counter + 1;
# close the connection if it is too long
if ( self.context().counter >= 10 )
zeek::terminate_session();
}
x : /./;
%context = Counter;
};
type Counter = tuple<counter:int64>;
# @TEST-END-FILE
# @TEST-START-FILE test.evt
protocol analyzer spicy::Test over UDP:
port 53/udp,
parse originator with Test::Foo;
# @TEST-END-FILE