mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 06:38:20 +00:00
Improve scripts/base/utils/dir unit test
This commit is contained in:
parent
6378c3dc90
commit
2586e5aa3e
4 changed files with 47 additions and 44 deletions
4
CHANGES
4
CHANGES
|
@ -1,4 +1,8 @@
|
||||||
|
|
||||||
|
2.6-beta2-43 | 2018-10-19 11:15:44 -0500
|
||||||
|
|
||||||
|
* Improve scripts/base/utils/dir unit test (Jon Siwek, Corelight)
|
||||||
|
|
||||||
2.6-beta2-42 | 2018-10-18 10:21:01 -0500
|
2.6-beta2-42 | 2018-10-18 10:21:01 -0500
|
||||||
|
|
||||||
* Fix documentation link for notice_alarm.log fields (Jon Siwek, Corelight)
|
* Fix documentation link for notice_alarm.log fields (Jon Siwek, Corelight)
|
||||||
|
|
2
VERSION
2
VERSION
|
@ -1 +1 @@
|
||||||
2.6-beta2-42
|
2.6-beta2-43
|
||||||
|
|
|
@ -1,10 +1,5 @@
|
||||||
new_file1, ../testdir/bye
|
initial file, ../testdir/hi
|
||||||
new_file1, ../testdir/hi
|
initial file, ../testdir/howsitgoing
|
||||||
new_file1, ../testdir/howsitgoing
|
initial file, ../testdir/bye
|
||||||
new_file2, ../testdir/bye
|
new_file, ../testdir/newone
|
||||||
new_file2, ../testdir/hi
|
new_file, ../testdir/bye
|
||||||
new_file2, ../testdir/howsitgoing
|
|
||||||
new_file1, ../testdir/bye
|
|
||||||
new_file1, ../testdir/newone
|
|
||||||
new_file2, ../testdir/bye
|
|
||||||
new_file2, ../testdir/newone
|
|
||||||
|
|
|
@ -1,6 +1,12 @@
|
||||||
# @TEST-EXEC: btest-bg-run bro bro -b ../dirtest.bro
|
# @TEST-EXEC: btest-bg-run bro bro -b ../dirtest.bro
|
||||||
# @TEST-EXEC: btest-bg-wait 15
|
# @TEST-EXEC: $SCRIPTS/wait-for-file bro/next1 10 || (btest-bg-wait -k 1 && false)
|
||||||
# @TEST-EXEC: TEST_DIFF_CANONIFIER=$SCRIPTS/diff-sort btest-diff bro/.stdout
|
# @TEST-EXEC: touch testdir/newone
|
||||||
|
# @TEST-EXEC: rm testdir/bye
|
||||||
|
# @TEST-EXEC: $SCRIPTS/wait-for-file bro/next2 10 || (btest-bg-wait -k 1 && false)
|
||||||
|
# @TEST-EXEC: touch testdir/bye
|
||||||
|
# @TEST-EXEC: btest-bg-wait 20
|
||||||
|
# @TEST-EXEC: touch testdir/newone
|
||||||
|
# @TEST-EXEC: btest-diff bro/.stdout
|
||||||
|
|
||||||
@TEST-START-FILE dirtest.bro
|
@TEST-START-FILE dirtest.bro
|
||||||
|
|
||||||
|
@ -9,43 +15,41 @@ redef exit_only_after_terminate = T;
|
||||||
|
|
||||||
global c: count = 0;
|
global c: count = 0;
|
||||||
|
|
||||||
function check_terminate_condition()
|
global initial_files: set[string] = set();
|
||||||
{
|
|
||||||
c += 1;
|
|
||||||
|
|
||||||
if ( c == 10 )
|
function check_initial_file(s: string)
|
||||||
|
{
|
||||||
|
if ( s in initial_files )
|
||||||
|
print "initial file", s;
|
||||||
|
else
|
||||||
|
print "didn't see initial file", s;
|
||||||
|
}
|
||||||
|
|
||||||
|
function new_file(fname: string)
|
||||||
|
{
|
||||||
|
++c;
|
||||||
|
|
||||||
|
if ( c <= 3 )
|
||||||
|
add initial_files[fname];
|
||||||
|
else
|
||||||
|
print "new_file", fname;
|
||||||
|
|
||||||
|
if ( c == 3 )
|
||||||
|
{
|
||||||
|
check_initial_file("../testdir/hi");
|
||||||
|
check_initial_file("../testdir/howsitgoing");
|
||||||
|
check_initial_file("../testdir/bye");
|
||||||
|
system("touch next1");
|
||||||
|
}
|
||||||
|
else if ( c == 4 )
|
||||||
|
system("touch next2");
|
||||||
|
else if ( c == 5 )
|
||||||
terminate();
|
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");
|
|
||||||
}
|
|
||||||
|
|
||||||
event change_things2()
|
|
||||||
{
|
|
||||||
system("touch ../testdir/bye");
|
|
||||||
}
|
|
||||||
|
|
||||||
event bro_init()
|
event bro_init()
|
||||||
{
|
{
|
||||||
Dir::monitor("../testdir", new_file1, .5sec);
|
Dir::monitor("../testdir", new_file, .25sec);
|
||||||
Dir::monitor("../testdir", new_file2, 1sec);
|
|
||||||
schedule 3sec { change_things() };
|
|
||||||
schedule 6sec { change_things2() };
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@TEST-END-FILE
|
@TEST-END-FILE
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue