mirror of
https://github.com/zeek/zeek.git
synced 2025-10-06 08:38:20 +00:00
Adapting plugin tests to use the new split Plugin.{h,cc} structure
that init-plugin now generates. Also adding new test that makes sure the the skeleton created by init-plugin compiles on its own withoyt any further changes.
This commit is contained in:
parent
2a49932911
commit
ca1b882761
7 changed files with 98 additions and 82 deletions
|
@ -1 +1 @@
|
|||
Subproject commit 32e8ea92f0880b09821bc5e18406920676aa28a8
|
||||
Subproject commit 315d7a2ab10f3ff1025e813dca156e7eaff35cef
|
3
testing/btest/Baseline/plugins.init-plugin/output
Normal file
3
testing/btest/Baseline/plugins.init-plugin/output
Normal file
|
@ -0,0 +1,3 @@
|
|||
Demo::Foo - <Insert description> (dynamic, version 1.0)
|
||||
|
||||
===
|
|
@ -1,14 +1,13 @@
|
|||
|
||||
#include <plugin/Plugin.h>
|
||||
#include "Plugin.h"
|
||||
|
||||
#include "Foo.h"
|
||||
|
||||
namespace plugin {
|
||||
namespace Demo_Foo {
|
||||
namespace plugin { namespace Demo_Foo { Plugin plugin; } }
|
||||
|
||||
class Plugin : public plugin::Plugin {
|
||||
public:
|
||||
plugin::Configuration Configure()
|
||||
using namespace plugin::Demo_Foo;
|
||||
|
||||
plugin::Configuration Plugin::Configure()
|
||||
{
|
||||
AddComponent(new ::file_analysis::Component("Foo", ::plugin::Demo_Foo::Foo::Instantiate));
|
||||
|
||||
|
@ -19,7 +18,3 @@ public:
|
|||
config.version.minor = 0;
|
||||
return config;
|
||||
}
|
||||
} plugin;
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,16 +1,14 @@
|
|||
|
||||
#include <plugin/Plugin.h>
|
||||
#include "Plugin.h"
|
||||
|
||||
#include <Func.h>
|
||||
#include <Event.h>
|
||||
|
||||
namespace plugin {
|
||||
namespace Demo_Hooks {
|
||||
namespace plugin { namespace Demo_Hooks { Plugin plugin; } }
|
||||
|
||||
class Plugin : public plugin::Plugin
|
||||
{
|
||||
protected:
|
||||
plugin::Configuration Configure()
|
||||
using namespace plugin::Demo_Hooks;
|
||||
|
||||
plugin::Configuration Plugin::Configure()
|
||||
{
|
||||
EnableHook(HOOK_LOAD_FILE);
|
||||
EnableHook(HOOK_CALL_FUNCTION);
|
||||
|
@ -29,22 +27,11 @@ protected:
|
|||
return config;
|
||||
}
|
||||
|
||||
virtual int HookLoadFile(const std::string& file, const std::string& ext);
|
||||
virtual Val* HookCallFunction(const Func* func, val_list* args);
|
||||
virtual bool HookQueueEvent(Event* event);
|
||||
virtual void HookDrainEvents();
|
||||
virtual void HookUpdateNetworkTime(double network_time);
|
||||
virtual void HookBroObjDtor(void* obj);
|
||||
virtual void MetaHookPre(HookType hook, const HookArgumentList& args);
|
||||
virtual void MetaHookPost(HookType hook, const HookArgumentList& args, HookArgument result);
|
||||
|
||||
} plugin;
|
||||
|
||||
static void describe_hook_args(const HookArgumentList& args, ODesc* d)
|
||||
static void describe_hook_args(const plugin::HookArgumentList& args, ODesc* d)
|
||||
{
|
||||
bool first = true;
|
||||
|
||||
for ( HookArgumentList::const_iterator i = args.begin(); i != args.end(); i++ )
|
||||
for ( plugin::HookArgumentList::const_iterator i = args.begin(); i != args.end(); i++ )
|
||||
{
|
||||
if ( ! first )
|
||||
d->Add(", ");
|
||||
|
@ -83,9 +70,11 @@ bool Plugin::HookQueueEvent(Event* event)
|
|||
|
||||
static int i = 0;
|
||||
|
||||
if ( network_time && i == 0 ) {
|
||||
if ( network_time && i == 0 )
|
||||
{
|
||||
fprintf(stderr, "%.6f %-15s %s\n", network_time, "| RequestObjDtor",
|
||||
d.Description());
|
||||
|
||||
RequestBroObjDtor(event);
|
||||
i = 1;
|
||||
}
|
||||
|
@ -132,6 +121,3 @@ void Plugin::MetaHookPost(HookType hook, const HookArgumentList& args, HookArgum
|
|||
hook_name(hook), d1.Description(),
|
||||
d2.Description());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
31
testing/btest/plugins/hooks-plugin/src/Plugin.h
Normal file
31
testing/btest/plugins/hooks-plugin/src/Plugin.h
Normal file
|
@ -0,0 +1,31 @@
|
|||
|
||||
#ifndef BRO_PLUGIN_Demo_Hooks
|
||||
#define BRO_PLUGIN_Demo_Hooks
|
||||
|
||||
#include <plugin/Plugin.h>
|
||||
|
||||
namespace plugin {
|
||||
namespace Demo_Hooks {
|
||||
|
||||
class Plugin : public ::plugin::Plugin
|
||||
{
|
||||
protected:
|
||||
virtual int HookLoadFile(const std::string& file, const std::string& ext);
|
||||
virtual Val* HookCallFunction(const Func* func, val_list* args);
|
||||
virtual bool HookQueueEvent(Event* event);
|
||||
virtual void HookDrainEvents();
|
||||
virtual void HookUpdateNetworkTime(double network_time);
|
||||
virtual void HookBroObjDtor(void* obj);
|
||||
virtual void MetaHookPre(HookType hook, const HookArgumentList& args);
|
||||
virtual void MetaHookPost(HookType hook, const HookArgumentList& args, HookArgument result);
|
||||
|
||||
// Overridden from plugin::Plugin.
|
||||
virtual plugin::Configuration Configure();
|
||||
};
|
||||
|
||||
extern Plugin plugin;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
6
testing/btest/plugins/init-plugin.bro
Normal file
6
testing/btest/plugins/init-plugin.bro
Normal file
|
@ -0,0 +1,6 @@
|
|||
# @TEST-EXEC: ${DIST}/aux/bro-aux/plugin-support/init-plugin Demo Foo
|
||||
# @TEST-EXEC: make BRO=${DIST}
|
||||
# @TEST-EXEC: BRO_PLUGIN_PATH=`pwd` bro -NN Demo::Foo >>output
|
||||
# @TEST-EXEC: echo === >>output
|
||||
# @TEST-EXEC: BRO_PLUGIN_PATH=`pwd` bro -r $TRACES/port4242.trace >>output
|
||||
# @TEST-EXEC: TEST_DIFF_CANONIFIER= btest-diff output
|
|
@ -1,14 +1,13 @@
|
|||
|
||||
#include <plugin/Plugin.h>
|
||||
#include "Plugin.h"
|
||||
|
||||
#include "Foo.h"
|
||||
|
||||
namespace plugin {
|
||||
namespace Demo_Foo {
|
||||
namespace plugin { namespace Demo_Foo { Plugin plugin; } }
|
||||
|
||||
class Plugin : public plugin::Plugin {
|
||||
public:
|
||||
plugin::Configuration Configure()
|
||||
using namespace plugin::Demo_Foo;
|
||||
|
||||
plugin::Configuration Plugin::Configure()
|
||||
{
|
||||
AddComponent(new ::analyzer::Component("Foo", plugin::Demo_Foo::Foo::Instantiate));
|
||||
|
||||
|
@ -19,7 +18,3 @@ public:
|
|||
config.version.minor = 0;
|
||||
return config;
|
||||
}
|
||||
} plugin;
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue