Merge remote-tracking branch 'origin/fastpath'

* origin/fastpath:
  Another attempt to improve core.when-interpreter-exceptions unit test.
This commit is contained in:
Robin Sommer 2013-12-12 07:12:47 -08:00
commit 928a5881b1
4 changed files with 47 additions and 34 deletions

View file

@ -1,4 +1,9 @@
2.2-72 | 2013-12-12 07:12:47 -0800
* Improve the core.when-interpreter-exceptions unit test to prevent
it from occasionally timing out. (Jon Siwek)
2.2-70 | 2013-12-10 15:02:50 -0800
* Fix (harmless) uninitialized field in basename/dirname util

View file

@ -1 +1 @@
2.2-70
2.2-72

View file

@ -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]
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]
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]
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]
1386110869.157209 received termination signal
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]
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]
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]
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]
received termination signal
[f(F)]
f() done, no exception, T
[f(T)]
[bro_init()]
timeout g(), T
timeout
timeout g(), F
timeout g(), T
g() done, no exception, T
localhost resolved
localhost resolved from f(), T
localhost resolved from f(), F
f() done, no exception, T

View file

@ -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: 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
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;
@ -26,22 +35,21 @@ event termination_check()
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 )
{
event termination_check();
print p$ip;
print myrecord$notset;
}
return T;
}
timeout 10 sec
{
print "lookup_hostname in f() timed out unexpectedly";
}
check_term_condition();
return F;
@ -49,9 +57,11 @@ function f(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
{
@ -60,7 +70,7 @@ function g(do_exception: bool): bool
if ( do_exception )
{
event termination_check();
print p$ip;
print myrecord$notset;
}
return T;
@ -72,28 +82,26 @@ function g(do_exception: bool): bool
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();
print p$ip;
}
timeout 10 sec
{
print "lookup_hostname timed out unexpectedly";
check_term_condition();
print myrecord$notset;
}
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();
}
timeout 0 sec
{
print "timeout";
event termination_check();
print p$ip;
print myrecord$notset;
}
when ( local b = f(T) )