mirror of
https://github.com/zeek/zeek.git
synced 2025-10-17 22:18:20 +00:00
Merge branch 'topic/awelzel/3957-raw-reader-spinning'
* topic/awelzel/3957-raw-reader-spinning:
input/Raw: Rework GetLine()
(cherry picked from commit 2a23e9fc19
)
This commit is contained in:
parent
f5fefd17df
commit
300b7a11ac
12 changed files with 292 additions and 27 deletions
|
@ -0,0 +1,52 @@
|
|||
# @TEST-DOC: Launching a program that produces output slowly and strangely separated.
|
||||
# @TEST-EXEC: chmod +x run.sh
|
||||
# @TEST-EXEC: btest-bg-run zeek zeek -b %INPUT
|
||||
# @TEST-EXEC: btest-bg-wait 10
|
||||
# @TEST-EXEC: btest-diff zeek/.stdout
|
||||
|
||||
redef exit_only_after_terminate = T;
|
||||
|
||||
redef Threading::heartbeat_interval = 0.01sec;
|
||||
|
||||
@TEST-START-FILE run.sh
|
||||
#!/usr/bin/env bash
|
||||
echo -e -n "aaa\nb"
|
||||
sleep 0.1
|
||||
echo -e -n "bb\nfi"
|
||||
sleep 0.1
|
||||
echo "nal"
|
||||
|
||||
sleep infinity
|
||||
@TEST-END-FILE
|
||||
|
||||
module A;
|
||||
|
||||
type Val: record {
|
||||
s: string;
|
||||
};
|
||||
|
||||
global lines = 0;
|
||||
|
||||
event one_line(description: Input::EventDescription, tpe: Input::Event, s: string)
|
||||
{
|
||||
print tpe, s;
|
||||
++lines;
|
||||
|
||||
if ( lines == 3 )
|
||||
{
|
||||
Input::remove("input");
|
||||
terminate();
|
||||
}
|
||||
}
|
||||
|
||||
event zeek_init()
|
||||
{
|
||||
Input::add_event([
|
||||
$name="run",
|
||||
$source="../run.sh |",
|
||||
$reader=Input::READER_RAW,
|
||||
$mode=Input::STREAM,
|
||||
$fields=Val,
|
||||
$ev=one_line, $want_record=F,
|
||||
]);
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
# @TEST-DOC: Launching a program that doesn't end it's final line with a \n
|
||||
# @TEST-EXEC: chmod +x run.sh
|
||||
# @TEST-EXEC: btest-bg-run zeek zeek -b %INPUT
|
||||
# @TEST-EXEC: btest-bg-wait 10
|
||||
# @TEST-EXEC: btest-diff zeek/.stdout
|
||||
|
||||
redef exit_only_after_terminate = T;
|
||||
|
||||
redef Threading::heartbeat_interval = 0.01sec;
|
||||
|
||||
@TEST-START-FILE run.sh
|
||||
#!/usr/bin/env bash
|
||||
sleep 0.1
|
||||
echo "aaa"
|
||||
sleep 0.1
|
||||
echo "bbb"
|
||||
sleep 0.1
|
||||
echo -n "final"
|
||||
|
||||
sleep 0.1
|
||||
exit 0
|
||||
@TEST-END-FILE
|
||||
|
||||
module A;
|
||||
|
||||
type Val: record {
|
||||
s: string;
|
||||
};
|
||||
|
||||
global lines = 0;
|
||||
|
||||
event one_line(description: Input::EventDescription, tpe: Input::Event, s: string)
|
||||
{
|
||||
print tpe, s;
|
||||
++lines;
|
||||
if ( lines == 3 )
|
||||
{
|
||||
Input::remove("input");
|
||||
terminate();
|
||||
}
|
||||
}
|
||||
|
||||
event zeek_init()
|
||||
{
|
||||
Input::add_event([
|
||||
$name="run",
|
||||
$source="../run.sh |",
|
||||
$reader=Input::READER_RAW,
|
||||
$mode=Input::STREAM,
|
||||
$fields=Val,
|
||||
$ev=one_line, $want_record=F,
|
||||
]);
|
||||
}
|
|
@ -0,0 +1,62 @@
|
|||
# @TEST-DOC: Launching a program that produces output slowly and exercises buffering.
|
||||
# @TEST-EXEC: chmod +x run.sh
|
||||
# @TEST-EXEC: btest-bg-run zeek zeek -b %INPUT
|
||||
# @TEST-EXEC: btest-bg-wait 10
|
||||
# @TEST-EXEC: btest-diff zeek/.stdout
|
||||
|
||||
redef exit_only_after_terminate = T;
|
||||
|
||||
redef Threading::heartbeat_interval = 0.01sec;
|
||||
|
||||
@TEST-START-FILE run.sh
|
||||
#!/usr/bin/env bash
|
||||
sleep 0.1
|
||||
echo -n "binary start"
|
||||
sleep 0.1
|
||||
dd if=/dev/zero bs=1 count=8192
|
||||
sleep 0.1
|
||||
echo -n "binary middle"
|
||||
sleep 0.1
|
||||
dd if=/dev/zero bs=1 count=8192
|
||||
sleep 0.1
|
||||
dd if=/dev/zero bs=1 count=8192
|
||||
sleep 0.1
|
||||
echo "binary done"
|
||||
sleep 0.1
|
||||
echo "ccc"
|
||||
sleep 0.1
|
||||
echo "final"
|
||||
|
||||
sleep infinity
|
||||
@TEST-END-FILE
|
||||
|
||||
module A;
|
||||
|
||||
type Val: record {
|
||||
s: string;
|
||||
};
|
||||
|
||||
global lines = 0;
|
||||
|
||||
event one_line(description: Input::EventDescription, tpe: Input::Event, s: string)
|
||||
{
|
||||
print tpe,|s|, s[:16], s[-16:];
|
||||
++lines;
|
||||
if ( lines == 3 )
|
||||
{
|
||||
Input::remove("input");
|
||||
terminate();
|
||||
}
|
||||
}
|
||||
|
||||
event zeek_init()
|
||||
{
|
||||
Input::add_event([
|
||||
$name="run",
|
||||
$source="../run.sh |",
|
||||
$reader=Input::READER_RAW,
|
||||
$mode=Input::STREAM,
|
||||
$fields=Val,
|
||||
$ev=one_line, $want_record=F,
|
||||
]);
|
||||
}
|
|
@ -0,0 +1,55 @@
|
|||
# @TEST-DOC: Launching a program that produces output slowly puts the raw reader into an endless loop.
|
||||
# @TEST-EXEC: chmod +x run.sh
|
||||
# @TEST-EXEC: btest-bg-run zeek zeek -b %INPUT
|
||||
# @TEST-EXEC: btest-bg-wait 10
|
||||
# @TEST-EXEC: btest-diff zeek/.stdout
|
||||
|
||||
redef exit_only_after_terminate = T;
|
||||
|
||||
redef Threading::heartbeat_interval = 0.01sec;
|
||||
|
||||
@TEST-START-FILE run.sh
|
||||
#!/usr/bin/env bash
|
||||
sleep 0.1
|
||||
echo -n "aaa-"
|
||||
sleep 0.1
|
||||
echo -n "bbb-"
|
||||
sleep 0.1
|
||||
echo "ccc"
|
||||
sleep 0.1
|
||||
echo "aaa-bbb-ccc"
|
||||
echo "final"
|
||||
|
||||
sleep infinity
|
||||
@TEST-END-FILE
|
||||
|
||||
module A;
|
||||
|
||||
type Val: record {
|
||||
s: string;
|
||||
};
|
||||
|
||||
global lines = 0;
|
||||
|
||||
event one_line(description: Input::EventDescription, tpe: Input::Event, s: string)
|
||||
{
|
||||
print tpe, s;
|
||||
++lines;
|
||||
if ( lines == 3 )
|
||||
{
|
||||
Input::remove("input");
|
||||
terminate();
|
||||
}
|
||||
}
|
||||
|
||||
event zeek_init()
|
||||
{
|
||||
Input::add_event([
|
||||
$name="run",
|
||||
$source="../run.sh |",
|
||||
$reader=Input::READER_RAW,
|
||||
$mode=Input::STREAM,
|
||||
$fields=Val,
|
||||
$ev=one_line, $want_record=F,
|
||||
]);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue