mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 06:38:20 +00:00

These were previously reporting leaks due to various allocations not getting cleaned up during the stack unwind, but at the current state of the transition toward IntrusivePtr usage, theses tests no longer leak.
95 lines
1.5 KiB
Text
95 lines
1.5 KiB
Text
# These tests show off common scripting mistakes, which should be
|
|
# handled internally by way of throwing an exception to unwind out
|
|
# of the current event handler body.
|
|
|
|
# @TEST-EXEC: zeek -b 1.zeek >1.out 2>&1
|
|
# @TEST-EXEC: btest-diff 1.out
|
|
|
|
# @TEST-EXEC: zeek -b 2.zeek >2.out 2>&1
|
|
# @TEST-EXEC: btest-diff 2.out
|
|
|
|
# @TEST-EXEC: zeek -b 3.zeek >3.out 2>&1
|
|
# @TEST-EXEC: btest-diff 3.out
|
|
|
|
@TEST-START-FILE 1.zeek
|
|
type myrec: record {
|
|
f: string &optional;
|
|
};
|
|
|
|
function foo(mr: myrec)
|
|
{
|
|
print "foo start";
|
|
# Unitialized field access: unwind out of current event handler body
|
|
print mr$f;
|
|
# Unreachable
|
|
print "foo done";
|
|
}
|
|
|
|
function bar()
|
|
{
|
|
print "bar start";
|
|
foo(myrec());
|
|
# Unreachable
|
|
print "bar done";
|
|
}
|
|
|
|
event zeek_init()
|
|
{
|
|
bar();
|
|
# Unreachable
|
|
print "zeek_init done";
|
|
}
|
|
|
|
event zeek_init() &priority=-10
|
|
{
|
|
# Reachable
|
|
print "other zeek_init";
|
|
}
|
|
@TEST-END-FILE
|
|
|
|
@TEST-START-FILE 2.zeek
|
|
function foo()
|
|
{
|
|
print "in foo";
|
|
local t: table[string] of string = table();
|
|
|
|
# Non-existing index access: (sub)expressions should not be evaluated
|
|
if ( t["nope"] == "nope" )
|
|
# Unreachable
|
|
print "yes";
|
|
else
|
|
# Unreachable
|
|
print "no";
|
|
|
|
# Unreachable
|
|
print "foo done";
|
|
}
|
|
|
|
event zeek_init()
|
|
{
|
|
foo();
|
|
# Unreachable
|
|
print "zeek_init done";
|
|
}
|
|
|
|
@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
|