Update plugin btests for namespace changes

This commit is contained in:
Tim Wojtulewicz 2020-08-21 18:10:39 +00:00
parent 70c2397f69
commit 874e170341
43 changed files with 420 additions and 317 deletions

View file

@ -8,17 +8,17 @@
#include <Desc.h>
#include <threading/Formatter.h>
namespace plugin { namespace Demo_Hooks { Plugin plugin; } }
namespace btest::plugin::Demo_Hooks { Plugin plugin; }
using namespace plugin::Demo_Hooks;
using namespace btest::plugin::Demo_Hooks;
plugin::Configuration Plugin::Configure()
zeek::plugin::Configuration Plugin::Configure()
{
EnableHook(HOOK_CALL_FUNCTION);
EnableHook(META_HOOK_PRE);
EnableHook(META_HOOK_POST);
EnableHook(zeek::plugin::HOOK_CALL_FUNCTION);
EnableHook(zeek::plugin::META_HOOK_PRE);
EnableHook(zeek::plugin::META_HOOK_POST);
plugin::Configuration config;
zeek::plugin::Configuration config;
config.name = "Demo::Hooks";
config.description = "Exercises all plugin hooks";
config.version.major = 1;
@ -27,7 +27,7 @@ plugin::Configuration Plugin::Configure()
return config;
}
static void describe_hook_args(const plugin::HookArgumentList& args, ODesc* d)
static void describe_hook_args(const zeek::plugin::HookArgumentList& args, zeek::ODesc* d)
{
bool first = true;
@ -41,20 +41,21 @@ static void describe_hook_args(const plugin::HookArgumentList& args, ODesc* d)
}
}
std::pair<bool, Val*> Plugin::HookCallFunction(const Func* func, Frame* frame, val_list* args)
std::pair<bool, zeek::Val*> Plugin::HookCallFunction(const zeek::Func* func, zeek::detail::Frame* frame,
zeek::ValPList* args)
{
ODesc d;
zeek::ODesc d;
d.SetShort();
HookArgument(func).Describe(&d);
HookArgument(args).Describe(&d);
fprintf(stderr, "%.6f %-15s %s\n", network_time, "| HookCallFunction",
zeek::plugin::HookArgument(func).Describe(&d);
zeek::plugin::HookArgument(args).Describe(&d);
fprintf(stderr, "%.6f %-15s %s\n", zeek::run_state::network_time, "| HookCallFunction",
d.Description());
if ( streq(func->Name(), "foo") )
if ( zeek::util::streq(func->Name(), "foo") )
{
auto& vl = *args;
Unref(vl[0]);
vl[0] = val_mgr->Count(13).release();
vl[0] = zeek::val_mgr->Count(13).release();
}
return {};
@ -64,11 +65,11 @@ std::pair<bool, Val*> Plugin::HookCallFunction(const Func* func, Frame* frame, v
/* Frame* frame, */
/* zeek::Args* args) */
/* { */
/* ODesc d; */
/* zeek::ODesc d; */
/* d.SetShort(); */
/* HookArgument(func).Describe(&d); */
/* HookArgument(args).Describe(&d); */
/* fprintf(stderr, "%.6f %-15s %s\n", network_time, "| HookFunctionCall", */
/* fprintf(stderr, "%.6f %-15s %s\n", zeek::run_state::network_time, "| HookFunctionCall", */
/* d.Description()); */
/* if ( streq(func->Name(), "foo") ) */
@ -82,25 +83,25 @@ std::pair<bool, Val*> Plugin::HookCallFunction(const Func* func, Frame* frame, v
void Plugin::MetaHookPre(zeek::plugin::HookType hook, const zeek::plugin::HookArgumentList& args)
{
ODesc d;
zeek::ODesc d;
d.SetShort();
describe_hook_args(args, &d);
fprintf(stderr, "%.6f %-15s %s(%s)\n", network_time, " MetaHookPre",
fprintf(stderr, "%.6f %-15s %s(%s)\n", zeek::run_state::network_time, " MetaHookPre",
hook_name(hook), d.Description());
}
void Plugin::MetaHookPost(zeek::plugin::HookType hook, const zeek::plugin::HookArgumentList& args,
zeek::plugin::HookArgument result)
{
ODesc d1;
zeek::ODesc d1;
d1.SetShort();
describe_hook_args(args, &d1);
ODesc d2;
zeek::ODesc d2;
d2.SetShort();
result.Describe(&d2);
fprintf(stderr, "%.6f %-15s %s(%s) -> %s\n", network_time, " MetaHookPost",
fprintf(stderr, "%.6f %-15s %s(%s) -> %s\n", zeek::run_state::network_time, " MetaHookPost",
hook_name(hook), d1.Description(),
d2.Description());
}