mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 06:38:20 +00:00
Add tests for bundled Spicy infrastructure.
This commit is contained in:
parent
95aff9a1e3
commit
e40aa0f6d2
8 changed files with 114 additions and 1 deletions
10
testing/btest/Baseline/spicy.spicy-dump/output
Normal file
10
testing/btest/Baseline/spicy.spicy-dump/output
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
||||||
|
test::X {
|
||||||
|
xs: [
|
||||||
|
11
|
||||||
|
22
|
||||||
|
33
|
||||||
|
44
|
||||||
|
55
|
||||||
|
]
|
||||||
|
}
|
5
testing/btest/Baseline/spicy.spicyz-aot/output
Normal file
5
testing/btest/Baseline/spicy.spicyz-aot/output
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
||||||
|
8, [$data=[b"POST /post HTTP/1.1", b"User-Agent: curl/7.29.0", b"Host: httpbin.org", b"Accept: */*", b"Content-Length: 11", b"Content-Type: application/x-www-form-urlencoded", b"", b"hello world"]]
|
||||||
|
Event:, [POST /post HTTP/1.1, User-Agent: curl/7.29.0, Host: httpbin.org, Accept: */*, Content-Length: 11, Content-Type: application/x-www-form-urlencoded, , hello world]
|
||||||
|
8, [$data=[b"HTTP/1.1 200 OK", b"Server: gunicorn/0.16.1", b"Date: Tue, 19 Mar 2013 16:05:11 GMT", b"Content-Type: application/json", b"Content-Length: 366", b"Connection: close", b"", b"{\x0a \"origin\": \"10.142.133.148\",\x0a \"files\": {},\x0a \"form\": null,\x0a \"url\": \"http://httpbin.org/post\",\x0a \"args\": {},\x0a \"headers\": {\x0a \"Content-Length\": \"11\",\x0a \"Connection\": \"close\",\x0a \"Accept\": \"*/*\",\x0a \"User-Agent\": \"curl/7.29.0\",\x0a \"Host\": \"httpbin.org\",\x0a \"Content-Type\": \"application/x-www-form-urlencoded\"\x0a },\x0a \"json\": null,\x0a \"data\": \"hello world\"\x0a}"]]
|
||||||
|
Event:, [HTTP/1.1 200 OK, Server: gunicorn/0.16.1, Date: Tue, 19 Mar 2013 16:05:11 GMT, Content-Type: application/json, Content-Length: 366, Connection: close, , {\x0a "origin": "10.142.133.148",\x0a "files": {},\x0a "form": null,\x0a "url": "http://httpbin.org/post",\x0a "args": {},\x0a "headers": {\x0a "Content-Length": "11",\x0a "Connection": "close",\x0a "Accept": "*/*",\x0a "User-Agent": "curl/7.29.0",\x0a "Host": "httpbin.org",\x0a "Content-Type": "application/x-www-form-urlencoded"\x0a },\x0a "json": null,\x0a "data": "hello world"\x0a}]
|
5
testing/btest/Baseline/spicy.spicyz-jit/output
Normal file
5
testing/btest/Baseline/spicy.spicyz-jit/output
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
||||||
|
8, [$data=[b"POST /post HTTP/1.1", b"User-Agent: curl/7.29.0", b"Host: httpbin.org", b"Accept: */*", b"Content-Length: 11", b"Content-Type: application/x-www-form-urlencoded", b"", b"hello world"]]
|
||||||
|
Event:, [POST /post HTTP/1.1, User-Agent: curl/7.29.0, Host: httpbin.org, Accept: */*, Content-Length: 11, Content-Type: application/x-www-form-urlencoded, , hello world]
|
||||||
|
8, [$data=[b"HTTP/1.1 200 OK", b"Server: gunicorn/0.16.1", b"Date: Tue, 19 Mar 2013 16:05:11 GMT", b"Content-Type: application/json", b"Content-Length: 366", b"Connection: close", b"", b"{\x0a \"origin\": \"10.142.133.148\",\x0a \"files\": {},\x0a \"form\": null,\x0a \"url\": \"http://httpbin.org/post\",\x0a \"args\": {},\x0a \"headers\": {\x0a \"Content-Length\": \"11\",\x0a \"Connection\": \"close\",\x0a \"Accept\": \"*/*\",\x0a \"User-Agent\": \"curl/7.29.0\",\x0a \"Host\": \"httpbin.org\",\x0a \"Content-Type\": \"application/x-www-form-urlencoded\"\x0a },\x0a \"json\": null,\x0a \"data\": \"hello world\"\x0a}"]]
|
||||||
|
Event:, [HTTP/1.1 200 OK, Server: gunicorn/0.16.1, Date: Tue, 19 Mar 2013 16:05:11 GMT, Content-Type: application/json, Content-Length: 366, Connection: close, , {\x0a "origin": "10.142.133.148",\x0a "files": {},\x0a "form": null,\x0a "url": "http://httpbin.org/post",\x0a "args": {},\x0a "headers": {\x0a "Content-Length": "11",\x0a "Connection": "close",\x0a "Accept": "*/*",\x0a "User-Agent": "curl/7.29.0",\x0a "Host": "httpbin.org",\x0a "Content-Type": "application/x-www-form-urlencoded"\x0a },\x0a "json": null,\x0a "data": "hello world"\x0a}]
|
|
@ -1,5 +1,5 @@
|
||||||
[btest]
|
[btest]
|
||||||
TestDirs = doc bifs language core scripts coverage signatures plugins broker supervisor telemetry
|
TestDirs = doc bifs language core scripts coverage signatures plugins broker spicy supervisor telemetry
|
||||||
TmpDir = %(testbase)s/.tmp
|
TmpDir = %(testbase)s/.tmp
|
||||||
BaselineDir = %(testbase)s/Baseline
|
BaselineDir = %(testbase)s/Baseline
|
||||||
IgnoreDirs = .svn CVS .tmp
|
IgnoreDirs = .svn CVS .tmp
|
||||||
|
@ -32,6 +32,8 @@ ZEEK_DISABLE_ZEEKYGEN=1
|
||||||
ZEEK_ALLOW_INIT_ERRORS=1
|
ZEEK_ALLOW_INIT_ERRORS=1
|
||||||
ZEEK_SUPERVISOR_NO_SIGKILL=1
|
ZEEK_SUPERVISOR_NO_SIGKILL=1
|
||||||
UBSAN_OPTIONS=print_stacktrace=1
|
UBSAN_OPTIONS=print_stacktrace=1
|
||||||
|
SPICY_PATH=`bash -c %(testbase)s/../../build/spicy-path`
|
||||||
|
HILTI_CXX_INCLUDE_DIRS=`bash -c %(testbase)s/../../build/hilti-cxx-include-dirs`
|
||||||
|
|
||||||
[environment-AST-dup]
|
[environment-AST-dup]
|
||||||
# Environment for testing AST duplication functionality, which is
|
# Environment for testing AST duplication functionality, which is
|
||||||
|
|
11
testing/btest/spicy/spicy-dump.spicy
Normal file
11
testing/btest/spicy/spicy-dump.spicy
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
# @TEST-DOC: Smoke test for a bundled Spicy.
|
||||||
|
#
|
||||||
|
# @TEST-REQUIRES: $SCRIPTS/have-spicy
|
||||||
|
# @TEST-EXEC: printf 12345 | ${BUILD}/auxil/spicy/spicy/bin/spicy-dump -d %INPUT >output 2>&1
|
||||||
|
# @TEST-EXEC: btest-diff output
|
||||||
|
|
||||||
|
module test;
|
||||||
|
|
||||||
|
public type X = unit {
|
||||||
|
xs: (bytes &size=1 &convert=$$.to_int()*11)[];
|
||||||
|
};
|
37
testing/btest/spicy/spicyz-aot.test
Normal file
37
testing/btest/spicy/spicyz-aot.test
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
# @TEST-DOC: Smoke test for a custom ahead-of-time compiled Spicy analyzer hooked into Zeek.
|
||||||
|
#
|
||||||
|
# @TEST-REQUIRES: $SCRIPTS/have-spicy
|
||||||
|
# @TEST-EXEC: ${BUILD}/src/builtin-plugins/spicy-plugin/bin/spicyz test.spicy test.evt -o test.hlto
|
||||||
|
# @TEST-EXEC: zeek -NN test.hlto | grep -q ANALYZER_SPICY_TEST
|
||||||
|
# @TEST-EXEC: zeek -r ${TRACES}/http/post.trace test.zeek test.hlto "Spicy::enable_print = T;" >>output 2>&1
|
||||||
|
# @TEST-EXEC: btest-diff output
|
||||||
|
|
||||||
|
# @TEST-START-FILE test.spicy
|
||||||
|
module test;
|
||||||
|
|
||||||
|
import zeek;
|
||||||
|
|
||||||
|
public type Dummy = unit {
|
||||||
|
# Consume all data. We split data into lines and log the number of lines and the lines when done.
|
||||||
|
data: bytes &eod &convert=$$.split(b"\r\n");
|
||||||
|
|
||||||
|
on %done { print |self.data|, self; }
|
||||||
|
};
|
||||||
|
# @TEST-END-FILE
|
||||||
|
|
||||||
|
# @TEST-START-FILE test.evt
|
||||||
|
protocol analyzer spicy::Test over TCP:
|
||||||
|
parse with test::Dummy,
|
||||||
|
port 80/tcp;
|
||||||
|
|
||||||
|
on test::Dummy -> event test::dummy(self.data);
|
||||||
|
# @TEST-END-FILE
|
||||||
|
|
||||||
|
# @TEST-START-FILE test.zeek
|
||||||
|
module test;
|
||||||
|
|
||||||
|
event test::dummy(data: vector of string)
|
||||||
|
{
|
||||||
|
print "Event:", data;
|
||||||
|
}
|
||||||
|
# @TEST-END-FILE
|
37
testing/btest/spicy/spicyz-jit.test
Normal file
37
testing/btest/spicy/spicyz-jit.test
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
# @TEST-DOC: Smoke test for a custom Spicy analyzer hooked into Zeek with JIT via Zeek itself.
|
||||||
|
#
|
||||||
|
# @TEST-REQUIRES: $SCRIPTS/have-spicy
|
||||||
|
# @TEST-EXEC: ${BUILD}/src/builtin-plugins/spicy-plugin/bin/spicyz test.spicy test.evt -o test.hlto
|
||||||
|
# @TEST-EXEC: zeek -NN test.hlto | grep -q ANALYZER_SPICY_TEST
|
||||||
|
# @TEST-EXEC: zeek -r ${TRACES}/http/post.trace test.zeek test.spicy test.evt "Spicy::enable_print = T;" >>output 2>&1
|
||||||
|
# @TEST-EXEC: btest-diff output
|
||||||
|
|
||||||
|
# @TEST-START-FILE test.spicy
|
||||||
|
module test;
|
||||||
|
|
||||||
|
import zeek;
|
||||||
|
|
||||||
|
public type Dummy = unit {
|
||||||
|
# Consume all data. We split data into lines and log the number of lines and the lines when done.
|
||||||
|
data: bytes &eod &convert=$$.split(b"\r\n");
|
||||||
|
|
||||||
|
on %done { print |self.data|, self; }
|
||||||
|
};
|
||||||
|
# @TEST-END-FILE
|
||||||
|
|
||||||
|
# @TEST-START-FILE test.evt
|
||||||
|
protocol analyzer spicy::Test over TCP:
|
||||||
|
parse with test::Dummy,
|
||||||
|
port 80/tcp;
|
||||||
|
|
||||||
|
on test::Dummy -> event test::dummy(self.data);
|
||||||
|
# @TEST-END-FILE
|
||||||
|
|
||||||
|
# @TEST-START-FILE test.zeek
|
||||||
|
module test;
|
||||||
|
|
||||||
|
event test::dummy(data: vector of string)
|
||||||
|
{
|
||||||
|
print "Event:", data;
|
||||||
|
}
|
||||||
|
# @TEST-END-FILE
|
6
testing/scripts/have-spicy
Executable file
6
testing/scripts/have-spicy
Executable file
|
@ -0,0 +1,6 @@
|
||||||
|
#!/bin/sh
|
||||||
|
if grep -q "DISABLE_SPICY:BOOL=true" "${BUILD}"/CMakeCache.txt; then
|
||||||
|
return 1
|
||||||
|
else
|
||||||
|
true
|
||||||
|
fi
|
Loading…
Add table
Add a link
Reference in a new issue