From 4de6d76488e0d85f7085aa53528bee93b7d7b8b7 Mon Sep 17 00:00:00 2001 From: Bernhard Amann Date: Fri, 25 May 2012 11:30:18 -0700 Subject: [PATCH] fix up the executeraw test - now it works for the first time and does not always fail --- src/input/readers/Raw.cc | 10 ++++++++++ .../scripts.base.frameworks.input.executeraw/out | 9 +++++++++ .../scripts/base/frameworks/input/executeraw.bro | 16 ++++++++++------ 3 files changed, 29 insertions(+), 6 deletions(-) create mode 100644 testing/btest/Baseline/scripts.base.frameworks.input.executeraw/out diff --git a/src/input/readers/Raw.cc b/src/input/readers/Raw.cc index 43c782de29..ce0b4f8a5f 100644 --- a/src/input/readers/Raw.cc +++ b/src/input/readers/Raw.cc @@ -178,6 +178,12 @@ bool Raw::DoInit(string path, int arg_mode, int arg_num_fields, const Field* con bool Raw::GetLine(string& str) { + if ( in->peek() == std::iostream::traits_type::eof() ) + return false; + + if ( in->eofbit == true || in->failbit == true ) + return false; + while ( getline(*in, str, separator[0]) ) return true; @@ -247,6 +253,10 @@ bool Raw::DoUpdate() Put(fields); } +#ifdef DEBUG + Debug(DBG_INPUT, "DoUpdate finished successfully"); +#endif + return true; } diff --git a/testing/btest/Baseline/scripts.base.frameworks.input.executeraw/out b/testing/btest/Baseline/scripts.base.frameworks.input.executeraw/out new file mode 100644 index 0000000000..8611b35dd3 --- /dev/null +++ b/testing/btest/Baseline/scripts.base.frameworks.input.executeraw/out @@ -0,0 +1,9 @@ +[source=wc -l ../input.log |, reader=Input::READER_RAW, mode=Input::MANUAL, name=input, fields=, want_record=F, ev=line +{ +print outfile, description; +print outfile, tpe; +print outfile, s; +close(outfile); +}] +Input::EVENT_NEW + 8 ../input.log diff --git a/testing/btest/scripts/base/frameworks/input/executeraw.bro b/testing/btest/scripts/base/frameworks/input/executeraw.bro index 6fceebf885..6d07a9bf29 100644 --- a/testing/btest/scripts/base/frameworks/input/executeraw.bro +++ b/testing/btest/scripts/base/frameworks/input/executeraw.bro @@ -1,5 +1,6 @@ # -# @TEST-EXEC: bro -b %INPUT >out +# @TEST-EXEC: btest-bg-run bro bro -b %INPUT +# @TEST-EXEC: btest-bg-wait -k 1 # @TEST-EXEC: btest-diff out @TEST-START-FILE input.log @@ -13,21 +14,24 @@ sdf 3rw43wRRERLlL#RWERERERE. @TEST-END-FILE +@load frameworks/communication/listen -module A; +global outfile: file; type Val: record { s: string; }; event line(description: Input::EventDescription, tpe: Input::Event, s: string) { - print description; - print tpe; - print s; + print outfile, description; + print outfile, tpe; + print outfile, s; + close(outfile); } event bro_init() { - Input::add_event([$source="wc input.log |", $reader=Input::READER_RAW, $name="input", $fields=Val, $ev=line]); + outfile = open ("../out"); + Input::add_event([$source="wc -l ../input.log |", $reader=Input::READER_RAW, $name="input", $fields=Val, $ev=line]); Input::remove("input"); }