zeek/testing/btest/spicy/file-analysis-data-in-concurrent.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

60 lines
1.4 KiB
Text

# @TEST-REQUIRES: have-spicy
#
# @TEST-EXEC: spicyz -d -o test.hlto ssh.spicy ./ssh-cond.evt
# @TEST-EXEC: zeek -r ${TRACES}/ssh/single-conn.trace test.hlto %INPUT Spicy::enable_print=T >output
# @TEST-EXEC: btest-diff output
# @TEST-START-FILE ssh.spicy
module SSH;
import spicy;
import zeek;
type Context = tuple<data_chunks: uint64>;
public type Banner = unit {
%context = Context;
magic : /SSH-/;
version : /[^-]*/;
dash : /-/;
software: /[^\r\n]*/;
};
public type Data = unit {
data: bytes &eod;
on %done { print self.data; }
};
on Banner::%done {
local fid1 = zeek::file_begin("foo/bar");
local fid2 = zeek::file_begin("foo/bar");
local fid3 = zeek::file_begin("foo/bar");
zeek::file_data_in(b"12", fid1);
zeek::file_data_in(b"!", fid3);
zeek::file_data_in(b"AAA", fid2);
zeek::file_data_in(b"@", fid3);
zeek::file_data_in(b"34", fid1);
zeek::file_data_in(b"#", fid3);
zeek::file_data_in(b"56", fid1);
zeek::file_data_in(b"BBB", fid2);
zeek::file_data_in(b"$"); # -> fid3
zeek::file_end(fid1);
zeek::file_data_in(b"CCC", fid2);
zeek::file_end(fid2);
zeek::file_end(fid3);
}
# @TEST-END-FILE
# @TEST-START-FILE ssh-cond.evt
import zeek;
protocol analyzer spicy::SSH over TCP:
parse originator with SSH::Banner,
port 22/tcp,
replaces SSH;
file analyzer spicy::Text:
parse with SSH::Data,
mime-type foo/bar;
# @TEST-END-FILE