zeek/testing/btest/core/dns-interpreter-exceptions.bro
Jon Siwek f7440375f1 Interpreter exceptions occurring in "when" blocks are now handled.
The scripting error that caused the exception is still reported, but
it no longer causes Bro to terminate.  Addresses #779
2012-12-04 12:38:09 -06:00

63 lines
1.3 KiB
Text

# @TEST-EXEC: bro -b -r $TRACES/wikipedia.trace %INPUT >out 2>&1
# @TEST-EXEC: TEST_DIFF_CANONIFIER=$SCRIPTS/diff-remove-abspath btest-diff out
# interpreter exceptions in "when" blocks shouldn't cause termination
global p: pkt_hdr;
function f(do_exception: bool): bool
{
return when ( local addrs = lookup_hostname("localhost") )
{
print "localhost resolved from f()", do_exception;
if ( do_exception )
print p$ip;
return T;
}
return F;
}
function g(do_exception: bool): bool
{
return when ( local addrs = lookup_hostname("localhost") )
{
print "shouldn't get here, g()", do_exception;
}
timeout 0 sec
{
print "timeout g()", do_exception;
if ( do_exception )
print p$ip;
return T;
}
return F;
}
event bro_init()
{
when ( local addrs = lookup_hostname("localhost") )
{
print "localhost resolved";
print p$ip;
}
when ( local addrs2 = lookup_hostname("localhost") )
{
print "shouldn't get here";
}
timeout 0 sec
{
print "timeout";
print p$ip;
}
when ( local b = f(T) )
print "f() exception done (shouldn't be printed)", b;
when ( local b2 = g(T) )
print "g() exception done (shouldn't be printed)", b2;
when ( local b3 = f(F) )
print "f() done, no exception", b3;
when ( local b4 = g(F) )
print "g() done, no exception", b4;
}