mirror of
https://github.com/zeek/zeek.git
synced 2025-10-07 17:18:20 +00:00
BIT-1941: improve unit test stability
Mostly trying to standardize the way tests sleep for arbitrary amounts of time to make it easier to tell at which particular point the unit test actually may need the timeout interval increased (or else debugged further).
This commit is contained in:
parent
df3ce608e3
commit
15d74ac081
43 changed files with 302 additions and 386 deletions
|
@ -7,6 +7,7 @@ redef exit_only_after_terminate = T;
|
|||
|
||||
global outfile: file;
|
||||
global processes_finished: count = 0;
|
||||
global lines_received: count = 0;
|
||||
global n: count = 0;
|
||||
global total_processes: count = 0;
|
||||
|
||||
|
@ -20,10 +21,23 @@ type Val: record {
|
|||
s: string;
|
||||
};
|
||||
|
||||
global more_input: function(name_prefix: string);
|
||||
|
||||
function check_terminate_condition()
|
||||
{
|
||||
if ( processes_finished != total_processes )
|
||||
return;
|
||||
|
||||
if ( lines_received != (total_processes - 1) * 2 )
|
||||
return;
|
||||
|
||||
terminate();
|
||||
}
|
||||
|
||||
event line(description: Input::EventDescription, tpe: Input::Event, s: string)
|
||||
{
|
||||
print outfile, tpe, description$source, description$name;
|
||||
print outfile, s;
|
||||
++lines_received;
|
||||
print outfile, tpe, description$source, description$name, s;
|
||||
}
|
||||
|
||||
event InputRaw::process_finished(name: string, source:string, exit_code:count, signal_exit:bool)
|
||||
|
@ -31,10 +45,18 @@ event InputRaw::process_finished(name: string, source:string, exit_code:count, s
|
|||
print "process_finished", name, source;
|
||||
Input::remove(name);
|
||||
++processes_finished;
|
||||
if ( processes_finished == total_processes )
|
||||
if ( processes_finished == 1 )
|
||||
{
|
||||
more_input("input");
|
||||
more_input("input");
|
||||
more_input("input");
|
||||
more_input("input");
|
||||
more_input("input");
|
||||
}
|
||||
else if ( processes_finished == total_processes )
|
||||
{
|
||||
close(outfile);
|
||||
terminate();
|
||||
check_terminate_condition();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -59,9 +81,4 @@ event bro_init()
|
|||
$reader=Input::READER_RAW, $mode=Input::STREAM,
|
||||
$name="input", $fields=Val, $ev=line, $want_record=F,
|
||||
$config=config_strings]);
|
||||
more_input("input");
|
||||
more_input("input");
|
||||
more_input("input");
|
||||
more_input("input");
|
||||
more_input("input");
|
||||
}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
# @TEST-EXEC: cp input1.log input.log
|
||||
# @TEST-EXEC: btest-bg-run bro bro -b %INPUT
|
||||
# @TEST-EXEC: sleep 3
|
||||
# @TEST-EXEC: $SCRIPTS/wait-for-file bro/got1 5 || (btest-bg-wait -k 1 && false)
|
||||
# @TEST-EXEC: cat input2.log >> input.log
|
||||
# @TEST-EXEC: sleep 3
|
||||
# @TEST-EXEC: $SCRIPTS/wait-for-file bro/got3 5 || (btest-bg-wait -k 1 && false)
|
||||
# @TEST-EXEC: cat input3.log >> input.log
|
||||
# @TEST-EXEC: btest-bg-wait 10
|
||||
# @TEST-EXEC: btest-diff out
|
||||
|
@ -38,12 +38,16 @@ global outfile: file;
|
|||
|
||||
event line(description: Input::EventDescription, tpe: Input::Event, s: string)
|
||||
{
|
||||
print outfile, description;
|
||||
print outfile, description$source, description$reader, description$mode, description$name;
|
||||
print outfile, tpe;
|
||||
print outfile, s;
|
||||
|
||||
try = try + 1;
|
||||
if ( try == 8 )
|
||||
if ( try == 1 )
|
||||
system("touch got1");
|
||||
else if ( try == 3 )
|
||||
system("touch got3");
|
||||
else if ( try == 8 )
|
||||
{
|
||||
print outfile, "done";
|
||||
close(outfile);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# @TEST-EXEC: cp input.log input2.log
|
||||
# @TEST-EXEC: btest-bg-run bro bro -b %INPUT
|
||||
# @TEST-EXEC: sleep 2
|
||||
# @TEST-EXEC: $SCRIPTS/wait-for-file bro/got2 5 || (btest-bg-wait -k 1 && false)
|
||||
# @TEST-EXEC: echo "hi" >> input2.log
|
||||
# @TEST-EXEC: btest-bg-wait 10
|
||||
# @TEST-EXEC: TEST_DIFF_CANONIFIER=$SCRIPTS/diff-sort btest-diff out
|
||||
|
@ -24,7 +24,9 @@ event line(description: Input::EventDescription, tpe: Input::Event, s: string)
|
|||
{
|
||||
print outfile, s;
|
||||
try = try + 1;
|
||||
if ( try == 3 )
|
||||
if ( try == 2 )
|
||||
system("touch got2");
|
||||
else if ( try == 3 )
|
||||
{
|
||||
close(outfile);
|
||||
terminate();
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
# @TEST-EXEC: cp input1.log input.log
|
||||
# @TEST-EXEC: btest-bg-run bro bro -b %INPUT
|
||||
# @TEST-EXEC: sleep 3
|
||||
# @TEST-EXEC: $SCRIPTS/wait-for-file bro/got1 5 || (btest-bg-wait -k 1 && false)
|
||||
# @TEST-EXEC: cat input2.log >> input.log
|
||||
# @TEST-EXEC: sleep 3
|
||||
# @TEST-EXEC: $SCRIPTS/wait-for-file bro/got3 5 || (btest-bg-wait -k 1 && false)
|
||||
# @TEST-EXEC: cat input3.log >> input.log
|
||||
# @TEST-EXEC: btest-bg-wait 10
|
||||
# @TEST-EXEC: btest-diff out
|
||||
|
@ -37,12 +37,17 @@ global outfile: file;
|
|||
|
||||
event line(description: Input::EventDescription, tpe: Input::Event, s: string)
|
||||
{
|
||||
print outfile, description;
|
||||
print outfile, description$source, description$reader, description$mode, description$name;
|
||||
print outfile, tpe;
|
||||
print outfile, s;
|
||||
|
||||
try = try + 1;
|
||||
if ( try == 8 )
|
||||
|
||||
if ( try == 1 )
|
||||
system("touch got1");
|
||||
else if ( try == 3 )
|
||||
system("touch got3");
|
||||
else if ( try == 8 )
|
||||
{
|
||||
print outfile, "done";
|
||||
close(outfile);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue