mirror of
https://github.com/zeek/zeek.git
synced 2025-10-05 08:08:19 +00:00
Updating tests and tweaking HookArgument to include Frame support.
* Add frame support to HookArgument, since it's a new argument to HookCallFunction * Fix test in api-version-mismatch to remove absolute paths from output * Update test plugin to use new HookCallFunction interface
This commit is contained in:
parent
0104d7147d
commit
70c7258dfa
7 changed files with 879 additions and 899 deletions
|
@ -83,6 +83,13 @@ void HookArgument::Describe(ODesc* d) const
|
|||
d->Add("<null>");
|
||||
break;
|
||||
|
||||
case FRAME:
|
||||
if ( arg.frame )
|
||||
arg.frame->Describe(d);
|
||||
else
|
||||
d->Add("<null>");
|
||||
break;
|
||||
|
||||
case FUNC:
|
||||
if ( arg.func )
|
||||
d->Add(arg.func->Name());
|
||||
|
@ -106,21 +113,6 @@ void HookArgument::Describe(ODesc* d) const
|
|||
d->Add("<null>");
|
||||
break;
|
||||
|
||||
case WRAPPED_VAL:
|
||||
if ( arg.wrapper )
|
||||
{
|
||||
d->Add("wrapped(");
|
||||
if(arg.wrapper->value)
|
||||
{
|
||||
arg.wrapper->value->Describe(d);
|
||||
}
|
||||
else
|
||||
d->Add("<null>");
|
||||
d->Add(")");
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case VAL_LIST:
|
||||
if ( arg.vals )
|
||||
{
|
||||
|
@ -139,6 +131,26 @@ void HookArgument::Describe(ODesc* d) const
|
|||
case VOIDP:
|
||||
d->Add("<void ptr>");
|
||||
break;
|
||||
|
||||
case WRAPPED_VAL:
|
||||
if ( arg.wrapper )
|
||||
{
|
||||
d->Add("wrapped(");
|
||||
if(arg.wrapper->value)
|
||||
{
|
||||
arg.wrapper->value->Describe(d);
|
||||
}
|
||||
else
|
||||
d->Add("<null>");
|
||||
d->Add(")");
|
||||
}
|
||||
else
|
||||
{
|
||||
d->Add("<null>");
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -184,7 +184,7 @@ public:
|
|||
* Type of the argument.
|
||||
*/
|
||||
enum Type {
|
||||
BOOL, DOUBLE, EVENT, FUNC, INT, STRING, VAL, WRAPPED_VAL, VAL_LIST, VOID, VOIDP,
|
||||
BOOL, DOUBLE, EVENT, FRAME, FUNC, INT, STRING, VAL, VAL_LIST, VOID, VOIDP, WRAPPED_VAL
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -242,6 +242,11 @@ public:
|
|||
*/
|
||||
HookArgument(ValWrapper* a) { type = WRAPPED_VAL; arg.wrapper = a; }
|
||||
|
||||
/**
|
||||
* Constructor with a Frame argument.
|
||||
*/
|
||||
HookArgument(Frame* f) { type = FRAME; arg.frame = f; }
|
||||
|
||||
/**
|
||||
* Returns the value for a boolen argument. The argument's type must
|
||||
* match accordingly.
|
||||
|
@ -290,6 +295,12 @@ public:
|
|||
*/
|
||||
const ValWrapper* AsValWrapper() const { assert(type == VAL_WRAPPER); return arg.wrapper; }
|
||||
|
||||
/**
|
||||
* Returns the value for a Bro frame argument. The argument's type must
|
||||
* match accordingly.
|
||||
*/
|
||||
const Frame* AsFrame() const { assert(type == FRAME); return arg.frame; }
|
||||
|
||||
/**
|
||||
* Returns the value for a list of Bro values argument. The argument's type must
|
||||
* match accordingly.
|
||||
|
@ -321,6 +332,7 @@ private:
|
|||
double double_;
|
||||
const Event* event;
|
||||
const Func* func;
|
||||
const Frame* frame;
|
||||
int int_;
|
||||
const Val* val;
|
||||
const ValWrapper* wrapper;
|
||||
|
|
|
@ -1 +1 @@
|
|||
fatal error in /home/robin/bro/master/scripts/base/init-bare.bro, line 1: plugin's API version does not match Bro (expected 2, got 42 in /home/robin/bro/master/testing/btest/.tmp/plugins.api-version-mismatch//lib/Demo-Foo.linux-x86_64.so)
|
||||
fatal error in XXX line 1: plugin's API version does not match Bro (expected 2, got 42 in XXX
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -2,6 +2,7 @@
|
|||
# @TEST-EXEC: bash %INPUT
|
||||
# @TEST-EXEC: ./configure --bro-dist=${DIST} && make
|
||||
# @TEST-EXEC-FAIL: BRO_PLUGIN_PATH=`pwd` bro -NN Demo::Foo >>output 2>&1
|
||||
# @TEST-EXEC: cat output | sed 's/\/[^ ]*/XXX/g' > output.2 && mv -f output.2 output
|
||||
# @TEST-EXEC: btest-diff output
|
||||
|
||||
( echo '#define BRO_PLUGIN_API_VERSION 42'; cat src/Plugin.cc; ) >src/Plugin.cc.tmp && mv src/Plugin.cc.tmp src/Plugin.cc
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
#include <Event.h>
|
||||
|
||||
namespace plugin { namespace Demo_Hooks { Plugin plugin; } }
|
||||
using plugin::ValWrapper;
|
||||
|
||||
using namespace plugin::Demo_Hooks;
|
||||
|
||||
|
@ -48,7 +49,7 @@ int Plugin::HookLoadFile(const std::string& file, const std::string& ext)
|
|||
return -1;
|
||||
}
|
||||
|
||||
Val* Plugin::HookCallFunction(const Func* func, Frame* frame, val_list* args)
|
||||
ValWrapper* Plugin::HookCallFunction(const Func* func, Frame* frame, val_list* args)
|
||||
{
|
||||
ODesc d;
|
||||
d.SetShort();
|
||||
|
|
|
@ -11,7 +11,7 @@ class Plugin : public ::plugin::Plugin
|
|||
{
|
||||
protected:
|
||||
virtual int HookLoadFile(const std::string& file, const std::string& ext);
|
||||
virtual Val* HookCallFunction(const Func* func, Frame* frame, val_list* args);
|
||||
virtual plugin::ValWrapper* HookCallFunction(const Func* func, Frame* frame, val_list* args);
|
||||
virtual bool HookQueueEvent(Event* event);
|
||||
virtual void HookDrainEvents();
|
||||
virtual void HookUpdateNetworkTime(double network_time);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue