mirror of
https://github.com/zeek/zeek.git
synced 2025-10-13 12:08:20 +00:00
Another attempt to improve core.when-interpreter-exceptions unit test.
lookup_hostname("localhost") occassionally timed out (after allowed 10 secs) when running test suite on some systems. Not sure why, but changed to use the Exec module for when block conditions instead as the scope of the test doesn't depend on a particular type of condition, it just needs something that will work reliably/quickly.
This commit is contained in:
parent
6c20df11cc
commit
63c36d58f3
2 changed files with 41 additions and 33 deletions
|
@ -1,13 +1,13 @@
|
||||||
1386110869.157209 expression error in /Users/jon/Projects/bro/bro/testing/btest/.tmp/core.when-interpreter-exceptions/when-interpreter-exceptions.bro, line 96: field value missing [p$ip]
|
expression error in /Users/jon/Projects/bro/bro/testing/btest/.tmp/core.when-interpreter-exceptions/when-interpreter-exceptions.bro, line 48: field value missing [myrecord$notset]
|
||||||
1386110869.157209 expression error in /Users/jon/Projects/bro/bro/testing/btest/.tmp/core.when-interpreter-exceptions/when-interpreter-exceptions.bro, line 63: field value missing [p$ip]
|
expression error in /Users/jon/Projects/bro/bro/testing/btest/.tmp/core.when-interpreter-exceptions/when-interpreter-exceptions.bro, line 92: field value missing [myrecord$notset]
|
||||||
1386110869.157209 expression error in /Users/jon/Projects/bro/bro/testing/btest/.tmp/core.when-interpreter-exceptions/when-interpreter-exceptions.bro, line 79: field value missing [p$ip]
|
expression error in /Users/jon/Projects/bro/bro/testing/btest/.tmp/core.when-interpreter-exceptions/when-interpreter-exceptions.bro, line 73: field value missing [myrecord$notset]
|
||||||
1386110869.157209 expression error in /Users/jon/Projects/bro/bro/testing/btest/.tmp/core.when-interpreter-exceptions/when-interpreter-exceptions.bro, line 36: field value missing [p$ip]
|
expression error in /Users/jon/Projects/bro/bro/testing/btest/.tmp/core.when-interpreter-exceptions/when-interpreter-exceptions.bro, line 104: field value missing [myrecord$notset]
|
||||||
1386110869.157209 received termination signal
|
received termination signal
|
||||||
|
[f(F)]
|
||||||
|
f() done, no exception, T
|
||||||
|
[f(T)]
|
||||||
|
[bro_init()]
|
||||||
|
timeout g(), T
|
||||||
timeout
|
timeout
|
||||||
timeout g(), F
|
timeout g(), F
|
||||||
timeout g(), T
|
|
||||||
g() done, no exception, T
|
g() done, no exception, T
|
||||||
localhost resolved
|
|
||||||
localhost resolved from f(), T
|
|
||||||
localhost resolved from f(), F
|
|
||||||
f() done, no exception, T
|
|
||||||
|
|
|
@ -1,10 +1,19 @@
|
||||||
# @TEST-EXEC: btest-bg-run bro "bro -b --pseudo-realtime -r $TRACES/rotation.trace %INPUT >output 2>&1"
|
# @TEST-EXEC: btest-bg-run bro "bro -b %INPUT >output 2>&1"
|
||||||
# @TEST-EXEC: btest-bg-wait 15
|
# @TEST-EXEC: btest-bg-wait 15
|
||||||
# @TEST-EXEC: TEST_DIFF_CANONIFIER="$SCRIPTS/diff-remove-abspath | $SCRIPTS/diff-remove-timestamps | $SCRIPTS/diff-sort" btest-diff bro/output
|
# @TEST-EXEC: TEST_DIFF_CANONIFIER="$SCRIPTS/diff-remove-abspath | $SCRIPTS/diff-remove-timestamps | $SCRIPTS/diff-sort" btest-diff bro/output
|
||||||
|
|
||||||
# interpreter exceptions in "when" blocks shouldn't cause termination
|
# interpreter exceptions in "when" blocks shouldn't cause termination
|
||||||
|
|
||||||
global p: pkt_hdr;
|
@load base/utils/exec
|
||||||
|
@load base/frameworks/communication # let network-time run. otherwise there are no heartbeats...
|
||||||
|
redef exit_only_after_terminate = T;
|
||||||
|
|
||||||
|
type MyRecord: record {
|
||||||
|
a: bool &default=T;
|
||||||
|
notset: bool &optional;
|
||||||
|
};
|
||||||
|
|
||||||
|
global myrecord: MyRecord;
|
||||||
|
|
||||||
global c = 0;
|
global c = 0;
|
||||||
|
|
||||||
|
@ -26,22 +35,21 @@ event termination_check()
|
||||||
|
|
||||||
function f(do_exception: bool): bool
|
function f(do_exception: bool): bool
|
||||||
{
|
{
|
||||||
return when ( local addrs = lookup_hostname("localhost") )
|
local cmd = Exec::Command($cmd=fmt("echo 'f(%s)'",
|
||||||
|
do_exception));
|
||||||
|
|
||||||
|
return when ( local result = Exec::run(cmd) )
|
||||||
{
|
{
|
||||||
print "localhost resolved from f()", do_exception;
|
print result$stdout;
|
||||||
|
|
||||||
if ( do_exception )
|
if ( do_exception )
|
||||||
{
|
{
|
||||||
event termination_check();
|
event termination_check();
|
||||||
print p$ip;
|
print myrecord$notset;
|
||||||
}
|
}
|
||||||
|
|
||||||
return T;
|
return T;
|
||||||
}
|
}
|
||||||
timeout 10 sec
|
|
||||||
{
|
|
||||||
print "lookup_hostname in f() timed out unexpectedly";
|
|
||||||
}
|
|
||||||
|
|
||||||
check_term_condition();
|
check_term_condition();
|
||||||
return F;
|
return F;
|
||||||
|
@ -49,9 +57,11 @@ function f(do_exception: bool): bool
|
||||||
|
|
||||||
function g(do_exception: bool): bool
|
function g(do_exception: bool): bool
|
||||||
{
|
{
|
||||||
return when ( local addrs = lookup_hostname("localhost") )
|
local stall = Exec::Command($cmd="sleep 30");
|
||||||
|
|
||||||
|
return when ( local result = Exec::run(stall) )
|
||||||
{
|
{
|
||||||
print "shouldn't get here, g()", do_exception;
|
print "shouldn't get here, g()", do_exception, result;
|
||||||
}
|
}
|
||||||
timeout 0 sec
|
timeout 0 sec
|
||||||
{
|
{
|
||||||
|
@ -60,7 +70,7 @@ function g(do_exception: bool): bool
|
||||||
if ( do_exception )
|
if ( do_exception )
|
||||||
{
|
{
|
||||||
event termination_check();
|
event termination_check();
|
||||||
print p$ip;
|
print myrecord$notset;
|
||||||
}
|
}
|
||||||
|
|
||||||
return T;
|
return T;
|
||||||
|
@ -72,28 +82,26 @@ function g(do_exception: bool): bool
|
||||||
|
|
||||||
event bro_init()
|
event bro_init()
|
||||||
{
|
{
|
||||||
when ( local addrs = lookup_hostname("localhost") )
|
local cmd = Exec::Command($cmd="echo 'bro_init()'");
|
||||||
|
local stall = Exec::Command($cmd="sleep 30");
|
||||||
|
|
||||||
|
when ( local result = Exec::run(cmd) )
|
||||||
{
|
{
|
||||||
print "localhost resolved";
|
print result$stdout;
|
||||||
event termination_check();
|
event termination_check();
|
||||||
print p$ip;
|
print myrecord$notset;
|
||||||
}
|
|
||||||
timeout 10 sec
|
|
||||||
{
|
|
||||||
print "lookup_hostname timed out unexpectedly";
|
|
||||||
check_term_condition();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
when ( local addrs2 = lookup_hostname("localhost") )
|
when ( local result2 = Exec::run(stall) )
|
||||||
{
|
{
|
||||||
print "shouldn't get here";
|
print "shouldn't get here", result2;
|
||||||
check_term_condition();
|
check_term_condition();
|
||||||
}
|
}
|
||||||
timeout 0 sec
|
timeout 0 sec
|
||||||
{
|
{
|
||||||
print "timeout";
|
print "timeout";
|
||||||
event termination_check();
|
event termination_check();
|
||||||
print p$ip;
|
print myrecord$notset;
|
||||||
}
|
}
|
||||||
|
|
||||||
when ( local b = f(T) )
|
when ( local b = f(T) )
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue