mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 06:38:20 +00:00
btest/input/raw: Fix reread test
This seems to have relied on the reading file twice behavior simply testing that 16 lines are observed. Switch to using two separate files and doing a system("mv ...") to trigger the REREAD logic, there's not force_update() needed and it wouldn't do anything if the file hadn't changed anyway.
This commit is contained in:
parent
d8b5bdf758
commit
09b956562e
2 changed files with 40 additions and 298 deletions
|
@ -1,289 +1,13 @@
|
||||||
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
||||||
[source=../input.log, reader=Input::READER_RAW, mode=Input::REREAD, name=input, fields=A::Val, want_record=F, ev=line
|
1, Input::EVENT_NEW, sdfkh:KH;fdkncv;ISEUp34:Fkdj;YVpIODhfDF, 39
|
||||||
{
|
2, Input::EVENT_NEW, DSF"DFKJ"SDFKLh304yrsdkfj@#(*U$34jfDJup3UF, 42
|
||||||
print outfile, A::description;
|
3, Input::EVENT_NEW, q3r3057fdf, 10
|
||||||
print outfile, A::tpe;
|
4, Input::EVENT_NEW, sdfs\d, 6
|
||||||
print outfile, A::s;
|
5, Input::EVENT_NEW, , 0
|
||||||
try = try + 1;
|
6, Input::EVENT_NEW, dfsdf, 5
|
||||||
if (16 == try)
|
7, Input::EVENT_NEW, sdf, 3
|
||||||
{
|
8, Input::EVENT_NEW, 3rw43wRRERLlL#RWERERERE., 24
|
||||||
Input::remove(input);
|
end_of_data, updating input.log
|
||||||
close(outfile);
|
9, Input::EVENT_NEW, Beginning of input2.log, 23
|
||||||
terminate();
|
10, Input::EVENT_NEW, 3rw43wRRERLlL#RWERERERE., 24
|
||||||
}
|
11, Input::EVENT_NEW, game over, 9
|
||||||
|
|
||||||
}, error_ev=<uninitialized>, config={
|
|
||||||
|
|
||||||
}]
|
|
||||||
Input::EVENT_NEW
|
|
||||||
sdfkh:KH;fdkncv;ISEUp34:Fkdj;YVpIODhfDF
|
|
||||||
[source=../input.log, reader=Input::READER_RAW, mode=Input::REREAD, name=input, fields=A::Val, want_record=F, ev=line
|
|
||||||
{
|
|
||||||
print outfile, A::description;
|
|
||||||
print outfile, A::tpe;
|
|
||||||
print outfile, A::s;
|
|
||||||
try = try + 1;
|
|
||||||
if (16 == try)
|
|
||||||
{
|
|
||||||
Input::remove(input);
|
|
||||||
close(outfile);
|
|
||||||
terminate();
|
|
||||||
}
|
|
||||||
|
|
||||||
}, error_ev=<uninitialized>, config={
|
|
||||||
|
|
||||||
}]
|
|
||||||
Input::EVENT_NEW
|
|
||||||
DSF"DFKJ"SDFKLh304yrsdkfj@#(*U$34jfDJup3UF
|
|
||||||
[source=../input.log, reader=Input::READER_RAW, mode=Input::REREAD, name=input, fields=A::Val, want_record=F, ev=line
|
|
||||||
{
|
|
||||||
print outfile, A::description;
|
|
||||||
print outfile, A::tpe;
|
|
||||||
print outfile, A::s;
|
|
||||||
try = try + 1;
|
|
||||||
if (16 == try)
|
|
||||||
{
|
|
||||||
Input::remove(input);
|
|
||||||
close(outfile);
|
|
||||||
terminate();
|
|
||||||
}
|
|
||||||
|
|
||||||
}, error_ev=<uninitialized>, config={
|
|
||||||
|
|
||||||
}]
|
|
||||||
Input::EVENT_NEW
|
|
||||||
q3r3057fdf
|
|
||||||
[source=../input.log, reader=Input::READER_RAW, mode=Input::REREAD, name=input, fields=A::Val, want_record=F, ev=line
|
|
||||||
{
|
|
||||||
print outfile, A::description;
|
|
||||||
print outfile, A::tpe;
|
|
||||||
print outfile, A::s;
|
|
||||||
try = try + 1;
|
|
||||||
if (16 == try)
|
|
||||||
{
|
|
||||||
Input::remove(input);
|
|
||||||
close(outfile);
|
|
||||||
terminate();
|
|
||||||
}
|
|
||||||
|
|
||||||
}, error_ev=<uninitialized>, config={
|
|
||||||
|
|
||||||
}]
|
|
||||||
Input::EVENT_NEW
|
|
||||||
sdfs\d
|
|
||||||
[source=../input.log, reader=Input::READER_RAW, mode=Input::REREAD, name=input, fields=A::Val, want_record=F, ev=line
|
|
||||||
{
|
|
||||||
print outfile, A::description;
|
|
||||||
print outfile, A::tpe;
|
|
||||||
print outfile, A::s;
|
|
||||||
try = try + 1;
|
|
||||||
if (16 == try)
|
|
||||||
{
|
|
||||||
Input::remove(input);
|
|
||||||
close(outfile);
|
|
||||||
terminate();
|
|
||||||
}
|
|
||||||
|
|
||||||
}, error_ev=<uninitialized>, config={
|
|
||||||
|
|
||||||
}]
|
|
||||||
Input::EVENT_NEW
|
|
||||||
|
|
||||||
[source=../input.log, reader=Input::READER_RAW, mode=Input::REREAD, name=input, fields=A::Val, want_record=F, ev=line
|
|
||||||
{
|
|
||||||
print outfile, A::description;
|
|
||||||
print outfile, A::tpe;
|
|
||||||
print outfile, A::s;
|
|
||||||
try = try + 1;
|
|
||||||
if (16 == try)
|
|
||||||
{
|
|
||||||
Input::remove(input);
|
|
||||||
close(outfile);
|
|
||||||
terminate();
|
|
||||||
}
|
|
||||||
|
|
||||||
}, error_ev=<uninitialized>, config={
|
|
||||||
|
|
||||||
}]
|
|
||||||
Input::EVENT_NEW
|
|
||||||
dfsdf
|
|
||||||
[source=../input.log, reader=Input::READER_RAW, mode=Input::REREAD, name=input, fields=A::Val, want_record=F, ev=line
|
|
||||||
{
|
|
||||||
print outfile, A::description;
|
|
||||||
print outfile, A::tpe;
|
|
||||||
print outfile, A::s;
|
|
||||||
try = try + 1;
|
|
||||||
if (16 == try)
|
|
||||||
{
|
|
||||||
Input::remove(input);
|
|
||||||
close(outfile);
|
|
||||||
terminate();
|
|
||||||
}
|
|
||||||
|
|
||||||
}, error_ev=<uninitialized>, config={
|
|
||||||
|
|
||||||
}]
|
|
||||||
Input::EVENT_NEW
|
|
||||||
sdf
|
|
||||||
[source=../input.log, reader=Input::READER_RAW, mode=Input::REREAD, name=input, fields=A::Val, want_record=F, ev=line
|
|
||||||
{
|
|
||||||
print outfile, A::description;
|
|
||||||
print outfile, A::tpe;
|
|
||||||
print outfile, A::s;
|
|
||||||
try = try + 1;
|
|
||||||
if (16 == try)
|
|
||||||
{
|
|
||||||
Input::remove(input);
|
|
||||||
close(outfile);
|
|
||||||
terminate();
|
|
||||||
}
|
|
||||||
|
|
||||||
}, error_ev=<uninitialized>, config={
|
|
||||||
|
|
||||||
}]
|
|
||||||
Input::EVENT_NEW
|
|
||||||
3rw43wRRERLlL#RWERERERE.
|
|
||||||
[source=../input.log, reader=Input::READER_RAW, mode=Input::REREAD, name=input, fields=A::Val, want_record=F, ev=line
|
|
||||||
{
|
|
||||||
print outfile, A::description;
|
|
||||||
print outfile, A::tpe;
|
|
||||||
print outfile, A::s;
|
|
||||||
try = try + 1;
|
|
||||||
if (16 == try)
|
|
||||||
{
|
|
||||||
Input::remove(input);
|
|
||||||
close(outfile);
|
|
||||||
terminate();
|
|
||||||
}
|
|
||||||
|
|
||||||
}, error_ev=<uninitialized>, config={
|
|
||||||
|
|
||||||
}]
|
|
||||||
Input::EVENT_NEW
|
|
||||||
sdfkh:KH;fdkncv;ISEUp34:Fkdj;YVpIODhfDF
|
|
||||||
[source=../input.log, reader=Input::READER_RAW, mode=Input::REREAD, name=input, fields=A::Val, want_record=F, ev=line
|
|
||||||
{
|
|
||||||
print outfile, A::description;
|
|
||||||
print outfile, A::tpe;
|
|
||||||
print outfile, A::s;
|
|
||||||
try = try + 1;
|
|
||||||
if (16 == try)
|
|
||||||
{
|
|
||||||
Input::remove(input);
|
|
||||||
close(outfile);
|
|
||||||
terminate();
|
|
||||||
}
|
|
||||||
|
|
||||||
}, error_ev=<uninitialized>, config={
|
|
||||||
|
|
||||||
}]
|
|
||||||
Input::EVENT_NEW
|
|
||||||
DSF"DFKJ"SDFKLh304yrsdkfj@#(*U$34jfDJup3UF
|
|
||||||
[source=../input.log, reader=Input::READER_RAW, mode=Input::REREAD, name=input, fields=A::Val, want_record=F, ev=line
|
|
||||||
{
|
|
||||||
print outfile, A::description;
|
|
||||||
print outfile, A::tpe;
|
|
||||||
print outfile, A::s;
|
|
||||||
try = try + 1;
|
|
||||||
if (16 == try)
|
|
||||||
{
|
|
||||||
Input::remove(input);
|
|
||||||
close(outfile);
|
|
||||||
terminate();
|
|
||||||
}
|
|
||||||
|
|
||||||
}, error_ev=<uninitialized>, config={
|
|
||||||
|
|
||||||
}]
|
|
||||||
Input::EVENT_NEW
|
|
||||||
q3r3057fdf
|
|
||||||
[source=../input.log, reader=Input::READER_RAW, mode=Input::REREAD, name=input, fields=A::Val, want_record=F, ev=line
|
|
||||||
{
|
|
||||||
print outfile, A::description;
|
|
||||||
print outfile, A::tpe;
|
|
||||||
print outfile, A::s;
|
|
||||||
try = try + 1;
|
|
||||||
if (16 == try)
|
|
||||||
{
|
|
||||||
Input::remove(input);
|
|
||||||
close(outfile);
|
|
||||||
terminate();
|
|
||||||
}
|
|
||||||
|
|
||||||
}, error_ev=<uninitialized>, config={
|
|
||||||
|
|
||||||
}]
|
|
||||||
Input::EVENT_NEW
|
|
||||||
sdfs\d
|
|
||||||
[source=../input.log, reader=Input::READER_RAW, mode=Input::REREAD, name=input, fields=A::Val, want_record=F, ev=line
|
|
||||||
{
|
|
||||||
print outfile, A::description;
|
|
||||||
print outfile, A::tpe;
|
|
||||||
print outfile, A::s;
|
|
||||||
try = try + 1;
|
|
||||||
if (16 == try)
|
|
||||||
{
|
|
||||||
Input::remove(input);
|
|
||||||
close(outfile);
|
|
||||||
terminate();
|
|
||||||
}
|
|
||||||
|
|
||||||
}, error_ev=<uninitialized>, config={
|
|
||||||
|
|
||||||
}]
|
|
||||||
Input::EVENT_NEW
|
|
||||||
|
|
||||||
[source=../input.log, reader=Input::READER_RAW, mode=Input::REREAD, name=input, fields=A::Val, want_record=F, ev=line
|
|
||||||
{
|
|
||||||
print outfile, A::description;
|
|
||||||
print outfile, A::tpe;
|
|
||||||
print outfile, A::s;
|
|
||||||
try = try + 1;
|
|
||||||
if (16 == try)
|
|
||||||
{
|
|
||||||
Input::remove(input);
|
|
||||||
close(outfile);
|
|
||||||
terminate();
|
|
||||||
}
|
|
||||||
|
|
||||||
}, error_ev=<uninitialized>, config={
|
|
||||||
|
|
||||||
}]
|
|
||||||
Input::EVENT_NEW
|
|
||||||
dfsdf
|
|
||||||
[source=../input.log, reader=Input::READER_RAW, mode=Input::REREAD, name=input, fields=A::Val, want_record=F, ev=line
|
|
||||||
{
|
|
||||||
print outfile, A::description;
|
|
||||||
print outfile, A::tpe;
|
|
||||||
print outfile, A::s;
|
|
||||||
try = try + 1;
|
|
||||||
if (16 == try)
|
|
||||||
{
|
|
||||||
Input::remove(input);
|
|
||||||
close(outfile);
|
|
||||||
terminate();
|
|
||||||
}
|
|
||||||
|
|
||||||
}, error_ev=<uninitialized>, config={
|
|
||||||
|
|
||||||
}]
|
|
||||||
Input::EVENT_NEW
|
|
||||||
sdf
|
|
||||||
[source=../input.log, reader=Input::READER_RAW, mode=Input::REREAD, name=input, fields=A::Val, want_record=F, ev=line
|
|
||||||
{
|
|
||||||
print outfile, A::description;
|
|
||||||
print outfile, A::tpe;
|
|
||||||
print outfile, A::s;
|
|
||||||
try = try + 1;
|
|
||||||
if (16 == try)
|
|
||||||
{
|
|
||||||
Input::remove(input);
|
|
||||||
close(outfile);
|
|
||||||
terminate();
|
|
||||||
}
|
|
||||||
|
|
||||||
}, error_ev=<uninitialized>, config={
|
|
||||||
|
|
||||||
}]
|
|
||||||
Input::EVENT_NEW
|
|
||||||
3rw43wRRERLlL#RWERERERE.
|
|
||||||
|
|
|
@ -13,10 +13,16 @@ sdf
|
||||||
3rw43wRRERLlL#RWERERERE.
|
3rw43wRRERLlL#RWERERERE.
|
||||||
@TEST-END-FILE
|
@TEST-END-FILE
|
||||||
|
|
||||||
|
@TEST-START-FILE input2.log
|
||||||
|
Beginning of input2.log
|
||||||
|
3rw43wRRERLlL#RWERERERE.
|
||||||
|
game over
|
||||||
|
@TEST-END-FILE
|
||||||
|
|
||||||
|
redef Threading::heartbeat_interval = 100msec;
|
||||||
redef exit_only_after_terminate = T;
|
redef exit_only_after_terminate = T;
|
||||||
|
|
||||||
global outfile: file;
|
global outfile: file;
|
||||||
global try: count;
|
|
||||||
|
|
||||||
module A;
|
module A;
|
||||||
|
|
||||||
|
@ -24,13 +30,27 @@ type Val: record {
|
||||||
s: string;
|
s: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
event line(description: Input::EventDescription, tpe: Input::Event, s: string)
|
global end_of_datas = 0;
|
||||||
|
|
||||||
|
event Input::end_of_data(name: string, source: string)
|
||||||
{
|
{
|
||||||
print outfile, description;
|
++end_of_datas;
|
||||||
print outfile, tpe;
|
if ( end_of_datas > 1 )
|
||||||
print outfile, s;
|
return;
|
||||||
try = try + 1;
|
|
||||||
if ( try == 16 )
|
print outfile, "end_of_data, updating input.log";
|
||||||
|
# This should be recognized by the raw reader as file update (inode change)
|
||||||
|
# and the new file is reread.
|
||||||
|
system("mv ../input2.log ../input.log");
|
||||||
|
}
|
||||||
|
|
||||||
|
global lines = 0;
|
||||||
|
|
||||||
|
event A::line(description: Input::EventDescription, tpe: Input::Event, s: string)
|
||||||
|
{
|
||||||
|
++lines;
|
||||||
|
print outfile, lines, tpe, s, |s|;
|
||||||
|
if ( s == "game over" )
|
||||||
{
|
{
|
||||||
Input::remove("input");
|
Input::remove("input");
|
||||||
close(outfile);
|
close(outfile);
|
||||||
|
@ -40,8 +60,6 @@ event line(description: Input::EventDescription, tpe: Input::Event, s: string)
|
||||||
|
|
||||||
event zeek_init()
|
event zeek_init()
|
||||||
{
|
{
|
||||||
try = 0;
|
|
||||||
outfile = open("../out");
|
outfile = open("../out");
|
||||||
Input::add_event([$source="../input.log", $reader=Input::READER_RAW, $mode=Input::REREAD, $name="input", $fields=Val, $ev=line, $want_record=F]);
|
Input::add_event([$source="../input.log", $reader=Input::READER_RAW, $mode=Input::REREAD, $name="input", $fields=Val, $ev=A::line, $want_record=F]);
|
||||||
Input::force_update("input");
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue