mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 06:38:20 +00:00
updates to test suite tests for compatibility with upcoming ZAM functionality
This commit is contained in:
parent
b5b58b0a3a
commit
b6e9776a11
18 changed files with 103 additions and 36 deletions
|
@ -1,4 +1,5 @@
|
||||||
# @TEST-EXEC: zeek -b %INPUT >output 2>err
|
# Use -D so that the induced FPs checked for below are consistent.
|
||||||
|
# @TEST-EXEC: zeek -D -b %INPUT >output 2>err
|
||||||
# @TEST-EXEC: btest-diff output
|
# @TEST-EXEC: btest-diff output
|
||||||
# @TEST-EXEC: btest-diff err
|
# @TEST-EXEC: btest-diff err
|
||||||
|
|
||||||
|
@ -40,10 +41,6 @@ function test_basic_bloom_filter()
|
||||||
local bf_edge2 = bloomfilter_basic_init(0.9999999, 1);
|
local bf_edge2 = bloomfilter_basic_init(0.9999999, 1);
|
||||||
local bf_edge3 = bloomfilter_basic_init(0.9999999, 100000000000);
|
local bf_edge3 = bloomfilter_basic_init(0.9999999, 100000000000);
|
||||||
|
|
||||||
# Invalid parameters.
|
|
||||||
local bf_bug0 = bloomfilter_basic_init(-0.5, 42);
|
|
||||||
local bf_bug1 = bloomfilter_basic_init(1.1, 42);
|
|
||||||
|
|
||||||
# Merging
|
# Merging
|
||||||
local bf_cnt2 = bloomfilter_basic_init(0.1, 1000);
|
local bf_cnt2 = bloomfilter_basic_init(0.1, 1000);
|
||||||
bloomfilter_add(bf_cnt2, 42);
|
bloomfilter_add(bf_cnt2, 42);
|
||||||
|
@ -61,6 +58,19 @@ function test_basic_bloom_filter()
|
||||||
print bloomfilter_lookup(bf_empty_merged, 42);
|
print bloomfilter_lookup(bf_empty_merged, 42);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# We split off the following into their own tests because ZAM error handling
|
||||||
|
# needs to terminate the current function's execution when these generate
|
||||||
|
# run-time errors.
|
||||||
|
function test_bad_param1()
|
||||||
|
{
|
||||||
|
local bf_bug0 = bloomfilter_basic_init(-0.5, 42);
|
||||||
|
}
|
||||||
|
|
||||||
|
function test_bad_param2()
|
||||||
|
{
|
||||||
|
local bf_bug1 = bloomfilter_basic_init(1.1, 42);
|
||||||
|
}
|
||||||
|
|
||||||
function test_counting_bloom_filter()
|
function test_counting_bloom_filter()
|
||||||
{
|
{
|
||||||
local bf = bloomfilter_counting_init(3, 32, 3);
|
local bf = bloomfilter_counting_init(3, 32, 3);
|
||||||
|
@ -94,4 +104,6 @@ event zeek_init()
|
||||||
{
|
{
|
||||||
test_basic_bloom_filter();
|
test_basic_bloom_filter();
|
||||||
test_counting_bloom_filter();
|
test_counting_bloom_filter();
|
||||||
|
test_bad_param1();
|
||||||
|
test_bad_param2();
|
||||||
}
|
}
|
||||||
|
|
|
@ -148,7 +148,7 @@ event zeek_init()
|
||||||
print topk_count(k3, "d");
|
print topk_count(k3, "d");
|
||||||
print topk_epsilon(k3, "d");
|
print topk_epsilon(k3, "d");
|
||||||
|
|
||||||
local styped: vector of count;
|
local styped: vector of string;
|
||||||
styped = topk_get_top(k3, 3);
|
styped = topk_get_top(k3, 3);
|
||||||
for ( i in styped )
|
for ( i in styped )
|
||||||
print i, styped[i];
|
print i, styped[i];
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
# @TEST-PORT: BROKER_PORT
|
# @TEST-PORT: BROKER_PORT
|
||||||
#
|
#
|
||||||
# @TEST-EXEC: btest-bg-run recv "zeek -B broker -b ../recv.zeek >recv.out"
|
# @TEST-EXEC: btest-bg-run recv "ZEEK_COMPILE_ALL=1 zeek -B broker -b ../recv.zeek >recv.out"
|
||||||
# @TEST-EXEC: btest-bg-run send "zeek -B broker -b ../send.zeek >send.out"
|
# @TEST-EXEC: btest-bg-run send "zeek -B broker -b ../send.zeek >send.out"
|
||||||
#
|
#
|
||||||
# @TEST-EXEC: btest-bg-wait 45
|
# @TEST-EXEC: btest-bg-wait 45
|
||||||
|
|
|
@ -1,3 +1,8 @@
|
||||||
|
# This crashes with ZAM because it explicitly violates typing, which happens
|
||||||
|
# to work in the intepreter, but isn't sound.
|
||||||
|
#
|
||||||
|
# @TEST-REQUIRES: test "${ZEEK_ZAM}" != "1"
|
||||||
|
#
|
||||||
# @TEST-EXEC: zeek -b %INPUT >out 2>&1
|
# @TEST-EXEC: zeek -b %INPUT >out 2>&1
|
||||||
# @TEST-EXEC: TEST_DIFF_CANONIFIER=$SCRIPTS/diff-remove-abspath btest-diff out
|
# @TEST-EXEC: TEST_DIFF_CANONIFIER=$SCRIPTS/diff-remove-abspath btest-diff out
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
# @TEST-EXEC: zeek -b %INPUT >out 2>&1
|
# @TEST-EXEC: zeek -b %INPUT >out 2>&1
|
||||||
# @TEST-EXEC: TEST_DIFF_CANONIFIER=$SCRIPTS/diff-remove-abspath btest-diff out
|
# @TEST-EXEC: TEST_DIFF_CANONIFIER=$SCRIPTS/diff-remove-abspath btest-diff out
|
||||||
|
|
||||||
|
global v1 = vector(10, 20, 30);
|
||||||
|
global v2 = vector(5, 2, 0);
|
||||||
|
|
||||||
event div_int(a: int, b: int)
|
event div_int(a: int, b: int)
|
||||||
{
|
{
|
||||||
print a / b;
|
print a / b;
|
||||||
|
@ -16,6 +19,11 @@ event div_double(a: double, b: double)
|
||||||
print a / b;
|
print a / b;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
event div_vec()
|
||||||
|
{
|
||||||
|
print v1 / v2;
|
||||||
|
}
|
||||||
|
|
||||||
event mod_int(a: int, b: int)
|
event mod_int(a: int, b: int)
|
||||||
{
|
{
|
||||||
print a % b;
|
print a % b;
|
||||||
|
@ -26,6 +34,11 @@ event mod_count(a: count, b: count)
|
||||||
print a % b;
|
print a % b;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
event mod_vec()
|
||||||
|
{
|
||||||
|
print v1 % v2;
|
||||||
|
}
|
||||||
|
|
||||||
event zeek_init()
|
event zeek_init()
|
||||||
{
|
{
|
||||||
event div_int(10, 0);
|
event div_int(10, 0);
|
||||||
|
@ -33,4 +46,6 @@ event zeek_init()
|
||||||
event div_double(10.0, 0.0);
|
event div_double(10.0, 0.0);
|
||||||
event mod_int(10, 0);
|
event mod_int(10, 0);
|
||||||
event mod_count(10, 0);
|
event mod_count(10, 0);
|
||||||
|
event div_vec();
|
||||||
|
event mod_vec();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,8 @@
|
||||||
|
# Skip this test when using ZAM, as it will generate a hard error (since it's
|
||||||
|
# certain that the variable is used w/o initialization) rather than just
|
||||||
|
# a warning.
|
||||||
|
# @TEST-REQUIRES: test "${ZEEK_ZAM}" != "1"
|
||||||
|
#
|
||||||
# @TEST-DOC: ``zeek -a -u`` should detect usage issues without executing code
|
# @TEST-DOC: ``zeek -a -u`` should detect usage issues without executing code
|
||||||
# @TEST-EXEC: zeek -b -a -u %INPUT >out 2>&1
|
# @TEST-EXEC: zeek -b -a -u %INPUT >out 2>&1
|
||||||
# @TEST-EXEC: TEST_DIFF_CANONIFIER=$SCRIPTS/diff-remove-abspath btest-diff out
|
# @TEST-EXEC: TEST_DIFF_CANONIFIER=$SCRIPTS/diff-remove-abspath btest-diff out
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# @TEST-REQUIRES: test "${ZEEK_ZAM}" != "1"
|
||||||
|
#
|
||||||
# @TEST-EXEC: ZEEK_PROFILER_FILE=cov.txt zeek -b -r $TRACES/http/get.trace profiling-test1.zeek
|
# @TEST-EXEC: ZEEK_PROFILER_FILE=cov.txt zeek -b -r $TRACES/http/get.trace profiling-test1.zeek
|
||||||
# @TEST-EXEC: grep profiling-test1.zeek cov.txt > step1.out
|
# @TEST-EXEC: grep profiling-test1.zeek cov.txt > step1.out
|
||||||
# @TEST-EXEC: btest-diff step1.out
|
# @TEST-EXEC: btest-diff step1.out
|
||||||
|
|
|
@ -10,10 +10,6 @@
|
||||||
# @TEST-EXEC: btest-diff 2.out
|
# @TEST-EXEC: btest-diff 2.out
|
||||||
# @TEST-EXEC: btest-diff 2.err
|
# @TEST-EXEC: btest-diff 2.err
|
||||||
|
|
||||||
# @TEST-EXEC: zeek -b 3.zeek >3.out 2>3.err
|
|
||||||
# @TEST-EXEC: btest-diff 3.out
|
|
||||||
# @TEST-EXEC: btest-diff 3.err
|
|
||||||
|
|
||||||
@TEST-START-FILE 1.zeek
|
@TEST-START-FILE 1.zeek
|
||||||
type myrec: record {
|
type myrec: record {
|
||||||
f: string &optional;
|
f: string &optional;
|
||||||
|
@ -76,23 +72,3 @@ event zeek_init()
|
||||||
}
|
}
|
||||||
|
|
||||||
@TEST-END-FILE
|
@TEST-END-FILE
|
||||||
|
|
||||||
@TEST-START-FILE 3.zeek
|
|
||||||
function foo(v: vector of any)
|
|
||||||
{
|
|
||||||
print "in foo";
|
|
||||||
# Vector append incompatible element type
|
|
||||||
v += "ok";
|
|
||||||
# Unreachable
|
|
||||||
print "foo done";
|
|
||||||
}
|
|
||||||
|
|
||||||
event zeek_init()
|
|
||||||
{
|
|
||||||
local v: vector of count;
|
|
||||||
v += 1;
|
|
||||||
foo(v);
|
|
||||||
# Unreachable
|
|
||||||
print "zeek_init done", v;
|
|
||||||
}
|
|
||||||
@TEST-END-FILE
|
|
||||||
|
|
30
testing/btest/language/common-mistakes2.zeek
Normal file
30
testing/btest/language/common-mistakes2.zeek
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
# A companion tonguage/common-mistakes.zeek. Split off because we skip this
|
||||||
|
# test when using ZAM, since it employs a type-checking violation via
|
||||||
|
# vector-of-any, which doesn't seem worth going out of our way to support
|
||||||
|
# in ZAM (and it isn't dead simple to do so).
|
||||||
|
|
||||||
|
# @TEST-REQUIRES: test "${ZEEK_ZAM}" != "1"
|
||||||
|
|
||||||
|
# @TEST-EXEC: zeek -b 3.zeek >3.out 2>3.err
|
||||||
|
# @TEST-EXEC: btest-diff 3.out
|
||||||
|
# @TEST-EXEC: btest-diff 3.err
|
||||||
|
|
||||||
|
@TEST-START-FILE 3.zeek
|
||||||
|
function foo(v: vector of any)
|
||||||
|
{
|
||||||
|
print "in foo";
|
||||||
|
# Vector append incompatible element type
|
||||||
|
v += "ok";
|
||||||
|
# Unreachable
|
||||||
|
print "foo done";
|
||||||
|
}
|
||||||
|
|
||||||
|
event zeek_init()
|
||||||
|
{
|
||||||
|
local v: vector of count;
|
||||||
|
v += 1;
|
||||||
|
foo(v);
|
||||||
|
# Unreachable
|
||||||
|
print "zeek_init done", v;
|
||||||
|
}
|
||||||
|
@TEST-END-FILE
|
|
@ -1,6 +1,6 @@
|
||||||
# @TEST-PORT: BROKER_PORT
|
# @TEST-PORT: BROKER_PORT
|
||||||
#
|
#
|
||||||
# @TEST-EXEC: btest-bg-run recv "zeek -D -B broker -b ../recv.zeek >recv.out"
|
# @TEST-EXEC: btest-bg-run recv "ZEEK_COMPILE_ALL=1 zeek -D -B broker -b ../recv.zeek >recv.out"
|
||||||
# @TEST-EXEC: btest-bg-run send "zeek -D -B broker -b ../send.zeek >send.out"
|
# @TEST-EXEC: btest-bg-run send "zeek -D -B broker -b ../send.zeek >send.out"
|
||||||
#
|
#
|
||||||
# @TEST-EXEC: btest-bg-wait 20
|
# @TEST-EXEC: btest-bg-wait 20
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# @TEST-REQUIRES: test "${ZEEK_ZAM}" != "1"
|
||||||
|
#
|
||||||
# @TEST-EXEC: zeek -b %INPUT >output 2>&1
|
# @TEST-EXEC: zeek -b %INPUT >output 2>&1
|
||||||
# @TEST-EXEC: grep "error" output >output2
|
# @TEST-EXEC: grep "error" output >output2
|
||||||
# @TEST-EXEC: for i in 1 2 3 4 5; do cat output2 | cut -d'|' -f$i >>out; done
|
# @TEST-EXEC: for i in 1 2 3 4 5; do cat output2 | cut -d'|' -f$i >>out; done
|
||||||
|
|
|
@ -1,3 +1,8 @@
|
||||||
|
# We skip this test for ZAM, because it will optimize away the values
|
||||||
|
# that are created to induce overflows. An alternative would be to change
|
||||||
|
# the test to print those values.
|
||||||
|
# @TEST-REQUIRES: test "${ZEEK_ZAM}" != "1"
|
||||||
|
#
|
||||||
# @TEST-EXEC: zeek -b first_set.zeek >first_set.out 2>first_set.err
|
# @TEST-EXEC: zeek -b first_set.zeek >first_set.out 2>first_set.err
|
||||||
# @TEST-EXEC: TEST_DIFF_CANONIFIER=$SCRIPTS/diff-remove-abspath btest-diff first_set.out
|
# @TEST-EXEC: TEST_DIFF_CANONIFIER=$SCRIPTS/diff-remove-abspath btest-diff first_set.out
|
||||||
# @TEST-EXEC: TEST_DIFF_CANONIFIER=$SCRIPTS/diff-remove-abspath btest-diff first_set.err
|
# @TEST-EXEC: TEST_DIFF_CANONIFIER=$SCRIPTS/diff-remove-abspath btest-diff first_set.err
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
|
# For ZAM, this test generates a hard error rather than a warning.
|
||||||
|
# @TEST-REQUIRES: test "${ZEEK_ZAM}" != "1"
|
||||||
|
#
|
||||||
# @TEST-EXEC: zeek -b %INPUT >out 2>err
|
# @TEST-EXEC: zeek -b %INPUT >out 2>err
|
||||||
# @TEST-EXEC: TEST_DIFF_CANONIFIER=$SCRIPTS/diff-remove-abspath btest-diff out
|
# @TEST-EXEC: TEST_DIFF_CANONIFIER=$SCRIPTS/diff-remove-abspath btest-diff out
|
||||||
# @TEST-EXEC: TEST_DIFF_CANONIFIER=$SCRIPTS/diff-remove-abspath btest-diff err
|
# @TEST-EXEC: TEST_DIFF_CANONIFIER=$SCRIPTS/diff-remove-abspath btest-diff err
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
# @TEST-REQUIRES: test "${ZEEK_ZAM}" != "1"
|
||||||
# @TEST-EXEC: ZEEK_USAGE_ISSUES=2 zeek -b %INPUT >out 2>err
|
# @TEST-EXEC: ZEEK_USAGE_ISSUES=2 zeek -b %INPUT >out 2>err
|
||||||
# @TEST-EXEC: TEST_DIFF_CANONIFIER=$SCRIPTS/diff-remove-abspath btest-diff out
|
# @TEST-EXEC: TEST_DIFF_CANONIFIER=$SCRIPTS/diff-remove-abspath btest-diff out
|
||||||
# @TEST-EXEC: TEST_DIFF_CANONIFIER=$SCRIPTS/diff-remove-abspath btest-diff err
|
# @TEST-EXEC: TEST_DIFF_CANONIFIER=$SCRIPTS/diff-remove-abspath btest-diff err
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
|
# This doesn't work for ZAM due to inlining making the "foo" hook ineffectual.
|
||||||
|
# @TEST-REQUIRES: test "${ZEEK_ZAM}" != "1"
|
||||||
|
#
|
||||||
# @TEST-EXEC: ${DIST}/auxil/zeek-aux/plugin-support/init-plugin -u . Demo Hooks
|
# @TEST-EXEC: ${DIST}/auxil/zeek-aux/plugin-support/init-plugin -u . Demo Hooks
|
||||||
# @TEST-EXEC: cp -r %DIR/func-hook-plugin/* .
|
# @TEST-EXEC: cp -r %DIR/func-hook-plugin/* .
|
||||||
# @TEST-EXEC: ./configure --zeek-dist=${DIST} && make
|
# @TEST-EXEC: ./configure --zeek-dist=${DIST} && make
|
||||||
|
|
|
@ -5,10 +5,11 @@
|
||||||
# @TEST-EXEC: btest-bg-run manager-1 "cp ../cluster-layout.zeek . && CLUSTER_NODE=manager-1 zeek -b %INPUT"
|
# @TEST-EXEC: btest-bg-run manager-1 "cp ../cluster-layout.zeek . && CLUSTER_NODE=manager-1 zeek -b %INPUT"
|
||||||
# @TEST-EXEC: btest-bg-run worker-1 "cp ../cluster-layout.zeek . && CLUSTER_NODE=worker-1 zeek -b --pseudo-realtime -C -r $TRACES/tls/ecdhe.pcap %INPUT"
|
# @TEST-EXEC: btest-bg-run worker-1 "cp ../cluster-layout.zeek . && CLUSTER_NODE=worker-1 zeek -b --pseudo-realtime -C -r $TRACES/tls/ecdhe.pcap %INPUT"
|
||||||
|
|
||||||
# @TEST-EXEC: $SCRIPTS/wait-for-file manager-1/lost 15 || (btest-bg-wait -k 1 && false)
|
# @TEST-EXEC: $SCRIPTS/wait-for-file manager-1/lost 45 || (btest-bg-wait -k 1 && false)
|
||||||
|
|
||||||
# @TEST-EXEC: btest-bg-run worker-2 "cp ../cluster-layout.zeek . && CLUSTER_NODE=worker-2 zeek -b --pseudo-realtime -C -r $TRACES/tls/ecdhe.pcap %INPUT"
|
# @TEST-EXEC: btest-bg-run worker-2 "cp ../cluster-layout.zeek . && CLUSTER_NODE=worker-2 zeek -b --pseudo-realtime -C -r $TRACES/tls/ecdhe.pcap %INPUT"
|
||||||
# @TEST-EXEC: btest-bg-wait 30
|
# This timeout needs to be large to accommodate ZAM compilation delays.
|
||||||
|
# @TEST-EXEC: btest-bg-wait 90
|
||||||
# @TEST-EXEC: btest-diff worker-1/.stdout
|
# @TEST-EXEC: btest-diff worker-1/.stdout
|
||||||
# @TEST-EXEC: btest-diff worker-2/.stdout
|
# @TEST-EXEC: btest-diff worker-2/.stdout
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,8 @@
|
||||||
# @TEST-EXEC: btest-bg-run manager-1 ZEEKPATH=$ZEEKPATH:.. CLUSTER_NODE=manager-1 zeek -b %INPUT
|
# @TEST-EXEC: btest-bg-run manager-1 ZEEKPATH=$ZEEKPATH:.. CLUSTER_NODE=manager-1 zeek -b %INPUT
|
||||||
# @TEST-EXEC: btest-bg-run worker-1 ZEEKPATH=$ZEEKPATH:.. CLUSTER_NODE=worker-1 zeek -b %INPUT
|
# @TEST-EXEC: btest-bg-run worker-1 ZEEKPATH=$ZEEKPATH:.. CLUSTER_NODE=worker-1 zeek -b %INPUT
|
||||||
# @TEST-EXEC: btest-bg-run worker-2 ZEEKPATH=$ZEEKPATH:.. CLUSTER_NODE=worker-2 zeek -b %INPUT
|
# @TEST-EXEC: btest-bg-run worker-2 ZEEKPATH=$ZEEKPATH:.. CLUSTER_NODE=worker-2 zeek -b %INPUT
|
||||||
# @TEST-EXEC: btest-bg-wait 45
|
# This timeout needs to be large to accommodate ZAM compilation delays.
|
||||||
|
# @TEST-EXEC: btest-bg-wait 90
|
||||||
# @TEST-EXEC: TEST_DIFF_CANONIFIER=$SCRIPTS/diff-sort btest-diff manager-1/.stdout
|
# @TEST-EXEC: TEST_DIFF_CANONIFIER=$SCRIPTS/diff-sort btest-diff manager-1/.stdout
|
||||||
|
|
||||||
@load base/frameworks/sumstats
|
@load base/frameworks/sumstats
|
||||||
|
|
|
@ -19,6 +19,12 @@ event zeek_init()
|
||||||
print supervisor_output_file, "supervisor zeek_init()";
|
print supervisor_output_file, "supervisor zeek_init()";
|
||||||
local f = open(pid_file);
|
local f = open(pid_file);
|
||||||
print f, getpid();
|
print f, getpid();
|
||||||
|
|
||||||
|
# The following is needed for ZAM code, which will otherwise
|
||||||
|
# keep the file open until the corresponding frame slot
|
||||||
|
# is reused or (finally) goes out of scope.
|
||||||
|
close(f);
|
||||||
|
|
||||||
local sn = Supervisor::NodeConfig($name="grault");
|
local sn = Supervisor::NodeConfig($name="grault");
|
||||||
local res = Supervisor::create(sn);
|
local res = Supervisor::create(sn);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue