mirror of
https://github.com/zeek/zeek.git
synced 2025-10-08 17:48:21 +00:00
Exec module changes/fixes.
- Give Dir::monitor() a param for the polling interval, so different dirs can be monitored at different frequencies. - Fix race in Exec::run() when reading extra output files produced by a process -- it was possible for Exec::run() to return before all extra output files had been fully read. - Add test cases.
This commit is contained in:
parent
325f0c2a3f
commit
73eb87a41e
10 changed files with 299 additions and 42 deletions
58
testing/btest/scripts/base/utils/dir.test
Normal file
58
testing/btest/scripts/base/utils/dir.test
Normal file
|
@ -0,0 +1,58 @@
|
|||
# @TEST-EXEC: btest-bg-run bro bro -b ../dirtest.bro
|
||||
# @TEST-EXEC: btest-bg-wait 10
|
||||
# @TEST-EXEC: TEST_DIFF_CANONIFIER=$SCRIPTS/diff-sort btest-diff bro/.stdout
|
||||
|
||||
@TEST-START-FILE dirtest.bro
|
||||
|
||||
@load base/utils/dir
|
||||
|
||||
redef exit_only_after_terminate = T;
|
||||
|
||||
global c: count = 0;
|
||||
|
||||
function check_terminate_condition()
|
||||
{
|
||||
c += 1;
|
||||
|
||||
if ( c == 10 )
|
||||
terminate();
|
||||
}
|
||||
|
||||
function new_file1(fname: string)
|
||||
{
|
||||
print "new_file1", fname;
|
||||
check_terminate_condition();
|
||||
}
|
||||
|
||||
function new_file2(fname: string)
|
||||
{
|
||||
print "new_file2", fname;
|
||||
check_terminate_condition();
|
||||
}
|
||||
|
||||
event change_things()
|
||||
{
|
||||
system("touch ../testdir/newone");
|
||||
system("rm ../testdir/bye && touch ../testdir/bye");
|
||||
}
|
||||
|
||||
event bro_init()
|
||||
{
|
||||
Dir::monitor("../testdir", new_file1, .5sec);
|
||||
Dir::monitor("../testdir", new_file2, 1sec);
|
||||
schedule 1sec { change_things() };
|
||||
}
|
||||
|
||||
@TEST-END-FILE
|
||||
|
||||
@TEST-START-FILE testdir/hi
|
||||
123
|
||||
@TEST-END-FILE
|
||||
|
||||
@TEST-START-FILE testdir/howsitgoing
|
||||
abc
|
||||
@TEST-END-FILE
|
||||
|
||||
@TEST-START-FILE testdir/bye
|
||||
!@#
|
||||
@TEST-END-FILE
|
Loading…
Add table
Add a link
Reference in a new issue