mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 22:58:20 +00:00
Merge remote-tracking branch 'origin/topic/jsiwek/gh-1122'
* origin/topic/jsiwek/gh-1122: GH-165: Fix global initializations that indirectly use builtin types Improve how primary/top-level BIFs get initialized GH-1122: Allow initializing globals with calls to subdir BIFs GH-1122: Improve error for global record initialization exceptions
This commit is contained in:
commit
2a8de33c63
23 changed files with 207 additions and 70 deletions
|
@ -0,0 +1,14 @@
|
|||
# @TEST-EXEC: zeek -b %INPUT >out
|
||||
# @TEST-EXEC: btest-diff out
|
||||
|
||||
# This test isn't specifically testing the PacketFilter functionality, rather
|
||||
# that a global variable can be initialized using a BIF call and that BIF call
|
||||
# can make use of some global type pointers to builtin types/aliases.
|
||||
|
||||
@load base/frameworks/packet-filter
|
||||
redef PacketFilter::restricted_filter = PacketFilter::port_to_bpf(80/tcp);
|
||||
|
||||
event zeek_init()
|
||||
{
|
||||
print PacketFilter::restricted_filter;
|
||||
}
|
14
testing/btest/language/global-init-calls-bif.zeek
Normal file
14
testing/btest/language/global-init-calls-bif.zeek
Normal file
|
@ -0,0 +1,14 @@
|
|||
# @TEST-EXEC: zeek -b %INPUT >out
|
||||
# @TEST-EXEC: btest-diff out
|
||||
|
||||
# This test isn't specifically testing the HLL cardinality functionality,
|
||||
# rather that a global variable can be initialized using a BIF call.
|
||||
# Also, it's particularly not a top-level BIF, but one defined in a subdir
|
||||
# of the Zeek source tree (those are treated differently than top-level BIFs).
|
||||
|
||||
global my_cc = hll_cardinality_init(0.1, 0.999);
|
||||
|
||||
hll_cardinality_add(my_cc, 1);
|
||||
hll_cardinality_add(my_cc, 2);
|
||||
hll_cardinality_add(my_cc, 3);
|
||||
print hll_cardinality_estimate(my_cc);
|
14
testing/btest/language/record-global-init-exception.zeek
Normal file
14
testing/btest/language/record-global-init-exception.zeek
Normal file
|
@ -0,0 +1,14 @@
|
|||
# @TEST-EXEC-FAIL: zeek -b %INPUT >out 2>&1
|
||||
# @TEST-EXEC: TEST_DIFF_CANONIFIER=$SCRIPTS/diff-remove-abspath btest-diff out
|
||||
|
||||
global my_count: count;
|
||||
|
||||
type MyRecord: record {
|
||||
f: count &default=my_count;
|
||||
};
|
||||
|
||||
# This global initialization encounters the uninitialized 'my_count' when
|
||||
# evaluating the &default expression. The test simply checking that the
|
||||
# interpreter exception is caught and at least fails out with a nice error
|
||||
# message instead of letting an uncaught exception cause termination.
|
||||
global my_record = MyRecord();
|
Loading…
Add table
Add a link
Reference in a new issue